io-event 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 202f6fedc64c46fd6d6ecfb8d8ca9a8e5f6e41c1c46182bb5b62ed03116aeb07
4
- data.tar.gz: a1d8fe1987852db3c4c6187c771783c98c1c661536690b74a499a951273da39f
3
+ metadata.gz: 82ae60c9c790437fc720a98489a0edcc345cca0420d795b2e33dcd8729f30dd2
4
+ data.tar.gz: f1a585938bb11cab9dd29a5acb50831feadce6e60d515112d2e8b22fdda5f65b
5
5
  SHA512:
6
- metadata.gz: f1d276fb8062dca9c05ed078f9ad91aac24e26d1a835ccee875d7ebe4e98e0bf93a236c0b97cf876aaccb4b40b52ffc4669d41c8e36215430e9d74c887c753a8
7
- data.tar.gz: 3765cd83a4e178e25fb6f9f24a6b4f4be014a3120465c380afe9daef5f3fdbbc63ac3db336ddcf986eab3adb49b5b85aa20b460916b3f4f9a2d140424a5ec843
6
+ metadata.gz: 34578267eccd7ae7c7c902f44db64f2be4a63e596c4c4522ed2199a5fd4c1247f1bcf31b02b0b2c21a8aa2856979c45421f86a01f0fbd32b824f5df91dd1ab7f
7
+ data.tar.gz: 3d4f4acd7739cc67c04e65c4a6f4079bd0d887c50cbb13f0d979b4d7f7f94916dc6067f93a33b8a63c67cae45b0f0743c2b9f4af4e46b1e33a7397910026ee86
data/ext/IO_Event.bundle CHANGED
Binary file
@@ -540,7 +540,11 @@ void select_internal_without_gvl(struct select_arguments *arguments) {
540
540
  arguments->data->blocked = 0;
541
541
 
542
542
  if (arguments->count == -1) {
543
- rb_sys_fail("select_internal_without_gvl:epoll_wait");
543
+ if (errno != EINTR) {
544
+ rb_sys_fail("select_internal_without_gvl:epoll_wait");
545
+ } else {
546
+ arguments->count = 0;
547
+ }
544
548
  }
545
549
  }
546
550
 
@@ -549,7 +553,11 @@ void select_internal_with_gvl(struct select_arguments *arguments) {
549
553
  select_internal((void *)arguments);
550
554
 
551
555
  if (arguments->count == -1) {
552
- rb_sys_fail("select_internal_with_gvl:epoll_wait");
556
+ if (errno != EINTR) {
557
+ rb_sys_fail("select_internal_with_gvl:epoll_wait");
558
+ } else {
559
+ arguments->count = 0;
560
+ }
553
561
  }
554
562
  }
555
563
 
@@ -605,7 +605,11 @@ void select_internal_without_gvl(struct select_arguments *arguments) {
605
605
  arguments->data->blocked = 0;
606
606
 
607
607
  if (arguments->count == -1) {
608
- rb_sys_fail("select_internal_without_gvl:kevent");
608
+ if (errno != EINTR) {
609
+ rb_sys_fail("select_internal_without_gvl:kevent");
610
+ } else {
611
+ arguments->count = 0;
612
+ }
609
613
  }
610
614
  }
611
615
 
@@ -614,7 +618,11 @@ void select_internal_with_gvl(struct select_arguments *arguments) {
614
618
  select_internal((void *)arguments);
615
619
 
616
620
  if (arguments->count == -1) {
617
- rb_sys_fail("select_internal_with_gvl:kevent");
621
+ if (errno != EINTR) {
622
+ rb_sys_fail("select_internal_with_gvl:kevent");
623
+ } else {
624
+ arguments->count = 0;
625
+ }
618
626
  }
619
627
  }
620
628
 
@@ -27,6 +27,8 @@
27
27
 
28
28
  #include "pidfd.c"
29
29
 
