summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-31 14:49:57 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-31 14:49:57 +0000
commit8ce4a284e438bf1b5a652a7d27db84f24fb742ff (patch)
treec81579fb7a39716098e1c361a2f590ffc8594a7a /ext/socket/socket.c
parent1a8fbff3dbbddf3c0d4e58d0f7da9ad1eb0e2025 (diff)
* ext/socket/socket.c (rsock_socketpair): extracted from
rsock_sock_s_socketpair. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 767446d..31346a0 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -76,6 +76,21 @@ pair_yield(VALUE pair)
#endif
#if defined HAVE_SOCKETPAIR
+
+static int
+rsock_socketpair(int domain, int type, int protocol, int sv[2])
+{
+ int ret;
+
+ ret = socketpair(domain, type, protocol, sv);
+ if (ret < 0 && (errno == EMFILE || errno == ENFILE)) {
+ rb_gc();
+ ret = socketpair(domain, type, protocol, sv);
+ }
+
+ return ret;
+}
+
/*
* call-seq:
* Socket.pair(domain, type, protocol) => [socket1, socket2]
@@ -111,11 +126,7 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
setup_domain_and_type(domain, &d, type, &t);
p = NUM2INT(protocol);
- ret = socketpair(d, t, p, sp);
- if (ret < 0 && (errno == EMFILE || errno == ENFILE)) {
- rb_gc();
- ret = socketpair(d, t, p, sp);
- }
+ ret = rsock_socketpair(d, t, p, sp);
if (ret < 0) {
rb_sys_fail("socketpair(2)");
}