diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | dir.c | 3 | ||||
-rw-r--r-- | ext/socket/init.c | 3 | ||||
-rw-r--r-- | ext/socket/socket.c | 3 | ||||
-rw-r--r-- | internal.h | 1 | ||||
-rw-r--r-- | io.c | 2 |
6 files changed, 14 insertions, 7 deletions
@@ -1,3 +1,12 @@ +Tue Nov 24 07:50:15 2015 Eric Wong <e@80x24.org> + + * dir.c (dir_initialize): use rb_gc_for_fd for ENOMEM + * ext/socket/init.c (rsock_socket): ditto + * ext/socket/socket.c (rsock_socketpair): ditto + * internal.h (rb_gc_for_fd): prototype + * io.c (rb_gc_for_fd): remove static + [ruby-core:71623] [Feature #11727] + Tue Nov 24 06:46:27 2015 Eric Wong <e@80x24.org> * io.c (rb_gc_for_fd): new helper function @@ -519,8 +519,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir) path = RSTRING_PTR(dirname); dp->dir = opendir(path); if (dp->dir == NULL) { - if (errno == EMFILE || errno == ENFILE) { - rb_gc(); + if (rb_gc_for_fd(errno)) { dp->dir = opendir(path); } #ifdef HAVE_GETATTRLIST diff --git a/ext/socket/init.c b/ext/socket/init.c index df32565b80..3fb436614e 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -358,8 +358,7 @@ rsock_socket(int domain, int type, int proto) fd = rsock_socket0(domain, type, proto); if (fd < 0) { - if (errno == EMFILE || errno == ENFILE) { - rb_gc(); + if (rb_gc_for_fd(errno)) { fd = rsock_socket0(domain, type, proto); } } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 2f282b8e34..0514bb6502 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -241,8 +241,7 @@ rsock_socketpair(int domain, int type, int protocol, int sv[2]) int ret; ret = rsock_socketpair0(domain, type, protocol, sv); - if (ret < 0 && (errno == EMFILE || errno == ENFILE)) { - rb_gc(); + if (ret < 0 && rb_gc_for_fd(errno)) { ret = rsock_socketpair0(domain, type, protocol, sv); } diff --git a/internal.h b/internal.h index 138f718cd1..456fc1fda6 100644 --- a/internal.h +++ b/internal.h @@ -851,6 +851,7 @@ void rb_stdio_set_default_encoding(void); void rb_write_error_str(VALUE mesg); VALUE rb_io_flush_raw(VALUE, int); size_t rb_io_memsize(const rb_io_t *); +int rb_gc_for_fd(int err); /* load.c */ VALUE rb_get_load_path(void); @@ -884,7 +884,7 @@ rb_io_read_check(rb_io_t *fptr) return; } -static int +int rb_gc_for_fd(int err) { if (err == EMFILE || err == ENFILE || err == ENOMEM) { |