ruby-changes:73949
From: Samuel <ko1@a...>
Date: Tue, 11 Oct 2022 06:18:46 +0900 (JST)
Subject: [ruby-changes:73949] 1bafa4a59b (master): Ignore failure to set nonblock mode. (#6524)
https://git.ruby-lang.org/ruby.git/commit/?id=1bafa4a59b From 1bafa4a59b296e6ca80e32755fc84b76c3c575e5 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Tue, 11 Oct 2022 10:18:20 +1300 Subject: Ignore failure to set nonblock mode. (#6524) --- io.c | 4 ++-- test/ruby/test_io.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/io.c b/io.c index 6cde02aaae..99513573d7 100644 --- a/io.c +++ b/io.c @@ -3571,7 +3571,7 @@ io_read_nonblock(rb_execution_context_t *ec, VALUE io, VALUE length, VALUE str, https://github.com/ruby/ruby/blob/trunk/io.c#L3571 n = read_buffered_data(RSTRING_PTR(str), len, fptr); if (n <= 0) { - rb_io_set_nonblock(fptr); + rb_fd_set_nonblock(fptr->fd); shrinkable |= io_setstrbuf(&str, len); iis.fptr = fptr; iis.nonblock = 1; @@ -3618,7 +3618,7 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex) https://github.com/ruby/ruby/blob/trunk/io.c#L3618 if (io_fflush(fptr) < 0) rb_sys_fail_on_write(fptr); - rb_io_set_nonblock(fptr); + rb_fd_set_nonblock(fptr->fd); n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str)); RB_GC_GUARD(str); diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index f4ebccf9df..0c8beb2f95 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1597,6 +1597,22 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1597 end end + def test_read_nonblock_file + make_tempfile do |path| + File.open(path, 'r') do |file| + file.read_nonblock(4) + end + end + end + + def test_write_nonblock_file + make_tempfile do |path| + File.open(path, 'w') do |file| + file.write_nonblock("Ruby") + end + end + end + def test_write_nonblock_simple_no_exceptions pipe(proc do |w| w.write_nonblock('1', exception: false) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/