iodine 0.7.5 → 0.7.6
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/ext/iodine/fio.c +29 -21
- data/ext/iodine/fio.h +12 -5
- data/ext/iodine/fio_cli.c +25 -17
- data/ext/iodine/fio_cli.h +19 -9
- data/ext/iodine/http.c +30 -0
- data/ext/iodine/http.h +2 -2
- data/ext/iodine/iodine_mustache.c +3 -2
- data/lib/iodine.rb +11 -0
- 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: 978b528f65f3a43372f47339c6f76ced52bfc12264665bf57c0d2f285b2a4ad2
|
4
|
+
data.tar.gz: b75b56ceebbda9a80510740f3d11425980a3562d46542e308e818fcf0fd9b219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf003b8b3ddf3a1be5c81cee28588a31ed9af159ad5e2b49d69d3e1a8bc6cf75149ba4191bc80c8e55e55cf5a9fae6b47d7c615662a6073824086b91d1a5811f
|
7
|
+
data.tar.gz: 923b37d94efd4e31d96743df37425334268c1c3a9fd51d44265f8a9603ff92346cc4d793e24a39203a93e5aabadf64981190ad88f843fb50fc276452ee6cb38e
|
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.6
|
10
|
+
|
11
|
+
**Fix**: (facil.io edge) timeout review was experiencing some errors that could cause timeouts to be ignored. This was fixed in the facil.io edge branch.
|
12
|
+
|
13
|
+
**Fix**: (Ruby 2.2) fixed a possible error with the Mustache parser on Ruby 2.2. I don't run Ruby 2.2, but this came up as a warning during CI tests.
|
14
|
+
|
15
|
+
**Fix**: `on_worker_boot` was mistakenly updated to a pre-fork callback (instead of a post fork callback) when attempting to fix the `on_worker_fork` behavior. This timing issue is now fixed and `on_worker_boot` is called **after** forking (both on the master process and the worker).
|
16
|
+
|
9
17
|
#### Change log v.0.7.5
|
10
18
|
|
11
19
|
**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.
|
data/ext/iodine/fio.c
CHANGED
@@ -1939,8 +1939,8 @@ postpone:
|
|
1939
1939
|
static void deferred_ping(void *arg, void *arg2) {
|
1940
1940
|
if (!uuid_data(arg).protocol ||
|
1941
1941
|
(uuid_data(arg).timeout &&
|
1942
|
-
(uuid_data(arg).timeout >
|
1943
|
-
(fio_data->last_cycle.tv_sec
|
1942
|
+
(uuid_data(arg).timeout + uuid_data(arg).active >
|
1943
|
+
(fio_data->last_cycle.tv_sec)))) {
|
1944
1944
|
return;
|
1945
1945
|
}
|
1946
1946
|
fio_protocol_s *pr = protocol_try_lock(fio_uuid2fd(arg), FIO_PR_LOCK_WRITE);
|
@@ -2578,6 +2578,9 @@ void fio_force_close(intptr_t uuid) {
|
|
2578
2578
|
errno = EBADF;
|
2579
2579
|
return;
|
2580
2580
|
}
|
2581
|
+
/* make sure the close marker is set */
|
2582
|
+
if (!uuid_data(uuid).close)
|
2583
|
+
uuid_data(uuid).close = 1;
|
2581
2584
|
/* clear away any packets in case we want to cut the connection short. */
|
2582
2585
|
fio_packet_s *packet;
|
2583
2586
|
fio_lock(&uuid_data(uuid).sock_lock);
|
@@ -2592,8 +2595,9 @@ void fio_force_close(intptr_t uuid) {
|
|
2592
2595
|
fio_packet_free(tmp);
|
2593
2596
|
}
|
2594
2597
|
/* check for rw-hooks termination packet */
|
2595
|
-
if (uuid_data(uuid).open &&
|
2596
|
-
uuid_data(uuid).rw_hooks->
|
2598
|
+
if (uuid_data(uuid).open && (uuid_data(uuid).close & 1) &&
|
2599
|
+
uuid_data(uuid).rw_hooks->before_close(uuid, uuid_data(uuid).rw_udata)) {
|
2600
|
+
uuid_data(uuid).close = 2; /* don't repeat the before_close callback */
|
2597
2601
|
fio_touch(uuid);
|
2598
2602
|
fio_poll_add_write(fio_uuid2fd(uuid));
|
2599
2603
|
return;
|
@@ -2629,24 +2633,25 @@ ssize_t fio_flush(intptr_t uuid) {
|
|
2629
2633
|
if (fio_trylock(&uuid_data(uuid).sock_lock))
|
2630
2634
|
goto would_block;
|
2631
2635
|
|
2632
|
-
flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata);
|
2633
|
-
if (flushed < 0) {
|
2634
|
-
goto test_errno;
|
2635
|
-
}
|
2636
|
-
if (flushed) {
|
2637
|
-
goto flushed;
|
2638
|
-
}
|
2639
|
-
|
2640
2636
|
if (uuid_data(uuid).packet) {
|
2641
2637
|
tmp = uuid_data(uuid).packet->write_func(fio_uuid2fd(uuid),
|
2642
2638
|
uuid_data(uuid).packet);
|
2643
2639
|
if (tmp == 0) {
|
2644
2640
|
errno = ECONNRESET;
|
2645
2641
|
fio_unlock(&uuid_data(uuid).sock_lock);
|
2642
|
+
uuid_data(uuid).close = 1;
|
2646
2643
|
goto closed;
|
2647
2644
|
} else if (tmp < 0) {
|
2648
2645
|
goto test_errno;
|
2649
2646
|
}
|
2647
|
+
} else {
|
2648
|
+
flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata);
|
2649
|
+
if (flushed < 0) {
|
2650
|
+
goto test_errno;
|
2651
|
+
}
|
2652
|
+
if (flushed) {
|
2653
|
+
goto flushed;
|
2654
|
+
}
|
2650
2655
|
}
|
2651
2656
|
|
2652
2657
|
/* end critical section */
|
@@ -2663,7 +2668,6 @@ would_block:
|
|
2663
2668
|
errno = EWOULDBLOCK;
|
2664
2669
|
return -1;
|
2665
2670
|
closed:
|
2666
|
-
uuid_data(uuid).close = 1;
|
2667
2671
|
fio_force_close(uuid);
|
2668
2672
|
return -1;
|
2669
2673
|
test_errno:
|
@@ -2685,7 +2689,7 @@ void fio_flush_all(void) {
|
|
2685
2689
|
if (!fio_data)
|
2686
2690
|
return;
|
2687
2691
|
for (uintptr_t i = 0; i < fio_data->max_protocol_fd; ++i) {
|
2688
|
-
if (fd_data(i).packet)
|
2692
|
+
if (fd_data(i).open || fd_data(i).packet)
|
2689
2693
|
fio_flush(fd2uuid(i));
|
2690
2694
|
}
|
2691
2695
|
}
|
@@ -2705,10 +2709,10 @@ static ssize_t fio_hooks_default_write(intptr_t uuid, void *udata,
|
|
2705
2709
|
(void)(udata);
|
2706
2710
|
}
|
2707
2711
|
|
2708
|
-
static ssize_t
|
2709
|
-
close(fio_uuid2fd(uuid));
|
2712
|
+
static ssize_t fio_hooks_default_before_close(intptr_t uuid, void *udata) {
|
2710
2713
|
return 0;
|
2711
2714
|
(void)udata;
|
2715
|
+
(void)uuid;
|
2712
2716
|
}
|
2713
2717
|
|
2714
2718
|
static ssize_t fio_hooks_default_flush(intptr_t uuid, void *udata) {
|
@@ -2723,7 +2727,7 @@ const fio_rw_hook_s FIO_DEFAULT_RW_HOOKS = {
|
|
2723
2727
|
.read = fio_hooks_default_read,
|
2724
2728
|
.write = fio_hooks_default_write,
|
2725
2729
|
.flush = fio_hooks_default_flush,
|
2726
|
-
.
|
2730
|
+
.before_close = fio_hooks_default_before_close,
|
2727
2731
|
.cleanup = fio_hooks_default_cleanup,
|
2728
2732
|
};
|
2729
2733
|
|
@@ -2737,8 +2741,8 @@ int fio_rw_hook_set(intptr_t uuid, fio_rw_hook_s *rw_hooks, void *udata) {
|
|
2737
2741
|
rw_hooks->write = fio_hooks_default_write;
|
2738
2742
|
if (!rw_hooks->flush)
|
2739
2743
|
rw_hooks->flush = fio_hooks_default_flush;
|
2740
|
-
if (!rw_hooks->
|
2741
|
-
rw_hooks->
|
2744
|
+
if (!rw_hooks->before_close)
|
2745
|
+
rw_hooks->before_close = fio_hooks_default_before_close;
|
2742
2746
|
if (!rw_hooks->cleanup)
|
2743
2747
|
rw_hooks->cleanup = fio_hooks_default_cleanup;
|
2744
2748
|
uuid = fio_uuid2fd(uuid);
|
@@ -2856,6 +2860,8 @@ void fio_timeout_set(intptr_t uuid, uint8_t timeout) {
|
|
2856
2860
|
if (uuid_is_valid(uuid)) {
|
2857
2861
|
uuid_data(uuid).active = fio_data->last_cycle.tv_sec;
|
2858
2862
|
uuid_data(uuid).timeout = timeout;
|
2863
|
+
} else {
|
2864
|
+
FIO_LOG_DEBUG("Called fio_timeout_set for invalid uuid %p", (void *)uuid);
|
2859
2865
|
}
|
2860
2866
|
}
|
2861
2867
|
/** Gets a timeout for a specific connection. Returns 0 if there's no set
|
@@ -3245,7 +3251,6 @@ static void fio_review_timeout(void *arg, void *ignr) {
|
|
3245
3251
|
uint16_t timeout = fd_data(fd).timeout;
|
3246
3252
|
if (!timeout)
|
3247
3253
|
timeout = 300; /* enforced timout settings */
|
3248
|
-
|
3249
3254
|
if (!fd_data(fd).protocol || (fd_data(fd).active + timeout >= review))
|
3250
3255
|
goto finish;
|
3251
3256
|
tmp = protocol_try_lock(fd, FIO_PR_LOCK_STATE);
|
@@ -3262,7 +3267,7 @@ finish:
|
|
3262
3267
|
fd++;
|
3263
3268
|
} while (!fd_data(fd).protocol && (fd <= fio_data->max_protocol_fd));
|
3264
3269
|
|
3265
|
-
if (fio_data->max_protocol_fd
|
3270
|
+
if (fio_data->max_protocol_fd < fd) {
|
3266
3271
|
fio_data->need_review = 1;
|
3267
3272
|
return;
|
3268
3273
|
}
|
@@ -3347,6 +3352,9 @@ static void fio_worker_startup(void) {
|
|
3347
3352
|
fio_data->threads = 1;
|
3348
3353
|
}
|
3349
3354
|
|
3355
|
+
/* require timeout review */
|
3356
|
+
fio_data->need_review = 1;
|
3357
|
+
|
3350
3358
|
/* the cycle task will loop by re-scheduling until it's time to finish */
|
3351
3359
|
fio_defer(fio_cycle, NULL, NULL);
|
3352
3360
|
|
data/ext/iodine/fio.h
CHANGED
@@ -410,7 +410,7 @@ extern int FIO_LOG_LEVEL;
|
|
410
410
|
#endif
|
411
411
|
|
412
412
|
#if FIO_PRINT_STATE
|
413
|
-
#define FIO_LOG_STATE(...) FIO_LOG_PRINT(
|
413
|
+
#define FIO_LOG_STATE(...) FIO_LOG_PRINT(FIO_LOG_LEVEL_INFO, __VA_ARGS__)
|
414
414
|
#else
|
415
415
|
#define FIO_LOG_STATE(...)
|
416
416
|
#endif
|
@@ -1193,20 +1193,27 @@ typedef struct fio_rw_hook_s {
|
|
1193
1193
|
* Implement writing to a file descriptor. Should behave like the file system
|
1194
1194
|
* `write` call.
|
1195
1195
|
*
|
1196
|
+
* If an internal buffer is implemented and it is full, errno should be set to
|
1197
|
+
* EWOULDBLOCK and the function should return -1.
|
1198
|
+
*
|
1199
|
+
* The function is expected to call the `flush` callback (or it's logic)
|
1200
|
+
* internally. Either `write` OR `flush` are called.
|
1201
|
+
*
|
1196
1202
|
* Note: facil.io library functions MUST NEVER be called by any r/w hook, or a
|
1197
1203
|
* deadlock might occur.
|
1198
1204
|
*/
|
1199
1205
|
ssize_t (*write)(intptr_t uuid, void *udata, const void *buf, size_t count);
|
1200
1206
|
/**
|
1201
|
-
* The `
|
1207
|
+
* The `before_close` callback is called only once before closing the `uuid`.
|
1202
1208
|
*
|
1203
|
-
* If the function returns a non-zero value,
|
1204
|
-
*
|
1209
|
+
* If the function returns a non-zero value, than closure will be delayed
|
1210
|
+
* until the `flush` returns 0 (or less). This allows a closure signal to be
|
1211
|
+
* sent by the read/write hook when such a signal is required.
|
1205
1212
|
*
|
1206
1213
|
* Note: facil.io library functions MUST NEVER be called by any r/w hook, or a
|
1207
1214
|
* deadlock might occur.
|
1208
1215
|
* */
|
1209
|
-
ssize_t (*
|
1216
|
+
ssize_t (*before_close)(intptr_t uuid, void *udata);
|
1210
1217
|
/**
|
1211
1218
|
* When implemented, this function will be called to flush any data remaining
|
1212
1219
|
* in the internal buffer.
|
data/ext/iodine/fio_cli.c
CHANGED
@@ -33,12 +33,13 @@ typedef struct {
|
|
33
33
|
|
34
34
|
static fio_cli_hash_s fio_aliases = FIO_SET_INIT;
|
35
35
|
static fio_cli_hash_s fio_values = FIO_SET_INIT;
|
36
|
-
static size_t
|
36
|
+
static size_t fio_unnamed_count = 0;
|
37
37
|
|
38
38
|
typedef struct {
|
39
|
-
int
|
39
|
+
int unnamed_min;
|
40
|
+
int unnamed_max;
|
40
41
|
int pos;
|
41
|
-
int
|
42
|
+
int unnamed_count;
|
42
43
|
char const *description;
|
43
44
|
char const **names;
|
44
45
|
} fio_cli_parser_data_s;
|
@@ -112,19 +113,19 @@ found:
|
|
112
113
|
|
113
114
|
static void fio_cli_set_arg(cstr_s arg, char const *value, char const *line,
|
114
115
|
fio_cli_parser_data_s *parser) {
|
115
|
-
/* handle
|
116
|
+
/* handle unnamed argument */
|
116
117
|
if (!line || !arg.len) {
|
117
118
|
if (!value) {
|
118
|
-
|
119
|
-
return;
|
119
|
+
goto print_help;
|
120
120
|
}
|
121
121
|
if (!strcmp(value, "-?") || !strcasecmp(value, "-h") ||
|
122
122
|
!strcasecmp(value, "-help") || !strcasecmp(value, "--help")) {
|
123
123
|
goto print_help;
|
124
124
|
}
|
125
|
-
cstr_s n = {.len = ++parser->
|
125
|
+
cstr_s n = {.len = ++parser->unnamed_count};
|
126
126
|
fio_cli_hash_insert(&fio_values, n.len, n, value, NULL);
|
127
|
-
if (
|
127
|
+
if (parser->unnamed_max >= 0 &&
|
128
|
+
parser->unnamed_count > parser->unnamed_max) {
|
128
129
|
arg.len = 0;
|
129
130
|
goto error;
|
130
131
|
}
|
@@ -287,10 +288,14 @@ print_help:
|
|
287
288
|
exit(0);
|
288
289
|
}
|
289
290
|
|
290
|
-
void fio_cli_start AVOID_MACRO(int argc, char const *argv[], int
|
291
|
-
char const *description,
|
291
|
+
void fio_cli_start AVOID_MACRO(int argc, char const *argv[], int unnamed_min,
|
292
|
+
int unnamed_max, char const *description,
|
293
|
+
char const **names) {
|
294
|
+
if (unnamed_max >= 0 && unnamed_max < unnamed_min)
|
295
|
+
unnamed_max = unnamed_min;
|
292
296
|
fio_cli_parser_data_s parser = {
|
293
|
-
.
|
297
|
+
.unnamed_min = unnamed_min,
|
298
|
+
.unnamed_max = unnamed_max,
|
294
299
|
.description = description,
|
295
300
|
.names = names,
|
296
301
|
.pos = 0,
|
@@ -338,13 +343,16 @@ void fio_cli_start AVOID_MACRO(int argc, char const *argv[], int allow_unknown,
|
|
338
343
|
|
339
344
|
/* Cleanup and save state for API */
|
340
345
|
fio_cli_hash_free(&fio_aliases);
|
341
|
-
|
346
|
+
fio_unnamed_count = parser.unnamed_count;
|
347
|
+
/* test for required unnamed arguments */
|
348
|
+
if (parser.unnamed_count < parser.unnamed_min)
|
349
|
+
fio_cli_set_arg((cstr_s){.len = 0}, NULL, NULL, &parser);
|
342
350
|
}
|
343
351
|
|
344
352
|
void fio_cli_end(void) {
|
345
353
|
fio_cli_hash_free(&fio_values);
|
346
354
|
fio_cli_hash_free(&fio_aliases);
|
347
|
-
|
355
|
+
fio_unnamed_count = 0;
|
348
356
|
}
|
349
357
|
/* *****************************************************************************
|
350
358
|
CLI Data Access
|
@@ -383,13 +391,13 @@ int fio_cli_get_i(char const *name) {
|
|
383
391
|
}
|
384
392
|
|
385
393
|
/** Returns the number of unrecognized argument. */
|
386
|
-
unsigned int
|
387
|
-
return (unsigned int)
|
394
|
+
unsigned int fio_cli_unnamed_count(void) {
|
395
|
+
return (unsigned int)fio_unnamed_count;
|
388
396
|
}
|
389
397
|
|
390
398
|
/** Returns the unrecognized argument using a 0 based `index`. */
|
391
|
-
char const *
|
392
|
-
if (!fio_cli_hash_count(&fio_values) || !
|
399
|
+
char const *fio_cli_unnamed(unsigned int index) {
|
400
|
+
if (!fio_cli_hash_count(&fio_values) || !fio_unnamed_count) {
|
393
401
|
return NULL;
|
394
402
|
}
|
395
403
|
cstr_s n = {.data = NULL, .len = index + 1};
|
data/ext/iodine/fio_cli.h
CHANGED
@@ -31,6 +31,14 @@ CLI API
|
|
31
31
|
* provided and the provided arument fails to match the required type, execution
|
32
32
|
* will end and an error message will be printed along with a short "help".
|
33
33
|
*
|
34
|
+
* The function / macro accepts the following arguments:
|
35
|
+
* - `argc`: command line argument count.
|
36
|
+
* - `argv`: command line argument list (array).
|
37
|
+
* - `unnamed_min`: the required minimum of un-named arguments.
|
38
|
+
* - `unnamed_max`: the maximum limit of un-named arguments.
|
39
|
+
* - `description`: a C string containing the program's description.
|
40
|
+
* - named arguments list: a list of C strings describing named arguments.
|
41
|
+
*
|
34
42
|
* The following optional type requirements are:
|
35
43
|
*
|
36
44
|
* * FIO_CLI_TYPE_STRING - (default) string argument.
|
@@ -43,9 +51,11 @@ CLI API
|
|
43
51
|
* The arguments "-?", "-h", "-help" and "--help" are automatically handled
|
44
52
|
* unless overridden.
|
45
53
|
*
|
54
|
+
* Un-named arguments shouldn't be listed in the named arguments list.
|
55
|
+
*
|
46
56
|
* Example use:
|
47
57
|
*
|
48
|
-
* fio_cli_start(argc, argv, 0, "this example accepts the following:",
|
58
|
+
* fio_cli_start(argc, argv, 0, 0, "this example accepts the following:",
|
49
59
|
* "-t -thread number of threads to run.", FIO_CLI_TYPE_INT,
|
50
60
|
* "-w -workers number of workers to run.", FIO_CLI_TYPE_INT,
|
51
61
|
* "-b, -address the address to bind to.",
|
@@ -68,16 +78,16 @@ CLI API
|
|
68
78
|
*
|
69
79
|
* This function is NOT thread safe.
|
70
80
|
*/
|
71
|
-
#define fio_cli_start(argc, argv,
|
72
|
-
fio_cli_start((argc), (argv), (
|
81
|
+
#define fio_cli_start(argc, argv, unnamed_min, unnamed_max, description, ...) \
|
82
|
+
fio_cli_start((argc), (argv), (unnamed_min), (unnamed_max), (description), \
|
73
83
|
(char const *[]){__VA_ARGS__, NULL})
|
74
84
|
#define FIO_CLI_IGNORE
|
75
85
|
/**
|
76
86
|
* Never use the function directly, always use the MACRO, because the macro
|
77
87
|
* attaches a NULL marker at the end of the `names` argument collection.
|
78
88
|
*/
|
79
|
-
void fio_cli_start FIO_CLI_IGNORE(int argc, char const *argv[],
|
80
|
-
int
|
89
|
+
void fio_cli_start FIO_CLI_IGNORE(int argc, char const *argv[], int unnamed_min,
|
90
|
+
int unnamed_max, char const *description,
|
81
91
|
char const **names);
|
82
92
|
/**
|
83
93
|
* Clears the memory used by the CLI dictionary, removing all parsed data.
|
@@ -95,11 +105,11 @@ int fio_cli_get_i(char const *name);
|
|
95
105
|
/** This MACRO returns the argument's value as a boolean. */
|
96
106
|
#define fio_cli_get_bool(name) (fio_cli_get((name)) != NULL)
|
97
107
|
|
98
|
-
/** Returns the number of
|
99
|
-
unsigned int
|
108
|
+
/** Returns the number of unnamed argument. */
|
109
|
+
unsigned int fio_cli_unnamed_count(void);
|
100
110
|
|
101
|
-
/** Returns the
|
102
|
-
char const *
|
111
|
+
/** Returns the unnamed argument using a 0 based `index`. */
|
112
|
+
char const *fio_cli_unnamed(unsigned int index);
|
103
113
|
|
104
114
|
/**
|
105
115
|
* Sets the argument's value as a NUL terminated C String (no copy!).
|
data/ext/iodine/http.c
CHANGED
@@ -39,6 +39,32 @@ static inline int patch_clock_gettime(int clk_id, struct timespec *t) {
|
|
39
39
|
}
|
40
40
|
#endif
|
41
41
|
|
42
|
+
/* *****************************************************************************
|
43
|
+
SSL/TLS patch
|
44
|
+
***************************************************************************** */
|
45
|
+
void __attribute__((weak)) fio_tls_accept(intptr_t uuid, void *tls) {
|
46
|
+
FIO_LOG_FATAL("HTTP SSL/TLS required but unavailable!");
|
47
|
+
exit(-1);
|
48
|
+
(void)uuid;
|
49
|
+
(void)tls;
|
50
|
+
}
|
51
|
+
#pragma weak fio_tls_accept
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Establishes an SSL/TLS connection as an SSL/TLS Server, using the specified
|
55
|
+
* conetext / settings object.
|
56
|
+
*
|
57
|
+
* The `uuid` should be a socket UUID that is already connected to a peer (i.e.,
|
58
|
+
* the result of `fio_accept`).
|
59
|
+
*/
|
60
|
+
void __attribute__((weak)) fio_tls_connect(intptr_t uuid, void *tls) {
|
61
|
+
FIO_LOG_FATAL("HTTP SSL/TLS required but unavailable!");
|
62
|
+
exit(-1);
|
63
|
+
(void)uuid;
|
64
|
+
(void)tls;
|
65
|
+
}
|
66
|
+
#pragma weak fio_tls_connect
|
67
|
+
|
42
68
|
/* *****************************************************************************
|
43
69
|
Small Helpers
|
44
70
|
***************************************************************************** */
|
@@ -883,6 +909,8 @@ Listening to HTTP connections
|
|
883
909
|
|
884
910
|
static void http_on_open(intptr_t uuid, void *set) {
|
885
911
|
static uint8_t at_capa;
|
912
|
+
if (((http_settings_s *)set)->tls)
|
913
|
+
fio_tls_accept(uuid, ((http_settings_s *)set)->tls);
|
886
914
|
fio_timeout_set(uuid, ((http_settings_s *)set)->timeout);
|
887
915
|
if (fio_uuid2fd(uuid) >= ((http_settings_s *)set)->max_clients) {
|
888
916
|
if (!at_capa)
|
@@ -972,6 +1000,8 @@ static void http_on_open_client(intptr_t uuid, void *set_) {
|
|
972
1000
|
http_settings_s *set = set_;
|
973
1001
|
http_s *h = set->udata;
|
974
1002
|
set->udata = h->udata;
|
1003
|
+
if (set->tls)
|
1004
|
+
fio_tls_connect(uuid, set->tls);
|
975
1005
|
fio_timeout_set(uuid, set->timeout);
|
976
1006
|
fio_protocol_s *pr = http1_new(uuid, set, NULL, 0);
|
977
1007
|
if (!pr) {
|
data/ext/iodine/http.h
CHANGED
@@ -355,14 +355,14 @@ struct http_settings_s {
|
|
355
355
|
* sockets count towards a server's limit.
|
356
356
|
*/
|
357
357
|
intptr_t max_clients;
|
358
|
+
/** reserved for future SSL/TLS support. */
|
359
|
+
void *tls;
|
358
360
|
/** reserved for future use. */
|
359
361
|
intptr_t reserved1;
|
360
362
|
/** reserved for future use. */
|
361
363
|
intptr_t reserved2;
|
362
364
|
/** reserved for future use. */
|
363
365
|
intptr_t reserved3;
|
364
|
-
/** reserved for future use. */
|
365
|
-
intptr_t reserved4;
|
366
366
|
/**
|
367
367
|
* The maximum websocket message size/buffer (in bytes) for Websocket
|
368
368
|
* connections. Defaults to ~250KB.
|
@@ -231,7 +231,7 @@ static int32_t mustache_on_section_test(mustache_section_s *section,
|
|
231
231
|
return 0;
|
232
232
|
}
|
233
233
|
if (RB_TYPE_P(o, T_ARRAY)) {
|
234
|
-
return
|
234
|
+
return RARRAY_LEN(o);
|
235
235
|
}
|
236
236
|
return 1;
|
237
237
|
}
|
@@ -363,7 +363,8 @@ error:
|
|
363
363
|
|
364
364
|
/**
|
365
365
|
Renders the mustache template found in `filename`, using the data provided in
|
366
|
-
the `data` argument.
|
366
|
+
the `data` argument. If `template` is provided it will be used instead of
|
367
|
+
reading the file's content.
|
367
368
|
|
368
369
|
Iodine::Mustache.render(filename, data, template = nil)
|
369
370
|
|
data/lib/iodine.rb
CHANGED
@@ -140,6 +140,12 @@ end
|
|
140
140
|
if(!defined?(on_worker_boot))
|
141
141
|
# Performs a block of code before a new worker process spins up (performed once per worker).
|
142
142
|
def on_worker_boot(*args, &block)
|
143
|
+
Iodine.after_fork(*args, &block)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
if(!defined?(on_worker_fork))
|
147
|
+
# Performs a block of code before a new worker process spins up (performed once per worker).
|
148
|
+
def on_worker_fork(*args, &block)
|
143
149
|
Iodine.before_fork(*args, &block)
|
144
150
|
end
|
145
151
|
end
|
@@ -150,4 +156,9 @@ if(!defined?(before_fork))
|
|
150
156
|
end
|
151
157
|
end
|
152
158
|
|
159
|
+
Iodine.after_fork_in_worker do
|
160
|
+
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
161
|
+
end
|
162
|
+
|
163
|
+
|
153
164
|
|
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.6
|
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-
|
11
|
+
date: 2018-11-05 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.6.
|
248
248
|
|
249
249
|
'
|
250
250
|
rdoc_options: []
|