iodine 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of iodine might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/examples/pubsub_engine.ru +2 -2
- data/ext/iodine/fio.c +2 -2
- data/ext/iodine/fio.h +67 -35
- data/ext/iodine/fiobject.c +2 -2
- data/ext/iodine/iodine.c +1 -1
- data/ext/iodine/iodine_defer.c +6 -6
- data/ext/iodine/iodine_http.c +3 -2
- data/ext/iodine/iodine_json.c +4 -3
- data/ext/iodine/iodine_mustache.c +1 -1
- data/ext/iodine/iodine_pubsub.c +3 -25
- data/ext/iodine/iodine_store.c +1 -1
- data/lib/iodine/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21610266b95f78b98341f1cfad626edec6f6aa903befe8c8ba6defa863c650ed
|
4
|
+
data.tar.gz: 2260a4db63a0a833d2d6902d3f54aed522d67f33378904caedd1c77eb6517c3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b5ac545d5b135548e5c781fb0212afba358b55b7e7b497212cfabd07924b56549fdb85a892162ae1c7e0f0be0d93d0d18c38bdb36d7f64c67fd5266fa1c307
|
7
|
+
data.tar.gz: ae58b456d93c90037847867d62b4f2243599618f5a9445a8c5b143c747567c96479881ee4571eea3ba58ea92d54091c76141eb33d96693fd5baf65333c9c98ea
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ Please notice that this change log contains changes for upcoming releases as wel
|
|
6
6
|
|
7
7
|
## Changes:
|
8
8
|
|
9
|
+
#### Change log v.0.7.5
|
10
|
+
|
11
|
+
**Fix**: fixed issue with direct calls to `publish` in the pre-defined pub/sub engines. These direct calls are used by custom engines when the default engine was replaced and would attempt (erroneously) direct engine access rather than use the `fio_publish` function.
|
12
|
+
|
13
|
+
**Fix**: fixed possible Array overflow risk that could result in memory corruption in some cases.
|
14
|
+
|
15
|
+
**Fix**: fixed more missing `static` keywords in the code. these should have little or no effect on the namespace (they were using long unique names with the `iodine` prefix).
|
16
|
+
|
9
17
|
#### Change log v.0.7.4
|
10
18
|
|
11
19
|
**Fix**: fixed a missing `static` keyword in the Ruby<=>C storage bridge which caused performance degradation and introduced namespace conflict risks.
|
data/examples/pubsub_engine.ru
CHANGED
@@ -7,7 +7,7 @@ require 'iodine'
|
|
7
7
|
class PubSubReporter < Iodine::PubSub::Engine
|
8
8
|
def initialize
|
9
9
|
# make sure engine setup is complete
|
10
|
-
super
|
10
|
+
super
|
11
11
|
# register engine and make it into the new default
|
12
12
|
@target = Iodine::PubSub.default
|
13
13
|
Iodine::PubSub.default = self
|
@@ -20,7 +20,7 @@ class PubSubReporter < Iodine::PubSub::Engine
|
|
20
20
|
puts "* Unsubscribing to \"#{to}\" (#{as || "exact match"})"
|
21
21
|
end
|
22
22
|
def publish to, msg
|
23
|
-
puts "* Publishing to \"#{to}\": #{msg.to_s[0..
|
23
|
+
puts "* Publishing to \"#{to}\": #{msg.to_s[0..12]}..."
|
24
24
|
# we need to forward the message to the actual engine (the previous default engine),
|
25
25
|
# or it will never be received by any Pub/Sub client.
|
26
26
|
@target.publish to, msg
|
data/ext/iodine/fio.c
CHANGED
@@ -224,9 +224,9 @@ typedef struct {
|
|
224
224
|
|
225
225
|
/** The logging level */
|
226
226
|
#if DEBUG
|
227
|
-
|
227
|
+
int FIO_LOG_LEVEL = FIO_LOG_LEVEL_DEBUG;
|
228
228
|
#else
|
229
|
-
|
229
|
+
int FIO_LOG_LEVEL = FIO_LOG_LEVEL_INFO;
|
230
230
|
#endif
|
231
231
|
static fio_data_s *fio_data = NULL;
|
232
232
|
|
data/ext/iodine/fio.h
CHANGED
@@ -319,6 +319,22 @@ void *fio_mmap(size_t size);
|
|
319
319
|
*/
|
320
320
|
void fio_malloc_after_fork(void);
|
321
321
|
|
322
|
+
#if FIO_FORCE_MALLOC
|
323
|
+
#define FIO_MALLOC(size) malloc((size))
|
324
|
+
#define FIO_CALLOC(size, units) calloc((size), (units))
|
325
|
+
#define FIO_REALLOC(ptr, new_length, existing_data_length) \
|
326
|
+
realloc((ptr), (new_length))
|
327
|
+
#define FIO_FREE free
|
328
|
+
|
329
|
+
#else
|
330
|
+
#define FIO_MALLOC(size) fio_malloc((size))
|
331
|
+
#define FIO_CALLOC(size, units) fio_calloc((size), (units))
|
332
|
+
#define FIO_REALLOC(ptr, new_length, existing_data_length) \
|
333
|
+
fio_realloc2((ptr), (new_length), (existing_data_length))
|
334
|
+
#define FIO_FREE fio_free
|
335
|
+
|
336
|
+
#endif
|
337
|
+
|
322
338
|
/* *****************************************************************************
|
323
339
|
|
324
340
|
|
@@ -361,13 +377,23 @@ Logging and testing helpers
|
|
361
377
|
#define FIO_LOG_LEVEL_DEBUG 5
|
362
378
|
|
363
379
|
/** The logging level */
|
364
|
-
extern
|
380
|
+
extern int FIO_LOG_LEVEL;
|
365
381
|
|
366
382
|
#ifndef FIO_LOG_PRINT
|
367
383
|
#define FIO_LOG_PRINT(level, ...) \
|
368
384
|
do { \
|
369
|
-
if (level <= FIO_LOG_LEVEL)
|
370
|
-
|
385
|
+
if (level <= FIO_LOG_LEVEL) { \
|
386
|
+
char tmp___log[512]; \
|
387
|
+
int len___log = snprintf(tmp___log, 500, __VA_ARGS__); \
|
388
|
+
if (len___log <= 0 || len___log > 500) { \
|
389
|
+
fwrite("ERROR: log line output too long (can't write).", 46, 1, \
|
390
|
+
stderr); \
|
391
|
+
break; \
|
392
|
+
} \
|
393
|
+
tmp___log[len___log++] = '\n'; \
|
394
|
+
tmp___log[len___log] = '0'; \
|
395
|
+
fwrite(tmp___log, len___log, 1, stderr); \
|
396
|
+
} \
|
371
397
|
} while (0)
|
372
398
|
#define FIO_LOG_DEBUG(...) \
|
373
399
|
FIO_LOG_PRINT(FIO_LOG_LEVEL_DEBUG, \
|
@@ -384,7 +410,7 @@ extern size_t FIO_LOG_LEVEL;
|
|
384
410
|
#endif
|
385
411
|
|
386
412
|
#if FIO_PRINT_STATE
|
387
|
-
#define FIO_LOG_STATE(...)
|
413
|
+
#define FIO_LOG_STATE(...) FIO_LOG_PRINT(0, __VA_ARGS__)
|
388
414
|
#else
|
389
415
|
#define FIO_LOG_STATE(...)
|
390
416
|
#endif
|
@@ -1022,12 +1048,12 @@ inline FIO_FUNC ssize_t fio_write(const intptr_t uuid, const void *buffer,
|
|
1022
1048
|
const size_t length) {
|
1023
1049
|
if (!length || !buffer)
|
1024
1050
|
return 0;
|
1025
|
-
void *cpy =
|
1051
|
+
void *cpy = FIO_MALLOC(length);
|
1026
1052
|
if (!cpy)
|
1027
1053
|
return -1;
|
1028
1054
|
memcpy(cpy, buffer, length);
|
1029
1055
|
return fio_write2(uuid, .data.buffer = cpy, .length = length,
|
1030
|
-
.after.dealloc =
|
1056
|
+
.after.dealloc = FIO_FREE);
|
1031
1057
|
}
|
1032
1058
|
|
1033
1059
|
/**
|
@@ -2981,7 +3007,7 @@ typedef struct {
|
|
2981
3007
|
((fio_str_s){.data = (buffer), \
|
2982
3008
|
.len = (length), \
|
2983
3009
|
.capa = (capacity), \
|
2984
|
-
.dealloc =
|
3010
|
+
.dealloc = FIO_FREE})
|
2985
3011
|
|
2986
3012
|
/**
|
2987
3013
|
* This macro allows the container to be initialized with existing data, as long
|
@@ -3285,7 +3311,7 @@ inline FIO_FUNC fio_str_info_s fio_str_info(const fio_str_s *s) {
|
|
3285
3311
|
* NOTE: This makes the allocation and reference counting logic more intuitive.
|
3286
3312
|
*/
|
3287
3313
|
inline FIO_FUNC fio_str_s *fio_str_new2(void) {
|
3288
|
-
fio_str_s *str =
|
3314
|
+
fio_str_s *str = FIO_MALLOC(sizeof(*str));
|
3289
3315
|
FIO_ASSERT_ALLOC(str);
|
3290
3316
|
*str = FIO_STR_INIT;
|
3291
3317
|
return str;
|
@@ -3358,7 +3384,7 @@ FIO_FUNC void fio_str_free2(fio_str_s *s) {
|
|
3358
3384
|
if (fio_str_free(s)) {
|
3359
3385
|
return;
|
3360
3386
|
}
|
3361
|
-
|
3387
|
+
FIO_FREE(s);
|
3362
3388
|
}
|
3363
3389
|
|
3364
3390
|
/** Returns the String's length in bytes. */
|
@@ -3457,11 +3483,11 @@ FIO_FUNC fio_str_info_s fio_str_capa_assert(fio_str_s *s, size_t needed) {
|
|
3457
3483
|
}
|
3458
3484
|
if (needed > s->capa) {
|
3459
3485
|
needed = ROUND_UP_CAPA2WORDS(needed);
|
3460
|
-
if (s->dealloc ==
|
3461
|
-
tmp = (char *)
|
3486
|
+
if (s->dealloc == FIO_FREE) {
|
3487
|
+
tmp = (char *)FIO_REALLOC(s->data, needed + 1, s->len);
|
3462
3488
|
FIO_ASSERT_ALLOC(tmp);
|
3463
3489
|
} else {
|
3464
|
-
tmp = (char *)
|
3490
|
+
tmp = (char *)FIO_MALLOC(needed + 1);
|
3465
3491
|
FIO_ASSERT_ALLOC(tmp);
|
3466
3492
|
memcpy(tmp, s->data, s->len);
|
3467
3493
|
if (s->dealloc)
|
@@ -3482,7 +3508,7 @@ is_small:
|
|
3482
3508
|
.data = FIO_STR_SMALL_DATA(s)};
|
3483
3509
|
}
|
3484
3510
|
needed = ROUND_UP_CAPA2WORDS(needed);
|
3485
|
-
tmp = (char *)
|
3511
|
+
tmp = (char *)FIO_MALLOC(needed + 1);
|
3486
3512
|
FIO_ASSERT_ALLOC(tmp);
|
3487
3513
|
const size_t existing_len = (size_t)((s->small >> 1) & 0xFF);
|
3488
3514
|
if (existing_len) {
|
@@ -3495,7 +3521,7 @@ is_small:
|
|
3495
3521
|
.small = 0,
|
3496
3522
|
.capa = needed,
|
3497
3523
|
.len = existing_len,
|
3498
|
-
.dealloc =
|
3524
|
+
.dealloc = FIO_FREE,
|
3499
3525
|
.data = tmp,
|
3500
3526
|
};
|
3501
3527
|
#else
|
@@ -3504,7 +3530,7 @@ is_small:
|
|
3504
3530
|
.small = 0,
|
3505
3531
|
.capa = needed,
|
3506
3532
|
.len = existing_len,
|
3507
|
-
.dealloc =
|
3533
|
+
.dealloc = FIO_FREE,
|
3508
3534
|
.data = tmp,
|
3509
3535
|
};
|
3510
3536
|
#endif
|
@@ -3534,7 +3560,7 @@ shrink2small:
|
|
3534
3560
|
if (len) {
|
3535
3561
|
memcpy(FIO_STR_SMALL_DATA(s), tmp, len + 1);
|
3536
3562
|
}
|
3537
|
-
|
3563
|
+
FIO_FREE(tmp);
|
3538
3564
|
}
|
3539
3565
|
|
3540
3566
|
/* *****************************************************************************
|
@@ -3938,7 +3964,7 @@ FIO_FUNC fio_str_info_s fio_str_readfile(fio_str_s *s, const char *filename,
|
|
3938
3964
|
if (home[home_len - 1] == '/' || home[home_len - 1] == '\\')
|
3939
3965
|
--home_len;
|
3940
3966
|
path_len = home_len + filename_len - 1;
|
3941
|
-
path =
|
3967
|
+
path = FIO_MALLOC(path_len + 1);
|
3942
3968
|
FIO_ASSERT_ALLOC(path);
|
3943
3969
|
memcpy(path, home, home_len);
|
3944
3970
|
memcpy(path + home_len, filename + 1, filename_len);
|
@@ -3978,7 +4004,7 @@ FIO_FUNC fio_str_info_s fio_str_readfile(fio_str_s *s, const char *filename,
|
|
3978
4004
|
}
|
3979
4005
|
close(file);
|
3980
4006
|
finish:
|
3981
|
-
|
4007
|
+
FIO_FREE(path);
|
3982
4008
|
return state;
|
3983
4009
|
#else
|
3984
4010
|
/* TODO: consider adding non POSIX implementations. */
|
@@ -4130,17 +4156,17 @@ static FIO_ARY_TYPE const FIO_NAME(s___const_invalid_object);
|
|
4130
4156
|
|
4131
4157
|
/* Customizable memory management */
|
4132
4158
|
#ifndef FIO_ARY_MALLOC /* NULL ptr indicates new allocation */
|
4133
|
-
#define FIO_ARY_MALLOC(size)
|
4159
|
+
#define FIO_ARY_MALLOC(size) FIO_MALLOC((size))
|
4134
4160
|
#endif
|
4135
4161
|
|
4136
4162
|
/* Customizable memory management */
|
4137
4163
|
#ifndef FIO_ARY_REALLOC /* NULL ptr indicates new allocation */
|
4138
4164
|
#define FIO_ARY_REALLOC(ptr, original_size, new_size, valid_data_length) \
|
4139
|
-
|
4165
|
+
FIO_REALLOC((ptr), (new_size), (valid_data_length))
|
4140
4166
|
#endif
|
4141
4167
|
|
4142
4168
|
#ifndef FIO_ARY_DEALLOC
|
4143
|
-
#define FIO_ARY_DEALLOC(ptr, size)
|
4169
|
+
#define FIO_ARY_DEALLOC(ptr, size) FIO_FREE((ptr))
|
4144
4170
|
#endif
|
4145
4171
|
|
4146
4172
|
/* padding to be assumed for future expansion. */
|
@@ -4351,13 +4377,13 @@ FIO_FUNC inline intptr_t FIO_NAME(__rel2absolute)(FIO_NAME(s) * ary,
|
|
4351
4377
|
FIO_FUNC void FIO_NAME(__require_on_top)(FIO_NAME(s) * ary, size_t len) {
|
4352
4378
|
if (ary->end + len < ary->capa)
|
4353
4379
|
return;
|
4354
|
-
len = FIO_ARY_SIZE2WORDS(len + ary->end);
|
4380
|
+
len = FIO_ARY_SIZE2WORDS((len + ary->end));
|
4355
4381
|
/* reallocate enough memory */
|
4356
4382
|
ary->arry = FIO_ARY_REALLOC(ary->arry, sizeof(*ary->arry) * ary->capa,
|
4357
4383
|
(len) * sizeof(*ary->arry),
|
4358
4384
|
ary->end * sizeof(*ary->arry));
|
4359
4385
|
FIO_ASSERT_ALLOC(ary->arry);
|
4360
|
-
ary->capa = len
|
4386
|
+
ary->capa = len;
|
4361
4387
|
}
|
4362
4388
|
|
4363
4389
|
/** Makes sure that `len` positions are available at the Array's head. */
|
@@ -4380,7 +4406,7 @@ FIO_FUNC void FIO_NAME(__require_on_bottom)(FIO_NAME(s) * ary, size_t len) {
|
|
4380
4406
|
len * sizeof(*ary->arry));
|
4381
4407
|
ary->start = ary->end - len;
|
4382
4408
|
if (tmp != ary->arry) {
|
4383
|
-
|
4409
|
+
FIO_FREE(tmp);
|
4384
4410
|
}
|
4385
4411
|
}
|
4386
4412
|
|
@@ -4804,7 +4830,7 @@ FIO_FUNC inline void FIO_NAME(_test)(void) {
|
|
4804
4830
|
}
|
4805
4831
|
#undef TEST_LIMIT
|
4806
4832
|
#else
|
4807
|
-
FIO_FUNC inline void FIO_NAME(_test)(void)
|
4833
|
+
FIO_FUNC inline void FIO_NAME(_test)(void) {}
|
4808
4834
|
#endif
|
4809
4835
|
|
4810
4836
|
/* *****************************************************************************
|
@@ -4985,13 +5011,15 @@ Done
|
|
4985
5011
|
/* Customizable memory management */
|
4986
5012
|
#ifndef FIO_SET_REALLOC /* NULL ptr indicates new allocation */
|
4987
5013
|
#define FIO_SET_REALLOC(ptr, original_size, new_size, valid_data_length) \
|
4988
|
-
|
5014
|
+
FIO_REALLOC((ptr), (new_size), (valid_data_length))
|
4989
5015
|
#endif
|
5016
|
+
|
4990
5017
|
#ifndef FIO_SET_CALLOC
|
4991
|
-
#define FIO_SET_CALLOC(size, count)
|
5018
|
+
#define FIO_SET_CALLOC(size, count) FIO_CALLOC((size), (count))
|
4992
5019
|
#endif
|
5020
|
+
|
4993
5021
|
#ifndef FIO_SET_FREE
|
4994
|
-
#define FIO_SET_FREE(ptr, size)
|
5022
|
+
#define FIO_SET_FREE(ptr, size) FIO_FREE((ptr))
|
4995
5023
|
#endif
|
4996
5024
|
|
4997
5025
|
/* The maximum number of bins to rotate when partial collisions occure */
|
@@ -5354,16 +5382,17 @@ FIO_FUNC inline FIO_SET_TYPE FIO_NAME(_insert_or_overwrite_)(
|
|
5354
5382
|
/* automatic fragmentation protection */
|
5355
5383
|
if (FIO_NAME(is_fragmented)(set))
|
5356
5384
|
FIO_NAME(rehash)(set);
|
5385
|
+
/* automatic capacity validation (we can never be at 100% capacity) */
|
5386
|
+
else if (set->pos >= set->capa) {
|
5387
|
+
set->mask = (set->mask << 1) | 3;
|
5388
|
+
FIO_NAME(rehash)(set);
|
5389
|
+
}
|
5357
5390
|
|
5358
|
-
/* locate future position
|
5391
|
+
/* locate future position */
|
5359
5392
|
FIO_NAME(_map_s_) *pos = FIO_NAME(_find_map_pos_)(set, hash_value, obj);
|
5393
|
+
|
5360
5394
|
if (!pos) {
|
5361
|
-
/*
|
5362
|
-
/* Either we are over capacity, or we have too many holes in the map. */
|
5363
|
-
if (set->pos >= set->capa) {
|
5364
|
-
set->mask = (set->mask << 1) | 3;
|
5365
|
-
FIO_NAME(rehash)(set);
|
5366
|
-
}
|
5395
|
+
/* inserting a new object, with too many holes in the map */
|
5367
5396
|
FIO_SET_COPY(set->ordered[set->pos].obj, obj);
|
5368
5397
|
set->ordered[set->pos].hash = hash_value;
|
5369
5398
|
++set->pos;
|
@@ -5493,6 +5522,7 @@ FIO_FUNC inline int FIO_NAME(remove)(FIO_NAME(s) * set,
|
|
5493
5522
|
--set->count;
|
5494
5523
|
pos->pos->hash = FIO_SET_HASH_INVALID;
|
5495
5524
|
if (pos->pos == set->pos + set->ordered - 1) {
|
5525
|
+
/* removing last item inserted */
|
5496
5526
|
pos->hash = FIO_SET_HASH_INVALID; /* no need for a "hole" */
|
5497
5527
|
do {
|
5498
5528
|
--set->pos;
|
@@ -5563,6 +5593,8 @@ FIO_FUNC int FIO_NAME(remove)(FIO_NAME(s) * set,
|
|
5563
5593
|
--set->count;
|
5564
5594
|
pos->pos->hash = FIO_SET_HASH_INVALID;
|
5565
5595
|
if (pos->pos == set->pos + set->ordered - 1) {
|
5596
|
+
/* removing last item inserted */
|
5597
|
+
pos->hash = FIO_SET_HASH_INVALID; /* no need for a "hole" */
|
5566
5598
|
do {
|
5567
5599
|
--set->pos;
|
5568
5600
|
} while (set->pos && FIO_SET_HASH_COMPARE(set->ordered[set->pos - 1].hash,
|
data/ext/iodine/fiobject.c
CHANGED
@@ -61,10 +61,10 @@ void *__attribute__((weak)) fio_mmap(size_t size) { return fio_malloc(size); }
|
|
61
61
|
/** The logging level */
|
62
62
|
#if DEBUG
|
63
63
|
#pragma weak FIO_LOG_LEVEL
|
64
|
-
|
64
|
+
int __attribute__((weak)) FIO_LOG_LEVEL = FIO_LOG_LEVEL_DEBUG;
|
65
65
|
#else
|
66
66
|
#pragma weak FIO_LOG_LEVEL
|
67
|
-
|
67
|
+
int __attribute__((weak)) FIO_LOG_LEVEL = FIO_LOG_LEVEL_INFO;
|
68
68
|
#endif
|
69
69
|
|
70
70
|
/**
|
data/ext/iodine/iodine.c
CHANGED
data/ext/iodine/iodine_defer.c
CHANGED
@@ -61,7 +61,7 @@ struct CreateThreadArgs {
|
|
61
61
|
};
|
62
62
|
|
63
63
|
/* used for GVL signalling */
|
64
|
-
void call_async_signal(void *pool) {
|
64
|
+
static void call_async_signal(void *pool) {
|
65
65
|
fio_stop();
|
66
66
|
(void)pool;
|
67
67
|
}
|
@@ -292,7 +292,7 @@ Sets a block of code to run before a new worker process is forked (cluster mode
|
|
292
292
|
|
293
293
|
Code runs within the master (root) process.
|
294
294
|
*/
|
295
|
-
VALUE iodine_before_fork_add(VALUE self) {
|
295
|
+
static VALUE iodine_before_fork_add(VALUE self) {
|
296
296
|
// clang-format on
|
297
297
|
rb_need_block();
|
298
298
|
VALUE block = rb_block_proc();
|
@@ -309,7 +309,7 @@ Sets a block of code to run after a new worker process is forked (cluster mode o
|
|
309
309
|
|
310
310
|
Code runs in both the parent and the child.
|
311
311
|
*/
|
312
|
-
VALUE iodine_after_fork_add(VALUE self) {
|
312
|
+
static VALUE iodine_after_fork_add(VALUE self) {
|
313
313
|
// clang-format on
|
314
314
|
rb_need_block();
|
315
315
|
VALUE block = rb_block_proc();
|
@@ -326,7 +326,7 @@ Sets a block of code to run after a new worker process is forked (cluster mode o
|
|
326
326
|
|
327
327
|
Code runs in both the parent and the child.
|
328
328
|
*/
|
329
|
-
VALUE iodine_after_fork_in_worker_add(VALUE self) {
|
329
|
+
static VALUE iodine_after_fork_in_worker_add(VALUE self) {
|
330
330
|
// clang-format on
|
331
331
|
rb_need_block();
|
332
332
|
VALUE block = rb_block_proc();
|
@@ -343,7 +343,7 @@ Sets a block of code to run after a new worker process is forked (cluster mode o
|
|
343
343
|
|
344
344
|
Code runs in both the parent and the child.
|
345
345
|
*/
|
346
|
-
VALUE iodine_after_fork_in_master_add(VALUE self) {
|
346
|
+
static VALUE iodine_after_fork_in_master_add(VALUE self) {
|
347
347
|
// clang-format on
|
348
348
|
rb_need_block();
|
349
349
|
VALUE block = rb_block_proc();
|
@@ -358,7 +358,7 @@ VALUE iodine_after_fork_in_master_add(VALUE self) {
|
|
358
358
|
/**
|
359
359
|
Sets a block of code to run once a Worker process shuts down (both in single process mode and cluster mode).
|
360
360
|
*/
|
361
|
-
VALUE iodine_on_shutdown_add(VALUE self) {
|
361
|
+
static VALUE iodine_on_shutdown_add(VALUE self) {
|
362
362
|
// clang-format on
|
363
363
|
rb_need_block();
|
364
364
|
VALUE block = rb_block_proc();
|
data/ext/iodine/iodine_http.c
CHANGED
@@ -246,7 +246,7 @@ Copying data from the C request to the Rack's ENV
|
|
246
246
|
|
247
247
|
#define to_upper(c) (((c) >= 'a' && (c) <= 'z') ? ((c) & ~32) : (c))
|
248
248
|
|
249
|
-
int iodine_copy2env_task(FIOBJ o, void *env_) {
|
249
|
+
static int iodine_copy2env_task(FIOBJ o, void *env_) {
|
250
250
|
VALUE env = (VALUE)env_;
|
251
251
|
FIOBJ name = fiobj_hash_key_in_loop();
|
252
252
|
fio_str_info_s tmp = fiobj_obj2cstr(name);
|
@@ -285,6 +285,7 @@ int iodine_copy2env_task(FIOBJ o, void *env_) {
|
|
285
285
|
}
|
286
286
|
return 0;
|
287
287
|
}
|
288
|
+
|
288
289
|
static inline VALUE copy2env(iodine_http_request_handle_s *handle) {
|
289
290
|
VALUE env;
|
290
291
|
http_s *h = handle->h;
|
@@ -819,7 +820,7 @@ Once HTTP/2 is supported (planned, but probably very far away), HTTP/2
|
|
819
820
|
timeouts will be dynamically managed by Iodine. The `timeout` option is only
|
820
821
|
relevant to HTTP/1.x connections.
|
821
822
|
*/
|
822
|
-
VALUE iodine_http_listen(VALUE self, VALUE opt) {
|
823
|
+
static VALUE iodine_http_listen(VALUE self, VALUE opt) {
|
823
824
|
// clang-format on
|
824
825
|
uint8_t log_http = 0;
|
825
826
|
size_t ping = 0;
|
data/ext/iodine/iodine_json.c
CHANGED
@@ -15,6 +15,7 @@ static VALUE object_class;
|
|
15
15
|
static VALUE array_class;
|
16
16
|
|
17
17
|
#define FIO_ARY_NAME fio_json_stack
|
18
|
+
#define FIO_ARY_TYPE VALUE
|
18
19
|
#include "fio.h"
|
19
20
|
|
20
21
|
/* *****************************************************************************
|
@@ -97,13 +98,13 @@ static int fio_json_on_start_object(json_parser_s *p) {
|
|
97
98
|
iodine_json_parser_s *pr = (iodine_json_parser_s *)p;
|
98
99
|
if (pr->target) {
|
99
100
|
/* push NULL, don't free the objects */
|
100
|
-
fio_json_stack_push(&pr->stack,
|
101
|
+
fio_json_stack_push(&pr->stack, pr->top);
|
101
102
|
pr->top = pr->target;
|
102
103
|
pr->target = 0;
|
103
104
|
} else {
|
104
105
|
VALUE h = rb_hash_new();
|
105
106
|
iodine_json_add2parser(pr, h);
|
106
|
-
fio_json_stack_push(&pr->stack,
|
107
|
+
fio_json_stack_push(&pr->stack, pr->top);
|
107
108
|
pr->top = h;
|
108
109
|
}
|
109
110
|
pr->is_hash = 1;
|
@@ -128,7 +129,7 @@ static int fio_json_on_start_array(json_parser_s *p) {
|
|
128
129
|
return -1;
|
129
130
|
VALUE ary = rb_ary_new();
|
130
131
|
iodine_json_add2parser(pr, ary);
|
131
|
-
fio_json_stack_push(&pr->stack,
|
132
|
+
fio_json_stack_push(&pr->stack, pr->top);
|
132
133
|
pr->top = ary;
|
133
134
|
pr->is_hash = 0;
|
134
135
|
return 0;
|
data/ext/iodine/iodine_pubsub.c
CHANGED
@@ -130,17 +130,6 @@ CLUSTER (not just this process) subscribes to a stream / channel.
|
|
130
130
|
*/
|
131
131
|
static VALUE iodine_pubsub_subscribe(VALUE self, VALUE to, VALUE match) {
|
132
132
|
return Qnil;
|
133
|
-
#if 0
|
134
|
-
iodine_pubsub_s *e = iodine_pubsub_CData(self);
|
135
|
-
if (e->engine == &e->do_not_touch) {
|
136
|
-
/* this is a Ruby engine, nothing to do. */
|
137
|
-
return Qnil;
|
138
|
-
}
|
139
|
-
FIOBJ ch = fiobj_str_new(RSTRING_PTR(to), RSTRING_LEN(to));
|
140
|
-
e->engine->subscribe(e->engine, ch, SYM2ID(match) == redis_id);
|
141
|
-
fiobj_free(ch);
|
142
|
-
return to;
|
143
|
-
#endif
|
144
133
|
(void)self;
|
145
134
|
(void)to;
|
146
135
|
(void)match;
|
@@ -152,17 +141,6 @@ process CLUSTER (not just this process) unsubscribes from a stream / channel.
|
|
152
141
|
*/
|
153
142
|
static VALUE iodine_pubsub_unsubscribe(VALUE self, VALUE to, VALUE match) {
|
154
143
|
return Qnil;
|
155
|
-
#if 0
|
156
|
-
iodine_pubsub_s *e = iodine_pubsub_CData(self);
|
157
|
-
if (e->engine == &e->do_not_touch) {
|
158
|
-
/* this is a Ruby engine, nothing to do. */
|
159
|
-
return Qnil;
|
160
|
-
}
|
161
|
-
FIOBJ ch = fiobj_str_new(RSTRING_PTR(to), RSTRING_LEN(to));
|
162
|
-
e->engine->unsubscribe(e->engine, ch, SYM2ID(match) == redis_id);
|
163
|
-
fiobj_free(ch);
|
164
|
-
return to;
|
165
|
-
#endif
|
166
144
|
(void)self;
|
167
145
|
(void)to;
|
168
146
|
(void)match;
|
@@ -181,12 +159,12 @@ NOTE: this callback is called per process event (not per cluster event) and the
|
|
181
159
|
*/
|
182
160
|
static VALUE iodine_pubsub_publish(VALUE self, VALUE to, VALUE message) {
|
183
161
|
iodine_pubsub_s *e = iodine_pubsub_CData(self);
|
184
|
-
if (e->engine == &e->do_not_touch) {
|
162
|
+
if (!e || e->engine == &e->do_not_touch) {
|
185
163
|
/* this is a Ruby engine, nothing to do. */
|
186
164
|
return Qnil;
|
187
165
|
}
|
188
|
-
|
189
|
-
|
166
|
+
fio_publish(.engine = e->engine, .channel = IODINE_RSTRINFO(to),
|
167
|
+
.message = IODINE_RSTRINFO(message));
|
190
168
|
return self;
|
191
169
|
}
|
192
170
|
|
data/ext/iodine/iodine_store.c
CHANGED
@@ -111,7 +111,7 @@ static void storage_clear(void *ignore) {
|
|
111
111
|
the data-type used to identify the registry
|
112
112
|
this sets the callbacks.
|
113
113
|
*/
|
114
|
-
static struct rb_data_type_struct storage_type_struct = {
|
114
|
+
static const struct rb_data_type_struct storage_type_struct = {
|
115
115
|
.wrap_struct_name = "RubyReferencesIn_C_Land",
|
116
116
|
.function.dfree = (void (*)(void *))storage_clear,
|
117
117
|
.function.dmark = (void (*)(void *))storage_mark,
|
data/lib/iodine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iodine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -244,7 +244,7 @@ licenses:
|
|
244
244
|
- MIT
|
245
245
|
metadata:
|
246
246
|
allowed_push_host: https://rubygems.org
|
247
|
-
post_install_message: 'Thank you for installing Iodine 0.7.
|
247
|
+
post_install_message: 'Thank you for installing Iodine 0.7.5.
|
248
248
|
|
249
249
|
'
|
250
250
|
rdoc_options: []
|