io-event 1.0.2 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/io/event/selector/epoll.c +28 -6
- data/ext/io/event/selector/selector.c +5 -0
- data/lib/io/event/debug/selector.rb +3 -6
- data/lib/io/event/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3b3dcc41afd982188c85b96e4d63056ae5edb43c41a5f650f8af9d2e6d5bf1
|
4
|
+
data.tar.gz: d3b1ca8e0241b85517940941507163c2c0a1faff442908521e0749b1848d5820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dcd4266b204828ed5514075ba2e00cdab0de2f20a63d8d37ee831493778b713e72ef51a97857fe1e3ec6761b1ba9f2a71bfb9e6b185249c18a1f6d9a3b28265
|
7
|
+
data.tar.gz: eaa160b9cb38c5564dad8b4b81971a6e8a30f27f409d8e547dff1514165eaced3d4954ea1db1ed33a4f22b2aeb82069aa7ad0755b84deb96d654a148904852b6
|
@@ -28,7 +28,9 @@
|
|
28
28
|
#include "pidfd.c"
|
29
29
|
#include "../interrupt.h"
|
30
30
|
|
31
|
-
|
31
|
+
enum {
|
32
|
+
DEBUG = 0,
|
33
|
+
};
|
32
34
|
|
33
35
|
static VALUE IO_Event_Selector_EPoll = Qnil;
|
34
36
|
|
@@ -231,6 +233,11 @@ VALUE IO_Event_Selector_EPoll_process_wait(VALUE self, VALUE fiber, VALUE pid, V
|
|
231
233
|
};
|
232
234
|
|
233
235
|
process_wait_arguments.descriptor = pidfd_open(process_wait_arguments.pid, 0);
|
236
|
+
|
237
|
+
if (process_wait_arguments.descriptor == -1) {
|
238
|
+
rb_sys_fail("IO_Event_Selector_EPoll_process_wait:pidfd_open");
|
239
|
+
}
|
240
|
+
|
234
241
|
rb_update_max_fd(process_wait_arguments.descriptor);
|
235
242
|
|
236
243
|
struct epoll_event event = {
|
@@ -241,6 +248,7 @@ VALUE IO_Event_Selector_EPoll_process_wait(VALUE self, VALUE fiber, VALUE pid, V
|
|
241
248
|
int result = epoll_ctl(data->descriptor, EPOLL_CTL_ADD, process_wait_arguments.descriptor, &event);
|
242
249
|
|
243
250
|
if (result == -1) {
|
251
|
+
close(process_wait_arguments.descriptor);
|
244
252
|
rb_sys_fail("IO_Event_Selector_EPoll_process_wait:epoll_ctl");
|
245
253
|
}
|
246
254
|
|
@@ -319,24 +327,38 @@ VALUE IO_Event_Selector_EPoll_io_wait(VALUE self, VALUE fiber, VALUE io, VALUE e
|
|
319
327
|
event.events = epoll_flags_from_events(NUM2INT(events));
|
320
328
|
event.data.ptr = (void*)fiber;
|
321
329
|
|
322
|
-
|
330
|
+
if (DEBUG) fprintf(stderr, "<- fiber=%p descriptor=%d\n", (void*)fiber, descriptor);
|
323
331
|
|
324
332
|
// A better approach is to batch all changes:
|
325
333
|
int result = epoll_ctl(data->descriptor, EPOLL_CTL_ADD, descriptor, &event);
|
326
334
|
|
327
335
|
if (result == -1 && errno == EEXIST) {
|
328
336
|
// The file descriptor was already inserted into epoll.
|
329
|
-
duplicate =
|
330
|
-
|
331
|
-
rb_update_max_fd(duplicate);
|
337
|
+
duplicate = dup(descriptor);
|
332
338
|
|
333
|
-
if (
|
339
|
+
if (duplicate == -1) {
|
334
340
|
rb_sys_fail("IO_Event_Selector_EPoll_io_wait:dup");
|
341
|
+
}
|
342
|
+
|
343
|
+
descriptor = duplicate;
|
344
|
+
|
345
|
+
rb_update_max_fd(descriptor);
|
335
346
|
|
336
347
|
result = epoll_ctl(data->descriptor, EPOLL_CTL_ADD, descriptor, &event);
|
337
348
|
}
|
338
349
|
|
339
350
|
if (result == -1) {
|
351
|
+
// If we duplicated the file descriptor, ensure it's closed:
|
352
|
+
if (duplicate >= 0) {
|
353
|
+
close(duplicate);
|
354
|
+
}
|
355
|
+
|
356
|
+
if (errno == EPERM) {
|
357
|
+
IO_Event_Selector_queue_push(&data->backend, fiber);
|
358
|
+
IO_Event_Selector_yield(&data->backend);
|
359
|
+
return events;
|
360
|
+
}
|
361
|
+
|
340
362
|
rb_sys_fail("IO_Event_Selector_EPoll_io_wait:epoll_ctl");
|
341
363
|
}
|
342
364
|
|
@@ -47,12 +47,9 @@ module IO::Event
|
|
47
47
|
@selector = nil
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
def transfer(*arguments)
|
55
|
-
@selector.transfer(*arguments)
|
50
|
+
# Transfer from the calling fiber to the event loop.
|
51
|
+
def transfer
|
52
|
+
@selector.transfer
|
56
53
|
end
|
57
54
|
|
58
55
|
def resume(*arguments)
|
data/lib/io/event/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- machty
|
9
|
+
- Benoit Daloze
|
10
|
+
- Delton Ding
|
8
11
|
autorequire:
|
9
12
|
bindir: bin
|
10
13
|
cert_chain: []
|
11
|
-
date: 2022-
|
14
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
12
15
|
dependencies:
|
13
16
|
- !ruby/object:Gem::Dependency
|
14
17
|
name: bake
|