diff options
author | Samuel Williams <[email protected]> | 2024-10-04 19:36:06 +1300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-10-04 19:36:06 +1300 |
commit | c878843b2cb8fd54ebfaabd10b6334cf4d400208 (patch) | |
tree | ef144e18d26c687be262821f65a8f98b06b4ed2b /io.c | |
parent | 96d69d2df269bbf68bb0e378b2cd4af46bfd37a4 (diff) |
Better handling of timeout in `rb_io_maybe_wait_*`. (#9531)
Notes
Notes:
Merged-By: ioquatix <[email protected]>
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1623,7 +1623,7 @@ rb_io_maybe_wait(int error, VALUE io, VALUE events, VALUE timeout) default: // Non-specific error, no event is ready: - return Qfalse; + return Qnil; } } @@ -1635,9 +1635,11 @@ rb_io_maybe_wait_readable(int error, VALUE io, VALUE timeout) if (RTEST(result)) { return RB_NUM2INT(result); } - else { - return 0; + else if (result == RUBY_Qfalse) { + rb_raise(rb_eIOTimeoutError, "Timed out waiting for IO to become readable!"); } + + return 0; } int @@ -1648,9 +1650,11 @@ rb_io_maybe_wait_writable(int error, VALUE io, VALUE timeout) if (RTEST(result)) { return RB_NUM2INT(result); } - else { - return 0; + else if (result == RUBY_Qfalse) { + rb_raise(rb_eIOTimeoutError, "Timed out waiting for IO to become writable!"); } + + return 0; } static void |