iodine 0.4.10 → 0.4.11
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 +4 -0
- data/ext/iodine/defer.c +10 -1
- data/ext/iodine/defer.h +8 -0
- data/ext/iodine/rb-defer.c +23 -2
- data/ext/iodine/websocket_parser.h +13 -11
- data/iodine.gemspec +7 -7
- data/lib/iodine/version.rb +1 -1
- metadata +39 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8def4f63c04685ba532ad67250a13099e9cc2a72
|
4
|
+
data.tar.gz: 9586665f6508a1fa66d2db4f62bfdd4fb5e20711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c1d1a6e6fab1cc794ac8e8148b171fa774a7c7c06055b67ccd6cfbd58da83a005f9abb8b1726e555404fe1baee9031ad73c8d5aa9b7d4660e5e2de87a38102
|
7
|
+
data.tar.gz: 2126c8d8c4e370b042909b1e0c376bdbddf9d68a128894b1a2040652b96aac2e287714d755cb815b1dc0d2e0d52b50943af4ae40b75b06107c7586bf25d30a08
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ 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.4.11
|
10
|
+
|
11
|
+
**Fix**: (`iodine`) use Ruby `fork` instead of system `fork`, allowing Ruby hooks to run before and after forking. This also fixes an issue where the Ruby timer thread isn't (re)initialized.
|
12
|
+
|
9
13
|
#### Change log v.0.4.10
|
10
14
|
|
11
15
|
**Portability**: (`mac OS High Sierra`) iodine will load the Objective C library on macOS machines before starting up the server - this will prevent `fork` from crashing the server on macOS High Sierra, see [discussion here](https://github.com/puma/puma/issues/1421).
|
data/ext/iodine/defer.c
CHANGED
@@ -270,6 +270,15 @@ pool_pt defer_pool_start(unsigned int thread_count) {
|
|
270
270
|
Child Process support (`fork`)
|
271
271
|
***************************************************************************** */
|
272
272
|
|
273
|
+
/**
|
274
|
+
OVERRIDE THIS to replace the default `fork` implementation or to inject hooks
|
275
|
+
into the forking function.
|
276
|
+
|
277
|
+
Behaves like the system's `fork`.
|
278
|
+
*/
|
279
|
+
#pragma weak defer_new_child
|
280
|
+
int defer_new_child(void) { return (int)fork(); }
|
281
|
+
|
273
282
|
/* forked `defer` workers use a global thread pool object. */
|
274
283
|
static pool_pt forked_pool;
|
275
284
|
|
@@ -367,7 +376,7 @@ int defer_perform_in_fork(unsigned int process_count,
|
|
367
376
|
if (process_count && !pids)
|
368
377
|
goto finish;
|
369
378
|
for (pids_count = 0; pids_count < process_count; pids_count++) {
|
370
|
-
if (!(pids[pids_count] =
|
379
|
+
if (!(pids[pids_count] = (pid_t)defer_new_child())) {
|
371
380
|
defer_fork_pid_id = pids_count + 1;
|
372
381
|
forked_pool = &pool_placeholder;
|
373
382
|
forked_pool = defer_pool_start(thread_count);
|
data/ext/iodine/defer.h
CHANGED
@@ -91,6 +91,14 @@ void defer_thread_throttle(unsigned long microsec);
|
|
91
91
|
Child Process support (`fork`)
|
92
92
|
***************************************************************************** */
|
93
93
|
|
94
|
+
/**
|
95
|
+
OVERRIDE THIS to replace the default `fork` implementation or to inject hooks
|
96
|
+
into the forking function.
|
97
|
+
|
98
|
+
Behaves like the system's `fork`.
|
99
|
+
*/
|
100
|
+
int defer_new_child(void);
|
101
|
+
|
94
102
|
/**
|
95
103
|
* Forks the process, starts up a thread pool and waits for all tasks to run.
|
96
104
|
* All existing tasks will run in all processes (multiple times).
|
data/ext/iodine/rb-defer.c
CHANGED
@@ -8,6 +8,8 @@ Feel free to copy, use and enjoy according to the license provided.
|
|
8
8
|
#include "rb-registry.h"
|
9
9
|
#include <ruby.h>
|
10
10
|
#include <ruby/thread.h>
|
11
|
+
|
12
|
+
#include <stdint.h>
|
11
13
|
// clang-format on
|
12
14
|
|
13
15
|
#include "defer.h"
|
@@ -41,10 +43,18 @@ static void *create_ruby_thread_gvl(void *args) {
|
|
41
43
|
}
|
42
44
|
|
43
45
|
/* protect the call to join from any exceptions */
|
44
|
-
static void *
|
46
|
+
static void *inner_join_with_rbthread_(void *rbt) {
|
45
47
|
return (void *)rb_funcall((VALUE)rbt, rb_intern("join"), 0);
|
46
48
|
}
|
47
49
|
|
50
|
+
static void *fork_using_ruby(void *ignr) {
|
51
|
+
const VALUE ProcessClass = rb_const_get(rb_cObject, rb_intern("Process"));
|
52
|
+
const VALUE pid = rb_funcall(ProcessClass, rb_intern("fork"), 0);
|
53
|
+
if (pid == Qnil)
|
54
|
+
return (void *)0;
|
55
|
+
return (void *)(intptr_t)(NUM2INT(pid));
|
56
|
+
}
|
57
|
+
|
48
58
|
/* *****************************************************************************
|
49
59
|
The Defer library overriding functions
|
50
60
|
***************************************************************************** */
|
@@ -69,7 +79,18 @@ OVERRIDE THIS to replace the default pthread implementation.
|
|
69
79
|
int defer_join_thread(void *thr) {
|
70
80
|
if (!thr || (VALUE)thr == Qfalse || (VALUE)thr == Qnil)
|
71
81
|
return -1;
|
72
|
-
rb_thread_call_with_gvl(
|
82
|
+
rb_thread_call_with_gvl(inner_join_with_rbthread_, (void *)thr);
|
73
83
|
Registry.remove((VALUE)thr);
|
74
84
|
return 0;
|
75
85
|
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
OVERRIDE THIS to replace the default `fork` implementation or to inject hooks
|
89
|
+
into the forking function.
|
90
|
+
|
91
|
+
Behaves like the system's `fork`.
|
92
|
+
*/
|
93
|
+
int defer_new_child(void) {
|
94
|
+
intptr_t pid = (intptr_t)rb_thread_call_with_gvl(fork_using_ruby, NULL);
|
95
|
+
return (int)pid;
|
96
|
+
}
|
@@ -18,13 +18,6 @@ must be implemented by the including file (the callbacks).
|
|
18
18
|
#include <stdint.h>
|
19
19
|
#include <stdlib.h>
|
20
20
|
#include <string.h>
|
21
|
-
/* *****************************************************************************
|
22
|
-
API - Internal Helpers
|
23
|
-
***************************************************************************** */
|
24
|
-
|
25
|
-
/** used internally to mask and unmask client messages. */
|
26
|
-
inline static void websocket_xmask(void *msg, uint64_t len, uint32_t mask);
|
27
|
-
|
28
21
|
/* *****************************************************************************
|
29
22
|
API - Message Wrapping
|
30
23
|
***************************************************************************** */
|
@@ -124,13 +117,20 @@ websocket_buffer_peek(void *buffer, uint64_t len);
|
|
124
117
|
*
|
125
118
|
* Returns the remaining data in the existing buffer (can be 0).
|
126
119
|
*
|
127
|
-
* Notice: if there's any
|
128
|
-
* place the data at the begining of the buffer.
|
120
|
+
* Notice: if there's any data in the buffer that can't be parsed
|
121
|
+
* just yet, `memmove` is used to place the data at the begining of the buffer.
|
129
122
|
*/
|
130
123
|
inline static __attribute__((unused)) uint64_t
|
131
124
|
websocket_consume(void *buffer, uint64_t len, void *udata,
|
132
125
|
uint8_t require_masking);
|
133
126
|
|
127
|
+
/* *****************************************************************************
|
128
|
+
API - Internal Helpers
|
129
|
+
***************************************************************************** */
|
130
|
+
|
131
|
+
/** used internally to mask and unmask client messages. */
|
132
|
+
inline static void websocket_xmask(void *msg, uint64_t len, uint32_t mask);
|
133
|
+
|
134
134
|
/* *****************************************************************************
|
135
135
|
|
136
136
|
Implementation
|
@@ -330,14 +330,16 @@ Message unwrapping
|
|
330
330
|
*/
|
331
331
|
inline static struct websocket_packet_info_s
|
332
332
|
websocket_buffer_peek(void *buffer, uint64_t len) {
|
333
|
-
if (len < 2)
|
333
|
+
if (len < 2) {
|
334
334
|
return (struct websocket_packet_info_s){0, 2, 0};
|
335
|
+
}
|
335
336
|
const uint8_t mask_f = (((uint8_t *)buffer)[1] >> 7) & 1;
|
336
337
|
const uint8_t mask_l = (mask_f << 2);
|
337
338
|
uint8_t len_indicator = (((uint8_t *)buffer)[1] & 127);
|
338
|
-
if (len < 126)
|
339
|
+
if (len < 126) {
|
339
340
|
return (struct websocket_packet_info_s){len_indicator,
|
340
341
|
(uint8_t)(2 + mask_l), mask_f};
|
342
|
+
}
|
341
343
|
switch (len_indicator) {
|
342
344
|
case 126:
|
343
345
|
if (len < 4)
|
data/iodine.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Boaz Segev']
|
10
10
|
spec.email = ['bo@plezi.io']
|
11
11
|
|
12
|
-
spec.summary = 'iodine - HTTP / Websocket Server with Pub/Sub support, optimized for Ruby MRI on Linux / BSD'
|
13
|
-
spec.description = '
|
12
|
+
spec.summary = 'iodine - a fast HTTP / Websocket Server with Pub/Sub support, optimized for Ruby MRI on Linux / BSD'
|
13
|
+
spec.description = 'A fast HTTP / Websocket Server with built-in Pub/Sub support (with or without Redis), static file support and many other features, optimized for Ruby MRI on Linux / BSD / macOS'
|
14
14
|
spec.homepage = 'https://github.com/boazsegev/iodine'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
@@ -31,17 +31,17 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.required_ruby_version = '>= 2.2.2' # Because earlier versions had been discontinued
|
33
33
|
|
34
|
-
spec.add_dependency 'rack'
|
34
|
+
spec.add_dependency 'rack', '>= 1.0', '< 3.0'
|
35
35
|
|
36
36
|
spec.requirements << 'A Unix based system: Linux / macOS / BSD.'
|
37
37
|
spec.requirements << 'An updated C compiler.'
|
38
38
|
spec.requirements << 'Ruby >= 2.2.2 required for Rack 2.'
|
39
39
|
spec.requirements << 'Ruby >= 2.4.0 recommended.'
|
40
40
|
|
41
|
-
spec.add_development_dependency 'bundler', '>= 1.10'
|
42
|
-
spec.add_development_dependency 'rake', '~> 12.0'
|
43
|
-
spec.add_development_dependency 'minitest', '>=5'
|
44
|
-
spec.add_development_dependency 'rake-compiler', '>= 1'
|
41
|
+
spec.add_development_dependency 'bundler', '>= 1.10', '< 2.0'
|
42
|
+
spec.add_development_dependency 'rake', '~> 12.0', '< 13.0'
|
43
|
+
spec.add_development_dependency 'minitest', '>=5', '< 6.0'
|
44
|
+
spec.add_development_dependency 'rake-compiler', '>= 1', '< 2.0'
|
45
45
|
|
46
46
|
# spec.post_install_message = "** WARNING!\n" \
|
47
47
|
# "Iodine 0.2.0 is NOT an upgrade - it's a total rewrite, it's written in C specifically for Ruby MRI.\n\n" \
|
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.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '1.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
29
|
+
version: '1.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '1.10'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
34
43
|
type: :development
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '1.10'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: rake
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +57,9 @@ dependencies:
|
|
45
57
|
- - "~>"
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '12.0'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '13.0'
|
48
63
|
type: :development
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,6 +67,9 @@ dependencies:
|
|
52
67
|
- - "~>"
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: '12.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '13.0'
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: minitest
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +77,9 @@ dependencies:
|
|
59
77
|
- - ">="
|
60
78
|
- !ruby/object:Gem::Version
|
61
79
|
version: '5'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '6.0'
|
62
83
|
type: :development
|
63
84
|
prerelease: false
|
64
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,6 +87,9 @@ dependencies:
|
|
66
87
|
- - ">="
|
67
88
|
- !ruby/object:Gem::Version
|
68
89
|
version: '5'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '6.0'
|
69
93
|
- !ruby/object:Gem::Dependency
|
70
94
|
name: rake-compiler
|
71
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +97,9 @@ dependencies:
|
|
73
97
|
- - ">="
|
74
98
|
- !ruby/object:Gem::Version
|
75
99
|
version: '1'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
76
103
|
type: :development
|
77
104
|
prerelease: false
|
78
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,8 +107,12 @@ dependencies:
|
|
80
107
|
- - ">="
|
81
108
|
- !ruby/object:Gem::Version
|
82
109
|
version: '1'
|
83
|
-
|
84
|
-
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '2.0'
|
113
|
+
description: A fast HTTP / Websocket Server with built-in Pub/Sub support (with or
|
114
|
+
without Redis), static file support and many other features, optimized for Ruby
|
115
|
+
MRI on Linux / BSD / macOS
|
85
116
|
email:
|
86
117
|
- bo@plezi.io
|
87
118
|
executables:
|
@@ -259,6 +290,6 @@ rubyforge_project:
|
|
259
290
|
rubygems_version: 2.6.11
|
260
291
|
signing_key:
|
261
292
|
specification_version: 4
|
262
|
-
summary: iodine - HTTP / Websocket Server with Pub/Sub support, optimized for
|
263
|
-
MRI on Linux / BSD
|
293
|
+
summary: iodine - a fast HTTP / Websocket Server with Pub/Sub support, optimized for
|
294
|
+
Ruby MRI on Linux / BSD
|
264
295
|
test_files: []
|