io-event 1.14.2 → 1.14.3

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: 0deb2b3991062957f5767ac97e9abf7fe72b20e2264d08fd81293c407f92024f
4
- data.tar.gz: 93b9e08ea55f39b5b983b8627b91720047154a2f778d86fea620da54d5e3173c
3
+ metadata.gz: 153dd5fa3b8e1b61e31f0304ac5b0c3dd274a877899b7569d092865219cd18e8
4
+ data.tar.gz: 5eae7ea5c192e2df1e3c02738dc76a6c3072ad0265eee78b26ee74a17ce43697
5
5
  SHA512:
6
- metadata.gz: 2e58ec44e475bad561ddd53797a1552037fc92a4602dd89f6af92148130d4486d7dca47b6ae09bf11373be7e393a1baea835ae29e3ea388da4d4189b1d87be47
7
- data.tar.gz: 9040993cc15180b65f142a28529d6672dceb88de0ae887ca9f1815bf0e11d4fe7929a3295ec50110b6c7faab83728cf36bf5c51d564b377eca4af40b756e9140
6
+ metadata.gz: 9b85b8d27de9d9319fcba699b6c939670a898210170f842ff7381a8f0446d04c1ca7da3f994265ce77cd2631ee621cbcb6943d39eb386045a169675d87a7d8f3
7
+ data.tar.gz: 3b4482cbe17cef909e01fb1701b30320f46497c97a3a7c77fe1c11da33cfd4eb20353dcc68476b25c147f410e217b42a45c9a1c0ee14e8dca1f54ceaf0051619
checksums.yaml.gz.sig CHANGED
Binary file
@@ -728,7 +728,7 @@ VALUE io_write_loop(VALUE _arguments) {
728
728
  break;
729
729
  } else if (length > 0 && IO_Event_try_again(errno)) {
730
730
  if (DEBUG_IO_WRITE) fprintf(stderr, "IO_Event_Selector_KQueue_io_wait(fd=%d, length=%zu)\n", arguments->descriptor, length);
731
- IO_Event_Selector_KQueue_io_wait(arguments->self, arguments->fiber, arguments->io, RB_INT2NUM(IO_EVENT_READABLE));
731
+ IO_Event_Selector_KQueue_io_wait(arguments->self, arguments->fiber, arguments->io, RB_INT2NUM(IO_EVENT_WRITABLE));
732
732
  } else {
733
733
  if (DEBUG_IO_WRITE) fprintf(stderr, "io_write_loop(fd=%d, length=%zu) -> errno=%d\n", arguments->descriptor, length, errno);
734
734
  return rb_fiber_scheduler_io_result(-1, errno);
@@ -737,7 +737,7 @@ VALUE io_write_loop(VALUE _arguments) {
737
737
  maximum_size = size - offset;
738
738
  }
739
739
 
740
- if (DEBUG_IO_READ) fprintf(stderr, "io_write_loop(fd=%d, length=%zu) -> %zu\n", arguments->descriptor, length, offset);
740
+ if (DEBUG_IO_WRITE) fprintf(stderr, "io_write_loop(fd=%d, length=%zu) -> %zu\n", arguments->descriptor, length, offset);
741
741
  return rb_fiber_scheduler_io_result(total, 0);
742
742
  };
743
743
 
@@ -29,7 +29,7 @@ VALUE IO_Event_Selector_process_status_wait(rb_pid_t pid, int flags)
29
29
  int IO_Event_Selector_nonblock_set(int file_descriptor)
