io-event 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbc13d55bf16de818e95478a83d0da64de1b9844bf92fd2970df3e8cc42d8240
4
- data.tar.gz: 41e8fb1ad62705688c44ff774e44360ffef8223c8d308c01d1163b66b67c3abe
3
+ metadata.gz: df3b3dcc41afd982188c85b96e4d63056ae5edb43c41a5f650f8af9d2e6d5bf1
4
+ data.tar.gz: d3b1ca8e0241b85517940941507163c2c0a1faff442908521e0749b1848d5820
5
5
  SHA512:
6
- metadata.gz: 878bb331d512cd99115da6451c07e06160fcf868e208280ef042d652be2d5cd606b1bb14623337ff1672729cb2f20b78f85232fd793a5baea274b3b5159a51ef
7
- data.tar.gz: 85fc1b0faa924bb3c4f62de80262275a321f8b36a23954f110e9e78e7d7c156a0df62b3bdcc1feabaff14ab14107db6f37d51aa7ad0d00c139690b7231b482c4
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
- static const int DEBUG = 0;
31
+ enum {
32
+ DEBUG = 0,
33
+ };
32
34
 
33
35
  static VALUE IO_Event_Selector_EPoll = Qnil;
34
36
 
@@ -325,26 +327,38 @@ VALUE IO_Event_Selector_EPoll_io_wait(VALUE self, VALUE fiber, VALUE io, VALUE e
325
327
  event.events = epoll_flags_from_events(NUM2INT(events));
326
328
  event.data.ptr = (void*)fiber;
327
329
 
328
- // fprintf(stderr, "<- fiber=%p descriptor=%d\n", (void*)fiber, descriptor);
330
+ if (DEBUG) fprintf(stderr, "<- fiber=%p descriptor=%d\n", (void*)fiber, descriptor);
329
331
 
330
332
  // A better approach is to batch all changes:
331
333
  int result = epoll_ctl(data->descriptor, EPOLL_CTL_ADD, descriptor, &event);
332
334
 
333
335
  if (result == -1 && errno == EEXIST) {
334
336
  // The file descriptor was already inserted into epoll.
335
- duplicate = descriptor = dup(descriptor);
336
-
337
- rb_update_max_fd(duplicate);
337
+ duplicate = dup(descriptor);
338
338
 
339
- if (descriptor == -1) {
339
+ if (duplicate == -1) {
340
340
  rb_sys_fail("IO_Event_Selector_EPoll_io_wait:dup");
341
341
  }
342
342
 
343
+ descriptor = duplicate;
344
+
345
+ rb_update_max_fd(descriptor);
346
+
343
347
  result = epoll_ctl(data->descriptor, EPOLL_CTL_ADD, descriptor, &event);
344
348
  }
345
349
 
346
350
  if (result == -1) {
347
- if (duplicate >= 0) close(duplicate);
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
+
348
362
  rb_sys_fail("IO_Event_Selector_EPoll_io_wait:epoll_ctl");
349
363
  }
350
364
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module IO::Event
22
- VERSION = "1.0.4"
22
+ VERSION = "1.0.5"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-03-09 00:00:00.000000000 Z
14
+ date: 2022-03-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bake
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.3.8
126
+ rubygems_version: 3.2.32
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: An event loop.