MN: skip waiting on `read_nonblock'

if the IO for `IO#read_nonblock` is not ready, it needs
to return (or raise) immediately.
This commit is contained in:
Koichi Sasada 2023-12-23 07:45:08 +09:00
parent 2fe9e08578
commit beec3d07c9

5
io.c
View File

@ -3410,8 +3410,13 @@ io_read_memory_call(VALUE arg)
} }
} }
if (iis->nonblock) {
return rb_thread_io_blocking_call(internal_read_func, iis, iis->fptr->fd, 0);
}
else {
return rb_thread_io_blocking_call(internal_read_func, iis, iis->fptr->fd, RB_WAITFD_IN); return rb_thread_io_blocking_call(internal_read_func, iis, iis->fptr->fd, RB_WAITFD_IN);
} }
}
static long static long
io_read_memory_locktmp(VALUE str, struct io_internal_read_struct *iis) io_read_memory_locktmp(VALUE str, struct io_internal_read_struct *iis)