30
30
  {
31
31
  #ifdef _WIN32
32
- rb_w32_set_nonblock(file_descriptor);
32
+ return rb_w32_set_nonblock(file_descriptor);
33
33
  #else
34
34
  // Get the current mode:
35
35
  int flags = fcntl(file_descriptor, F_GETFL, 0);
@@ -988,6 +988,10 @@ VALUE IO_Event_Selector_URing_io_close(VALUE self, VALUE io) {
988
988
  io_uring_prep_close(sqe, descriptor);
989
989
  io_uring_sqe_set_data(sqe, NULL);
990
990
  io_uring_submit_now(selector);
991
+
992
+ // It would be nice to explore not flushing immediately, but instead deferring to the next select cycle.
993
+ // The problem with this approach is that if the user expects the file descriptor to be closed immediately, (e.g. before fork), it may not be closed in time.
994
+ // io_uring_submit_pending(selector);
991
995
  } else {
992
996
  close(descriptor);
993
997
  }
@@ -1101,13 +1105,19 @@ unsigned select_process_completions(struct IO_Event_Selector_URing *selector) {
1101
1105
  }
1102
1106
 
1103
1107
  io_uring_cq_advance(ring, 1);
1104
- // This marks the waiting operation as "complete":
1105
- IO_Event_Selector_URing_Completion_release(selector, completion);
1106
1108
 
1109
+ VALUE fiber = 0;
1107
1110
  if (waiting && waiting->fiber) {
1108
1111
  assert(waiting->result != -ECANCELED);
1109
1112
 
1110
- IO_Event_Selector_loop_resume(&selector->backend, waiting->fiber, 0, NULL);
1113
+ fiber = waiting->fiber;
1114
+ }
1115
+
1116
+ // This marks the waiting operation as "complete":
1117
+ IO_Event_Selector_URing_Completion_release(selector, completion);
1118
+
1119
+ if (fiber) {
1120
+ IO_Event_Selector_loop_resume(&selector->backend, fiber, 0, NULL);
1111
1121
  }
1112
1122
  }
1113
1123
 
@@ -128,6 +128,12 @@ module IO::Event
128
128
  @selector.ready?
129
129
  end
130
130
 
131
+ # Run the given blocking operation and wait for its completion.
132
+ def blocking_operation_wait(operation)
133
+ log("Waiting for blocking operation #{operation.inspect}")
134
+ @selector.blocking_operation_wait(operation)
135
+ end
136
+
131
137
  # Wait for the given process, forwarded to the underlying selector.
132
138
  def process_wait(*arguments)
133
139
  log("Waiting for process with #{arguments.inspect}")
@@ -230,7 +230,7 @@ module IO::Event
230
230
 
231
231
  if result < 0
232
232
  if length > 0 and again?(result)
233
- self.io_wait(fiber, io, IO::READABLE)
233
+ self.io_wait(fiber, io, IO::WRITABLE)
234
234
  else
235
235
  return result
236
236
  end
@@ -287,7 +287,7 @@ module IO::Event
287
287
 
288
288
  if again?(result)
289
289
  if length > 0
290
- self.io_wait(fiber, io, IO::READABLE)
290
+ self.io_wait(fiber, io, IO::WRITABLE)
291
291
  else
292
292
  return result
293
293
  end
@@ -7,6 +7,6 @@
7
7
  class IO
8
8
  # @namespace
9
9
  module Event
10
- VERSION = "1.14.2"
10
+ VERSION = "1.14.3"
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.14.3
22
+
23
+ - Fix several implementation bugs that could cause deadlocks on blocking writes.
24
+
21
25
  ### v1.14.0
22
26
 
23
27
  - [Enhanced `IO::Event::PriorityHeap` with deletion and bulk insertion methods](https://socketry.github.io/io-event/releases/index#enhanced-io::event::priorityheap-with-deletion-and-bulk-insertion-methods)
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v1.14.3
4
+
5
+ - Fix several implementation bugs that could cause deadlocks on blocking writes.
6
+
3
7
  ## v1.14.0
4
8
 
5
9
  ### Enhanced `IO::Event::PriorityHeap` with deletion and bulk insertion methods
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.14.2
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.6.9
119
+ rubygems_version: 4.0.3
120
120
  specification_version: 4
121
121
  summary: An event loop.
122
122
  test_files: []
metadata.gz.sig CHANGED
Binary file