Project

General

Profile

Actions

Bug #21789

open

IO#flush doesn't invoke fiber scheduler io_write hook

Bug #21789: IO#flush doesn't invoke fiber scheduler io_write hook

Added by noteflakes (Sharon Rosner) about 7 hours ago. Updated about 7 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:124286]

Description

When calling IO#flush or closing an IO with unflushed writes, the flushing is done by calling rb_io_blocking_region_wait and eventually doing a write system call. When done in a non-blocking fiber with an active fiber scheduler, this will invoke the #blocking_operation_wait fiber scheduler hook, which will run the system call in a worker thread, and therefore the flushing bypasses the async I/O capabilities of the fiber scheduler.

The proposed fix is to test for the presence of a fiber scheduler in io_flush_buffer_async and invoke the #io_write fiber scheduler hook with the unflushed part of the IO's write buffer.

Associated PR here: https://github.com/ruby/ruby/pull/15609

Actions

Also available in: PDF Atom