30
+ #include <linux/version.h>
31
+
30
32
  enum {
31
33
  DEBUG = 0,
32
34
  DEBUG_IO_READ = 0,
@@ -371,12 +373,28 @@ VALUE IO_Event_Selector_URing_io_wait(VALUE self, VALUE fiber, VALUE io, VALUE e
371
373
 
372
374
  #ifdef HAVE_RUBY_IO_BUFFER_H
373
375
 
376
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)
377
+ static inline off_t io_seekable(int descriptor) {
378
+ return -1;
379
+ }
380
+ #else
381
+ #warning Upgrade your kernel to 5.16! io_uring bugs prevent efficient io_read/io_write hooks.
382
+ static inline off_t io_seekable(int descriptor)
383
+ {
384
+ if (lseek(descriptor, 0, SEEK_CUR) == -1) {
385
+ return 0;
386
+ } else {
387
+ return -1;
388
+ }
389
+ }
390
+ #endif
391
+
374
392
  static int io_read(struct IO_Event_Selector_URing *data, VALUE fiber, int descriptor, char *buffer, size_t length) {
375
393
  struct io_uring_sqe *sqe = io_get_sqe(data);
376
394
 
377
395
  if (DEBUG) fprintf(stderr, "io_read:io_uring_prep_read(fiber=%p)\n", (void*)fiber);
378
396
 
379
- io_uring_prep_read(sqe, descriptor, buffer, length, -1);
397
+ io_uring_prep_read(sqe, descriptor, buffer, length, io_seekable(descriptor));
380
398
  io_uring_sqe_set_data(sqe, (void*)fiber);
381
399
  io_uring_submit_now(data);
382
400
 
@@ -427,7 +445,7 @@ int io_write(struct IO_Event_Selector_URing *data, VALUE fiber, int descriptor,
427
445
 
428
446
  if (DEBUG) fprintf(stderr, "io_write:io_uring_prep_write(fiber=%p)\n", (void*)fiber);
429
447
 
430
- io_uring_prep_write(sqe, descriptor, buffer, length, -1);
448
+ io_uring_prep_write(sqe, descriptor, buffer, length, io_seekable(descriptor));
431
449
  io_uring_sqe_set_data(sqe, (void*)fiber);
432
450
  io_uring_submit_pending(data);
433
451
 
@@ -558,6 +576,8 @@ int select_internal_without_gvl(struct select_arguments *arguments) {
558
576
 
559
577
  if (arguments->result == -ETIME) {
560
578
  arguments->result = 0;
579
+ } else if (arguments->result == -EINTR) {
580
+ arguments->result = 0;
561
581
  } else if (arguments->result < 0) {
562
582
  rb_syserr_fail(-arguments->result, "select_internal_without_gvl:io_uring_wait_cqe_timeout");
563
583
  } else {
@@ -568,8 +588,6 @@ int select_internal_without_gvl(struct select_arguments *arguments) {
568
588
  return arguments->result;
569
589
  }
570
590
 
571
- // #define IO_EVENT_SELECTOR_URING_UDATA_INTERRUPT ((__u64) -2)
572
-
573
591
  static inline
574
592
  unsigned select_process_completions(struct io_uring *ring) {
575
593
  unsigned completed = 0;
@@ -585,10 +603,6 @@ unsigned select_process_completions(struct io_uring *ring) {
585
603
  continue;
586
604
  }
587
605
 
588
- // if (cqe->user_data == IO_EVENT_SELECTOR_URING_UDATA_INTERRUPT) {
589
- // io_uring_cq_advance(ring, 1);
590
- // }
591
-
592
606
  VALUE fiber = (VALUE)cqe->user_data;
593
607
  VALUE result = RB_INT2NUM(cqe->res);
594
608
 
data/ext/kqueue.o CHANGED
Binary file
@@ -31,12 +31,10 @@ module IO::Event
31
31
  end
32
32
  end
33
33
 
34
- if self.const_defined?(:URing)
35
- return URing
34
+ if self.const_defined?(:EPoll)
35
+ return EPoll
36
36
  elsif self.const_defined?(:KQueue)
37
37
  return KQueue
38
- elsif self.const_defined?(:EPoll)
39
- return EPoll
40
38
  else
41
39
  return Select
42
40
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module IO::Event
22
- VERSION = "0.4.0"
22
+ VERSION = "0.5.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2021-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bake
@@ -113,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: '3.0'
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.3.0
123
+ rubygems_version: 3.2.32
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: An event loop.