mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 5f77f9bea6
: [Backport #21195]
Fix handling of `error`/`errno` in `io_internal_wait`. (#12961) [Bug #21195]
This commit is contained in:
parent
aac5c546cd
commit
51dee044c1
3 changed files with 35 additions and 3 deletions
6
io.c
6
io.c
|
@ -1156,8 +1156,14 @@ io_internal_wait(VALUE thread, rb_io_t *fptr, int error, int events, struct time
|
|||
return -1;
|
||||
}
|
||||
|
||||
// If there was an error BEFORE we started waiting, return it:
|
||||
if (error) {
|
||||
errno = error;
|
||||
return -1;
|
||||
} else {
|
||||
// Otherwise, whatever error was generated by `nogvl_wait_for` is the one we want:
|
||||
return ready;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -4297,4 +4297,30 @@ __END__
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_blocking_timeout
|
||||
assert_separately([], <<~'RUBY')
|
||||
IO.pipe do |r, w|
|
||||
trap(:INT) do
|
||||
w.puts "INT"
|
||||
end
|
||||
|
||||
main = Thread.current
|
||||
thread = Thread.new do
|
||||
# Wait until the main thread has entered `$stdin.gets`:
|
||||
Thread.pass until main.status == 'sleep'
|
||||
|
||||
# Cause an interrupt while handling `$stdin.gets`:
|
||||
Process.kill :INT, $$
|
||||
end
|
||||
|
||||
r.timeout = 1
|
||||
assert_equal("INT", r.gets.chomp)
|
||||
rescue IO::TimeoutError
|
||||
# Ignore - some platforms don't support interrupting `gets`.
|
||||
ensure
|
||||
thread&.join
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 7
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 138
|
||||
#define RUBY_PATCHLEVEL 139
|
||||
|
||||
#include "ruby/version.h"
|
||||
#include "ruby/internal/abi.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue