io-event 1.10.0 → 1.10.2

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: ec418d3289f8648ac13d7808bbe8d56b50a3b4cf518f61da116c56c3c345daa9
4
- data.tar.gz: 8de6423981f2bfb2da54e0cd99e493787253a2c2c83bc644f72fffdcf52a295c
3
+ metadata.gz: 643309e8464f787b038f0d7a83470e1b4750989455329081a59924c8ba4c1f43
4
+ data.tar.gz: 449bd6b5a87a17f826eaaa6f8d62102641a1722d8a49d4cf3f3036bbff6252c1
5
5
  SHA512:
6
- metadata.gz: 9fd70cf075b1703fd8e4659fa2adaf7381f7d5523e47e8700eeda233a01679c671ebb8197fd06f525da17b7a30332e996dd087874503f8ff7a594b8f88268554
7
- data.tar.gz: c42e23c74e1069fb199fd1044b7fc487b8f1587294703a19362242bbbfa23c21fbba36a6a114fafb978ddc4cfcd2a21d2a6c7b7c3d3dc1c4a08094ca9b51bd2a
6
+ metadata.gz: 34cd0ddcba1cc3a67cbf586cacb12a87b07c7f12a2b32d05f6d6a2d288ec50c6f7a53df5be6b8458f479e887831ec74ff395253021a0a5b6af0b7166bbb41f58
7
+ data.tar.gz: 1e13343fea3e66597dc67e4f671df961fa967d8bb09d3c9b5b706e866b250431ec9bac01c49df994c3e7859497ed14a4b8cfe31aa03856dc66bc43aff18f7a5e
checksums.yaml.gz.sig CHANGED
Binary file
data/ext/extconf.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  # Released under the MIT License.
5
5
  # Copyright, 2021-2025, by Samuel Williams.
6
6
  # Copyright, 2023, by Math Ieu.
7
+ # Copyright, 2025, by Stanislav (Stas) Katkov.
7
8
 
8
9
  return if RUBY_DESCRIPTION =~ /jruby/
9
10
 
@@ -14,12 +15,12 @@ extension_name = "IO_Event"
14
15
 
15
16
  # dir_config(extension_name)
16
17
 
17
- $CFLAGS << " -Wall -Wno-unknown-pragmas -std=c99"
18
+ append_cflags(["-Wall", "-Wno-unknown-pragmas", "-std=c99"])
18
19
 
19
20
  if ENV.key?("RUBY_DEBUG")
20
21
  $stderr.puts "Enabling debug mode..."
21
-
22
- $CFLAGS << " -DRUBY_DEBUG -O0"
22
+
23
+ append_cflags(["-DRUBY_DEBUG", "-O0"])
23
24
  end
24
25
 
25
26
  $srcs = ["io/event/event.c", "io/event/time.c", "io/event/fiber.c", "io/event/selector/selector.c"]
@@ -32,7 +33,7 @@ have_func("&rb_fiber_transfer")
32
33
  if have_library("uring") and have_header("liburing.h")
33
34
  # We might want to consider using this in the future:
34
35
  # have_func("io_uring_submit_and_wait_timeout", "liburing.h")
35
-
36
+
36
37
  $srcs << "io/event/selector/uring.c"
37
38
  end
38
39
 
@@ -59,9 +60,9 @@ have_header("ruby/io/buffer.h")
59
60
 
60
61
  if ENV.key?("RUBY_SANITIZE")
61
62
  $stderr.puts "Enabling sanitizers..."
62
-
63
+
63
64
  # Add address and undefined behaviour sanitizers:
64
- $CFLAGS << " -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer"
65
+ append_cflags(["-fsanitize=address", "-fsanitize=undefined", "-fno-omit-frame-pointer"])
65
66
  $LDFLAGS << " -fsanitize=address -fsanitize=undefined"
66
67
  end
67
68
 
@@ -18,7 +18,7 @@
18
18
  enum {
19
19
  DEBUG = 0,
20
20
  DEBUG_COMPLETION = 0,
21
- DEBUG_IO_READ = 1,
21
+ DEBUG_CQE = 0,
22
22
  };
23
23
 
24
24
  enum {URING_ENTRIES = 64};
