io-event 1.16.0 → 1.16.1

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: 4928b16497387fabcf4eb19d7dfefe5840674e385b086db2f0df0a15367e4d09
4
- data.tar.gz: 635ceb881767fc1d6fd876f39da295b9402971f3aaf0e5778ef022108abaf890
3
+ metadata.gz: dd552a5bb53e9a2e9169c55a7f789e84f761a2707c83edd5955512818ad55e25
4
+ data.tar.gz: 97a35fef870d94f7c596d612fdd6664c2e65cff9b14a8cf6b9035b12584f0833
5
5
  SHA512:
6
- metadata.gz: 943e688606c2df3398c465103e1212143d2af98cf0b36f761f54ca4f9f627fe833992106c5b8c851fe61b7dba5b73dcf81978ec6db7f126af6532b25bd19815f
7
- data.tar.gz: e3870c0635b7f3ea0fd01390f5401adb2cd99fc9e7afc326b05efbf870715c609a5cde47f45b0e326223c7caad752ae51258cbe6f92eac7a7e9b799e58de3f2a
6
+ metadata.gz: e187b07cc91e2ecf7fb641a61f481fbb9ba42a1a52c14532fa659ede0a6723dde5ac63e35d7a584d549ca52a94462131f5755b9da7bce1b06abd99f1ea6b3f24
7
+ data.tar.gz: '090f2023d28eac6b05386727f0497bbd02db76b6a3bf0b43f9e068e5e5d36edb543a16c94806fea736c319298b491b1d13e069c7f89bf41a89dd86171b183c96'
checksums.yaml.gz.sig CHANGED
Binary file
@@ -32,7 +32,6 @@ struct IO_Event_Selector_URing
32
32
  {
33
33
  struct IO_Event_Selector backend;
34
34
  struct io_uring ring;
35
- size_t pending;
36
35
 
37
36
  // Flag indicating whether the selector is currently blocked in a system call.
38
37
  // Set to 1 when blocked in io_uring_wait_cqe_timeout() without GVL, 0 otherwise.
@@ -239,7 +238,6 @@ VALUE IO_Event_Selector_URing_allocate(VALUE self) {
239
238
  IO_Event_Selector_initialize(&selector->backend, self, Qnil);
240
239
  selector->ring.ring_fd = -1;
241
240
 
242
- selector->pending = 0;
243
241
  selector->blocked = 0;
244
242
  selector->interrupt.descriptor = -1;
245
243
  selector->wakeup_registered = 0;
@@ -421,15 +419,14 @@ void IO_Event_Selector_URing_dump_completion_queue(struct IO_Event_Selector_URin
421
419
  // Flush the submission queue, optionally yielding if unsuccessful.
422
420
  static
423
421
  int io_uring_submit_all(struct IO_Event_Selector_URing *selector, bool yield) {
424
- while (selector->pending > 0) {
422
+ struct io_uring *ring = &selector->ring;
423
+
424
+ while (io_uring_sq_ready(ring) > 0) {
425
425
  int result = io_uring_submit(&selector->ring);
426
426
 
427
- if (result >= 0) {
428
- // io_uring_submit() returns the number of submitted SQEs
429
- selector->pending -= result;
430
- } else if (result == -EBUSY || result == -EAGAIN) {
427
+ if (result == -EBUSY || result == -EAGAIN) {
431
428
  if (yield) IO_Event_Selector_yield(&selector->backend);
432
- } else {
429
+ } else if (result < 0) {
433
430
  rb_syserr_fail(-result, "io_uring_submit_all:io_uring_submit");
434
431
  return result;
435
432
  }
@@ -442,7 +439,10 @@ int io_uring_submit_all(struct IO_Event_Selector_URing *selector, bool yield) {
442
439
  // Flush the submission queue if pending operations are present.
443
440
  static
444
441
  int io_uring_submit_flush(struct IO_Event_Selector_URing *selector) {
445
- if (DEBUG) fprintf(stderr, "io_uring_submit_now(pending=%ld)\n", selector->pending);
442
+ if (DEBUG) {
443
+ unsigned pending = io_uring_sq_ready(&selector->ring);
444
+ fprintf(stderr, "io_uring_submit_flush(pending=%u)\n", pending);
445
+ }
446
446
 
447
447
  return io_uring_submit_all(selector, false);
448
448
  }
@@ -450,15 +450,21 @@ int io_uring_submit_flush(struct IO_Event_Selector_URing *selector) {
450
450
  // Immediately flush the submission queue, yielding to the event loop if it was not successful.
451
451
  static
452
452
  int io_uring_submit_now(struct IO_Event_Selector_URing *selector) {
453
- if (DEBUG) fprintf(stderr, "io_uring_submit_now(pending=%ld)\n", selector->pending);
454
-
453
+ if (DEBUG) {
454
+ unsigned pending = io_uring_sq_ready(&selector->ring);
455
+ fprintf(stderr, "io_uring_submit_now(pending=%u)\n", pending);
456
+ }
457
+
455
458
  return io_uring_submit_all(selector, true);
456
459
  }
457
460
 
458
461
  // Submit a pending operation. This does not submit the operation immediately, but instead defers it to the next call to `io_uring_submit_flush` or `io_uring_submit_now`. This is useful for operations that are not urgent, but should be used with care as it can lead to a deadlock if the submission queue is not flushed.
459
462
  static
460
463
  void io_uring_submit_pending(struct IO_Event_Selector_URing *selector) {
461
- if (DEBUG) fprintf(stderr, "io_uring_submit_pending(ring=%p, pending=%ld)\n", &selector->ring, selector->pending);
464
+ if (DEBUG) {
465
+ unsigned pending = io_uring_sq_ready(&selector->ring);
466
+ fprintf(stderr, "io_uring_submit_pending(ring=%p, pending=%u)\n", &selector->ring, pending);
467
+ }
462
468
  }
463
469
 
464
470
  struct io_uring_sqe * io_get_sqe(struct IO_Event_Selector_URing *selector) {
@@ -471,7 +477,6 @@ struct io_uring_sqe * io_get_sqe(struct IO_Event_Selector_URing *selector) {
471
477
  sqe = io_uring_get_sqe(&selector->ring);
472
478
  }
473
479
 
474
- selector->pending += 1;
475
480
  return sqe;
476
481
  }
477
482
 
@@ -159,7 +159,7 @@ module IO::Event
159
159
  def io_wait(fiber, io, events)
160
160
  waiter = @waiting[io] = Waiter.new(fiber, events, @waiting[io])
161
161
 
162
- @loop.transfer
162
+ @loop.transfer || false
163
163
  ensure
164
164
  waiter&.invalidate
165
165
  end
@@ -7,6 +7,6 @@
7
7
  class IO
8
8
  # @namespace
9
9
  module Event
10
- VERSION = "1.16.0"
10
+ VERSION = "1.16.1"
11
11
  end
12
12
  end
data/readme.md CHANGED
@@ -18,6 +18,10 @@ Please see the [project documentation](https://socketry.github.io/io-event/) for
18
18
 
19
19
  Please see the [project releases](https://socketry.github.io/io-event/releases/index) for all releases.
20
20
 
21
+ ### v1.16.1
22
+
23
+ - Ensure the pure Ruby `Select` selector returns `false`, not `nil`, when `io_wait` resumes without any ready events.
24
+
21
25
  ### v1.16.0
22
26
 
23
27
  - Use `eventfd` for `URing` cross-thread wakeup, and enable `IORING_SETUP_SINGLE_ISSUER`, `IORING_SETUP_DEFER_TASKRUN`, and `IORING_SETUP_TASKRUN_FLAG`. The waking thread now signals via `eventfd` rather than submitting a `NOP` SQE, which unlocks the single-issuer optimisation, defers task work to the application thread, and lets `select()` skip the `io_uring_get_events()` syscall when no task work is pending.
@@ -60,10 +64,6 @@ Please see the [project releases](https://socketry.github.io/io-event/releases/i
60
64
 
61
65
  - [Introduce `IO::Event::WorkerPool` for off-loading blocking operations.](https://socketry.github.io/io-event/releases/index#introduce-io::event::workerpool-for-off-loading-blocking-operations.)
62
66
 
63
- ### v1.10.2
64
-
65
- - Improved consistency of handling closed IO when invoking `#select`.
66
-
67
67
  ## Contributing
68
68
 
69
69
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v1.16.1
4
+
5
+ - Ensure the pure Ruby `Select` selector returns `false`, not `nil`, when `io_wait` resumes without any ready events.
6
+
3
7
  ## v1.16.0
4
8
 
5
9
  - Use `eventfd` for `URing` cross-thread wakeup, and enable `IORING_SETUP_SINGLE_ISSUER`, `IORING_SETUP_DEFER_TASKRUN`, and `IORING_SETUP_TASKRUN_FLAG`. The waking thread now signals via `eventfd` rather than submitting a `NOP` SQE, which unlocks the single-issuer optimisation, defers task work to the application thread, and lets `select()` skip the `io_uring_get_events()` syscall when no task work is pending.
data.tar.gz.sig CHANGED
Binary file
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.16.0
4
+ version: 1.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -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: 4.0.6
126
+ rubygems_version: 4.0.10
127
127
  specification_version: 4
128
128
  summary: An event loop.
129
129
  test_files: []
metadata.gz.sig CHANGED
Binary file