Skip to content

Commit 062130c

Browse files
committed
Fix Ruby version support + more tests.
1 parent 45f7d60 commit 062130c

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323

2424
ruby:
2525
- "3.2"
26+
- "3.2.6"
2627
- "3.3"
2728
- "3.4"
2829
- "head"

lib/io/event/selector/select.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def io_read(fiber, io, buffer, length, offset = 0)
199199
result = Fiber.blocking{buffer.read(io, 0, offset)}
200200

201201
if result < 0
202-
if again?(result)
202+
if length > 0 and again?(result)
203203
self.io_wait(fiber, io, IO::READABLE)
204204
else
205205
return result
@@ -229,7 +229,7 @@ def io_write(fiber, io, buffer, length, offset = 0)
229229
result = Fiber.blocking{buffer.write(io, 0, offset)}
230230

231231
if result < 0
232-
if again?(result)
232+
if length > 0 and again?(result)
233233
self.io_wait(fiber, io, IO::READABLE)
234234
else
235235
return result

lib/io/event/support.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@ def self.buffer?
1818
#
1919
# To be removed on 31 Mar 2026.
2020
def self.fiber_scheduler_v2?
21-
# Some interface changes were back-ported incorrectly:
22-
# https://github.com/ruby/ruby/pull/10778
23-
# Specifically "Improvements to IO::Buffer read/write/pread/pwrite."
24-
# Missing correct size calculation.
25-
return false if RUBY_VERSION >= "3.2.5"
26-
27-
IO.const_defined?(:Buffer) and Fiber.respond_to?(:blocking) and IO::Buffer.instance_method(:read).arity == -1
21+
if RUBY_VERSION >= "3.2"
22+
return true if RUBY_VERSION >= "3.2.6"
23+
24+
# Some interface changes were back-ported incorrectly and released in 3.2.5 <https://github.com/ruby/ruby/pull/10778> - Specifically "Improvements to IO::Buffer read/write/pread/pwrite." is missing correct size calculation.
25+
return false if RUBY_VERSION >= "3.2.5"
26+
27+
# Feature detection:
28+
IO.const_defined?(:Buffer) and Fiber.respond_to?(:blocking) and IO::Buffer.instance_method(:read).arity == -1
29+
end
2830
end
2931

3032
# Updated inferfaces for read/write and IO::Buffer were introduced in Ruby 3.3, including pread/pwrite.
3133
#
3234
# To become the default 31 Mar 2026.
3335
def self.fiber_scheduler_v3?
36+
return true if RUBY_VERSION >= "3.3"
37+
3438
if fiber_scheduler_v2?
35-
return true if RUBY_VERSION >= "3.3"
36-
3739
# Feature detection if required:
3840
begin
3941
IO::Buffer.new.slice(0, 0).write(STDOUT)

0 commit comments

Comments
 (0)