aboutsummaryrefslogtreecommitdiffstats
path: root/ext/socket
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/init.c3
-rw-r--r--ext/socket/socket.c3
2 files changed, 2 insertions, 4 deletions
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);
}