Skip to content

Commit

Permalink
Allow to disable the FiberScheduler#io_write hook
Browse files Browse the repository at this point in the history
apparently, the presence of the `io_write` hook can cause issues on Ruby < 3.3

https://bugs.ruby-lang.org/issues/19640
socketry/async#233
  • Loading branch information
rsamoilov committed Feb 19, 2024
1 parent 2926fff commit 9f17f2a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/rage/fiber_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ def io_read(io, buffer, length, offset = 0)
end
end

def io_write(io, buffer, length, offset = 0)
bytes_to_write = length
bytes_to_write = buffer.size if length == 0
unless ENV["RAGE_DISABLE_IO_WRITE"]
def io_write(io, buffer, length, offset = 0)
bytes_to_write = length
bytes_to_write = buffer.size if length == 0

::Iodine::Scheduler.write(io.fileno, buffer.get_string, bytes_to_write, offset)
::Iodine::Scheduler.write(io.fileno, buffer.get_string, bytes_to_write, offset)

bytes_to_write - offset
bytes_to_write - offset
end
end

def kernel_sleep(duration = nil)
Expand Down

0 comments on commit 9f17f2a

Please sign in to comment.