@@ -552,7 +552,10 @@ VALUE io_wait_transfer(VALUE _arguments) {
552
552
 
553
553
  if (DEBUG) fprintf(stderr, "io_wait_transfer:waiting=%p, result=%d\n", (void*)arguments->waiting, arguments->waiting->result);
554
554
 
555
- if (arguments->waiting->result) {
555
+ int32_t result = arguments->waiting->result;
556
+ if (result < 0) {
557
+ rb_syserr_fail(-result, "io_wait_transfer:io_uring_poll_add");
558
+ } else if (result > 0) {
556
559
  // We explicitly filter the resulting events based on the requested events.
557
560
  // In some cases, poll will report events we didn't ask for.
558
561
  return RB_INT2NUM(events_from_poll_flags(arguments->waiting->result & arguments->flags));
@@ -1059,7 +1062,7 @@ unsigned select_process_completions(struct IO_Event_Selector_URing *selector) {
1059
1062
  }
1060
1063
 
1061
1064
  io_uring_for_each_cqe(ring, head, cqe) {
1062
- if (DEBUG) fprintf(stderr, "select_process_completions: cqe res=%d user_data=%p\n", cqe->res, (void*)cqe->user_data);
1065
+ if (DEBUG_CQE) fprintf(stderr, "select_process_completions: cqe res=%d user_data=%p\n", cqe->res, (void*)cqe->user_data);
1063
1066
 
1064
1067
  ++completed;
1065
1068
 
@@ -421,19 +421,25 @@ module IO::Event
421
421
  writable = Array.new
422
422
  priority = Array.new
423
423
 
424
- @waiting.each do |io, waiter|
425
- waiter.each do |fiber, events|
426
- if (events & IO::READABLE) > 0
427
- readable << io
428
- end
429
-
430
- if (events & IO::WRITABLE) > 0
431
- writable << io
432
- end
433
-
434
- if (events & IO::PRIORITY) > 0
435
- priority << io
424
+ @waiting.delete_if do |io, waiter|
425
+ if io.closed?
426
+ true
427
+ else
428
+ waiter.each do |fiber, events|
429
+ if (events & IO::READABLE) > 0
430
+ readable << io
431
+ end
432
+
433
+ if (events & IO::WRITABLE) > 0
434
+ writable << io
435
+ end
436
+
437
+ if (events & IO::PRIORITY) > 0
438
+ priority << io
439
+ end
436
440
  end
441
+
442
+ false
437
443
  end
438
444
  end
439
445
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "priority_heap"
7
7
 
@@ -91,7 +91,6 @@ class IO
91
91
  schedule(self.now + offset.to_f, block)
92
92
  end
93
93
 
94
-
95
94
  # Compute the time interval until the next timer fires.
96
95
  #
97
96
  # @parameter now [Float] The current time.
@@ -7,6 +7,6 @@
7
7
  class IO
8
8
  # @namespace
9
9
  module Event
10
- VERSION = "1.10.0"
10
+ VERSION = "1.10.2"
11
11
  end
12
12
  end
data/license.md CHANGED
@@ -11,6 +11,7 @@ Copyright, 2024, by Pavel Rosický.
11
11
  Copyright, 2024, by Anthony Ross.
12
12
  Copyright, 2024, by Shizuo Fujita.
13
13
  Copyright, 2024, by Jean Boussier.
14
+ Copyright, 2025, by Stanislav (Stas) Katkov.
14
15
 
15
16
  Permission is hereby granted, free of charge, to any person obtaining a copy
16
17
  of this software and associated documentation files (the "Software"), to deal
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.10.2
22
+
23
+ - Improved consistency of handling closed IO when invoking `#select`.
24
+
21
25
  ### v1.10.0
22
26
 
23
27
  - `IO::Event::Profiler` is moved to dedicated gem: [fiber-profiler](https://github.com/socketry/fiber-profiler).
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v1.10.2
4
+
5
+ - Improved consistency of handling closed IO when invoking `#select`.
6
+
3
7
  ## v1.10.0
4
8
 
5
9
  - `IO::Event::Profiler` is moved to dedicated gem: [fiber-profiler](https://github.com/socketry/fiber-profiler).
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.10.0
4
+ version: 1.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -15,6 +15,7 @@ authors:
15
15
  - Delton Ding
16
16
  - Pavel Rosický
17
17
  - Shizuo Fujita
18
+ - Stanislav (Stas) Katkov
18
19
  bindir: bin
19
20
  cert_chain:
20
21
  - |
@@ -46,7 +47,7 @@ cert_chain:
46
47
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
47
48
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
48
49
  -----END CERTIFICATE-----
49
- date: 2025-03-12 00:00:00.000000000 Z
50
+ date: 1980-01-02 00:00:00.000000000 Z
50
51
  dependencies: []
51
52
  executables: []
52
53
  extensions:
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.6.2
112
+ rubygems_version: 3.7.0.dev
112
113
  specification_version: 4
113
114
  summary: An event loop.
114
115
  test_files: []
metadata.gz.sig CHANGED
Binary file