[ruby-core:116534] [Ruby master Bug#20231] Don't wait in io_binwrite_string if not necessary.

Issue #20231 has been reported by ioquatix (Samuel Williams). ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Backport: 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by ioquatix (Samuel Williams). Assignee set to ioquatix (Samuel Williams) ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-106552 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by naruse (Yui NARUSE). Merging into 3.3 but failed https://github.com/ruby/ruby/pull/9813 ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-106570 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by ioquatix (Samuel Williams). @naruse That PR seems unrelated, is the link correct? ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-106571 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by naruse (Yui NARUSE). ioquatix (Samuel Williams) wrote in #note-4:
@naruse That PR seems unrelated, is the link correct?
Thanks, the correct PR is https://github.com/ruby/ruby/pull/9831 ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-106596 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by naruse (Yui NARUSE). Backport changed from 3.2: REQUIRED, 3.3: REQUIRED to 3.2: REQUIRED, 3.3: DONE ruby_3_3 2c365e6dfb95e0df24725c6f377b9cdf5e354557 merged revision(s) 2554c5d3b8738a248cedb2fea96dfab9fbe19417. ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-106600 * Author: ioquatix (Samuel Williams) * Status: Closed * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: REQUIRED, 3.3: DONE ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.2: REQUIRED, 3.3: DONE to 3.2: DONE, 3.3: DONE ruby_3_2 bf6e9299ef4f10dbd23f32331c355ac875bfb5e3 merged revision(s) 2554c5d3b8738a248cedb2fea96dfab9fbe19417. ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-107547 * Author: ioquatix (Samuel Williams) * Status: Closed * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: DONE, 3.3: DONE ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/

Issue #20231 has been updated by ioquatix (Samuel Williams). Thanks! ---------------------------------------- Bug #20231: Don't wait in io_binwrite_string if not necessary. https://bugs.ruby-lang.org/issues/20231#change-107554 * Author: ioquatix (Samuel Williams) * Status: Closed * Assignee: ioquatix (Samuel Williams) * Backport: 3.2: DONE, 3.3: DONE ---------------------------------------- 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>. -- https://bugs.ruby-lang.org/
participants (3)
-
ioquatix (Samuel Williams)
-
nagachika (Tomoyuki Chikanaga)
-
naruse (Yui NARUSE)