From 61e5fe06748de67e1d198a4d28d1e59e5c1dcedc Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 23 Nov 2015 22:50:53 +0000 Subject: use rb_gc_for_fd for more callers * 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] Manpages for opendir(2), socket(2), and socketpair(3posix) describe ENOMEM as a possible error for each of these; handle it consistently with our existing wrappers for open(2)/pipe(2) etc... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/socket/init.c | 3 +-- ext/socket/socket.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'ext/socket') 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); } -- cgit v1.2.3