rage-iodine 3.3.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/ext/iodine/fio.c +16 -6
- data/ext/iodine/scheduler.c +42 -6
- data/lib/iodine/version.rb +1 -1
- data/lib/iodine.rb +0 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4262f702902096226a678e94c8b73acf61798fb5441c8cfbb04a831cbea7a738
|
4
|
+
data.tar.gz: fdede223e570118defae54723fe52744cc01548e1c0c71d303dfc4760448d76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf0070ab89370aa02970d80d920ac5b498172e5dfc2ef78b460a1d2d131886ef033a16f96107b3510f4b1652622e133942dcd16d438adead001962bcba54111
|
7
|
+
data.tar.gz: 85a2937799e604dbd0079668b5432bd785b3550d7e3e5dd94bae41f0b0c7b58ed68c036aad6cbcb79dadaddfb6534a31c0f0b34e34bfb5773c8dbfab84a0656d
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,16 @@ Please notice that this change log contains changes for upcoming releases as wel
|
|
6
6
|
|
7
7
|
## Changes:
|
8
8
|
|
9
|
+
#### Change log v.4.1.0 (2025-02-07)
|
10
|
+
|
11
|
+
**Update**: Correctly handle `0` timeouts.
|
12
|
+
|
13
|
+
#### Change log v.4.0.0 (2024-09-11)
|
14
|
+
|
15
|
+
**Update**: Stop disconnecting from the DB on fork.
|
16
|
+
|
17
|
+
**Update**: Fiber Scheduler updates to correctly close file descriptors.
|
18
|
+
|
9
19
|
#### Change log v.3.3.0 (2024-08-18)
|
10
20
|
|
11
21
|
**Update**: Improvements and fixes for the static file service.
|
data/ext/iodine/fio.c
CHANGED
@@ -363,6 +363,8 @@ typedef struct {
|
|
363
363
|
uint8_t open;
|
364
364
|
/** indicated that the connection should be closed. */
|
365
365
|
uint8_t close;
|
366
|
+
/** indicates whether the fd is coming from the Fiber Scheduler. */
|
367
|
+
uint8_t internal;
|
366
368
|
/** peer address length */
|
367
369
|
uint8_t addr_len;
|
368
370
|
/** peer address */
|
@@ -2075,7 +2077,7 @@ static size_t fio_poll(void) {
|
|
2075
2077
|
epoll_wait(internal[j].data.fd, events, FIO_POLL_MAX_EVENTS, 0);
|
2076
2078
|
if (active_count > 0) {
|
2077
2079
|
for (int i = 0; i < active_count; i++) {
|
2078
|
-
if (events[i].events & (~(EPOLLIN | EPOLLOUT | EPOLLHUP | EPOLLRDHUP))) {
|
2080
|
+
if (events[i].events & (~(EPOLLIN | EPOLLOUT | EPOLLHUP | EPOLLRDHUP | EPOLLERR))) {
|
2079
2081
|
// errors are hendled as disconnections (on_close)
|
2080
2082
|
fio_force_close_in_poll(fd2uuid(events[i].data.fd));
|
2081
2083
|
} else {
|
@@ -2088,9 +2090,12 @@ static size_t fio_poll(void) {
|
|
2088
2090
|
fio_defer_push_task(deferred_on_data,
|
2089
2091
|
(void *)fd2uuid(events[i].data.fd), NULL);
|
2090
2092
|
}
|
2091
|
-
if (events[i].events & (EPOLLHUP | EPOLLRDHUP)) {
|
2092
|
-
|
2093
|
-
|
2093
|
+
if (events[i].events & (EPOLLHUP | EPOLLRDHUP | EPOLLERR)) {
|
2094
|
+
if(fd_data(events[i].data.fd).internal) {
|
2095
|
+
fio_force_close_in_poll(fd2uuid(events[i].data.fd));
|
2096
|
+
} else {
|
2097
|
+
fio_clear_fd((intptr_t)events[i].data.fd, 0);
|
2098
|
+
}
|
2094
2099
|
}
|
2095
2100
|
}
|
2096
2101
|
} // end for loop
|
@@ -2226,8 +2231,11 @@ static size_t fio_poll(void) {
|
|
2226
2231
|
NULL);
|
2227
2232
|
}
|
2228
2233
|
if (events[i].flags & (EV_EOF | EV_ERROR)) {
|
2229
|
-
|
2230
|
-
|
2234
|
+
if(fd_data(events[i].udata).internal) {
|
2235
|
+
fio_force_close_in_poll(fd2uuid(events[i].udata));
|
2236
|
+
} else {
|
2237
|
+
fio_clear_fd((intptr_t)events[i].udata, 0);
|
2238
|
+
}
|
2231
2239
|
}
|
2232
2240
|
}
|
2233
2241
|
} else if (active_count < 0) {
|
@@ -4033,6 +4041,7 @@ static int fio_attach__internal(void *uuid_, void *protocol_) {
|
|
4033
4041
|
}
|
4034
4042
|
fio_protocol_s *old_pr = uuid_data(uuid).protocol;
|
4035
4043
|
uuid_data(uuid).open = 1;
|
4044
|
+
uuid_data(uuid).internal = 1;
|
4036
4045
|
uuid_data(uuid).protocol = protocol;
|
4037
4046
|
touchfd(fio_uuid2fd(uuid));
|
4038
4047
|
fio_unlock(&uuid_data(uuid).protocol_lock);
|
@@ -4093,6 +4102,7 @@ static int fio_watch__internal(void *uuid_, void *protocol_) {
|
|
4093
4102
|
|
4094
4103
|
fio_protocol_s *old_pr = uuid_data(uuid).protocol;
|
4095
4104
|
uuid_data(uuid).open = 1;
|
4105
|
+
uuid_data(uuid).internal = 0;
|
4096
4106
|
uuid_data(uuid).protocol = protocol;
|
4097
4107
|
touchfd(fio_uuid2fd(uuid));
|
4098
4108
|
fio_unlock(&uuid_data(uuid).protocol_lock);
|
data/ext/iodine/scheduler.c
CHANGED
@@ -15,7 +15,9 @@
|
|
15
15
|
static ID call_id;
|
16
16
|
static uint8_t ATTACH_ON_READ_READY_CALLBACK;
|
17
17
|
static uint8_t ATTACH_ON_WRITE_READY_CALLBACK;
|
18
|
-
static VALUE
|
18
|
+
static VALUE e_timeout_args[1];
|
19
|
+
static VALUE e_closed_args[1];
|
20
|
+
static VALUE e_not_ready_args[1];
|
19
21
|
|
20
22
|
/* *****************************************************************************
|
21
23
|
Fiber Scheduler API
|
@@ -36,6 +38,10 @@ typedef struct {
|
|
36
38
|
static void iodine_scheduler_task_close(intptr_t uuid, fio_protocol_s *fio_protocol) {
|
37
39
|
scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
|
38
40
|
|
41
|
+
if (!protocol->fulfilled) {
|
42
|
+
IodineCaller.call2(protocol->block, call_id, 1, e_closed_args);
|
43
|
+
}
|
44
|
+
|
39
45
|
IodineStore.remove(protocol->block);
|
40
46
|
fio_free(protocol);
|
41
47
|
|
@@ -53,11 +59,30 @@ static void iodine_scheduler_task_perform(intptr_t uuid, fio_protocol_s *fio_pro
|
|
53
59
|
(void)uuid;
|
54
60
|
}
|
55
61
|
|
62
|
+
static void iodine_scheduler_task_not_ready(void *uuid, void *fio_protocol) {
|
63
|
+
scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
|
64
|
+
|
65
|
+
if (!protocol->fulfilled) {
|
66
|
+
IodineCaller.call2(protocol->block, call_id, 1, e_not_ready_args);
|
67
|
+
protocol->fulfilled = 1;
|
68
|
+
}
|
69
|
+
|
70
|
+
(void)uuid;
|
71
|
+
}
|
72
|
+
|
73
|
+
static void iodine_scheduler_task_deferred_not_ready(intptr_t uuid, fio_protocol_s *fio_protocol) {
|
74
|
+
// if there's a read event, `fio_defer` will give it time to fulfill the protocol first;
|
75
|
+
// otherwise, the fiber will be resumed with `false` indicating the IO is not ready
|
76
|
+
fio_defer(iodine_scheduler_task_not_ready, (void *)uuid, (void *)fio_protocol);
|
77
|
+
|
78
|
+
(void)uuid;
|
79
|
+
}
|
80
|
+
|
56
81
|
static void iodine_scheduler_task_timeout(intptr_t uuid, fio_protocol_s *fio_protocol) {
|
57
82
|
scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
|
58
83
|
|
59
84
|
if (!protocol->fulfilled) {
|
60
|
-
IodineCaller.call2(protocol->block, call_id, 1,
|
85
|
+
IodineCaller.call2(protocol->block, call_id, 1, e_timeout_args);
|
61
86
|
protocol->fulfilled = 1;
|
62
87
|
}
|
63
88
|
}
|
@@ -69,8 +94,11 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
|
|
69
94
|
Check_Type(r_waittype, T_FIXNUM);
|
70
95
|
size_t waittype = FIX2UINT(r_waittype);
|
71
96
|
|
72
|
-
|
73
|
-
|
97
|
+
size_t timeout;
|
98
|
+
if (r_timeout != Qnil) {
|
99
|
+
Check_Type(r_timeout, T_FIXNUM);
|
100
|
+
timeout = FIX2UINT(r_timeout);
|
101
|
+
}
|
74
102
|
|
75
103
|
fio_set_non_block(fd);
|
76
104
|
|
@@ -107,8 +135,14 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
|
|
107
135
|
}
|
108
136
|
|
109
137
|
intptr_t uuid = fio_fd2uuid(fd);
|
110
|
-
|
138
|
+
|
139
|
+
if (r_timeout == Qnil) {
|
140
|
+
fio_timeout_set(uuid, 0);
|
141
|
+
} else if (timeout) {
|
111
142
|
fio_timeout_set(uuid, timeout);
|
143
|
+
} else {
|
144
|
+
// timeout was explicitly set to 0 - return right away
|
145
|
+
protocol->p.on_ready = iodine_scheduler_task_deferred_not_ready;
|
112
146
|
}
|
113
147
|
|
114
148
|
fio_watch(uuid, (fio_protocol_s *)protocol);
|
@@ -178,7 +212,9 @@ Scheduler initialization
|
|
178
212
|
|
179
213
|
void iodine_scheduler_initialize(void) {
|
180
214
|
call_id = rb_intern2("call", 4);
|
181
|
-
|
215
|
+
e_timeout_args[0] = INT2NUM(-ETIMEDOUT);
|
216
|
+
e_closed_args[0] = INT2NUM(-EIO);
|
217
|
+
e_not_ready_args[0] = Qfalse;
|
182
218
|
|
183
219
|
VALUE SchedulerModule = rb_define_module_under(IodineModule, "Scheduler");
|
184
220
|
|
data/lib/iodine/version.rb
CHANGED
data/lib/iodine.rb
CHANGED
@@ -156,12 +156,6 @@ require 'rack/handler/iodine' unless defined? ::Iodine::Rack::IODINE_RACK_LOADED
|
|
156
156
|
|
157
157
|
### Automatic ActiveRecord and Sequel support for forking (preventing connection sharing)
|
158
158
|
Iodine.on_state(:before_fork) do
|
159
|
-
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && ActiveRecord::Base.respond_to?(:connection)
|
160
|
-
begin
|
161
|
-
ActiveRecord::Base.connection.disconnect!
|
162
|
-
rescue
|
163
|
-
end
|
164
|
-
end
|
165
159
|
if defined?(Sequel)
|
166
160
|
begin
|
167
161
|
Sequel::DATABASES.each { |database| database.disconnect }
|
@@ -169,14 +163,6 @@ Iodine.on_state(:before_fork) do
|
|
169
163
|
end
|
170
164
|
end
|
171
165
|
end
|
172
|
-
Iodine.on_state(:after_fork) do
|
173
|
-
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && ActiveRecord::Base.respond_to?(:establish_connection)
|
174
|
-
begin
|
175
|
-
ActiveRecord::Base.establish_connection
|
176
|
-
rescue
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
166
|
|
181
167
|
### Parse CLI for default HTTP settings
|
182
168
|
Iodine::Base::CLI.parse if defined?(IODINE_PARSE_CLI) && IODINE_PARSE_CLI
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rage-iodine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|