diff --git a/ChangeLog b/ChangeLog index 016c974645..36c62566bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jan 18 22:35:15 2014 Tanaka Akira + + * io.c (rb_update_max_fd): Return immediately if the given fd is small + enough. + Sat Jan 18 22:25:53 2014 Tanaka Akira * io.c: Test O_CLOEXEC only once. diff --git a/io.c b/io.c index 5d66bdf4b0..6bab4f9378 100644 --- a/io.c +++ b/io.c @@ -189,6 +189,9 @@ rb_update_max_fd(int fd) struct stat buf; rb_atomic_t afd = (rb_atomic_t)fd; + if (afd <= max_file_descriptor) + return; + if (fstat(fd, &buf) != 0 && errno == EBADF) { rb_bug("rb_update_max_fd: invalid fd (%d) given.", fd); }