Project

General

Profile

Actions

Bug #20231

closed

Don't wait in io_binwrite_string if not necessary.

Added by ioquatix (Samuel Williams) 3 months ago. Updated about 1 month ago.

Status:
Closed
Target version:
-
ruby -v:
[ruby-core:116534]

Description

PR: https://github.com/ruby/ruby/pull/9792

Writing to a buffered IO can result in the entire internal buffer being flushed, which causes io_binwrite_string_internal to return 0. In that case, we were setting errno = EAGAIN. This causes rb_io_maybe_wait_writable to be invoked, however we should immediately retry io_binwrite_string_internal instead.

The reason why calling rb_io_maybe_wait_writable is a bad idea in general, is that not all IO can go via this mechanism in every situation - in other words, kqueue does not support kevent("/dev/null", writable) and returns errno=22 EINVAL. The same applies to some kinds of pipes, TTYs, etc.

Indirectly responsible for https://github.com/socketry/async/issues/301.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0