summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorSamuel Williams <[email protected]>2024-10-04 19:36:06 +1300
committerGitHub <[email protected]>2024-10-04 19:36:06 +1300
commitc878843b2cb8fd54ebfaabd10b6334cf4d400208 (patch)
treeef144e18d26c687be262821f65a8f98b06b4ed2b /io.c
parent96d69d2df269bbf68bb0e378b2cd4af46bfd37a4 (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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/io.c b/io.c
index 3c99043916..1e5c851f87 100644
--- a/io.c
+++ b/io.c
@@ -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