diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-05 09:06:05 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-05 09:06:05 +0000 |
commit | a3521e0261d229f8402cc84a018d2bc1a64fcc5a (patch) | |
tree | b7c2f11244bafa3a40adf38e8b479506d8444275 /ext/socket/socket.c | |
parent | 385a7d4594da0168c7e9cf031f1e4a9c6ff46e8c (diff) |
* ext/socket/socket.c (rsock_socketpair0): refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r-- | ext/socket/socket.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 402675c5b0..872dd65b85 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -86,17 +86,15 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2]) static int try_sock_cloexec = 1; if (try_sock_cloexec) { ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv); - if (ret == -1) { + if (ret == -1 && errno == EINVAL) { /* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */ - if (try_sock_cloexec && errno == EINVAL) { - ret = socketpair(domain, type, protocol, sv); - if (ret != -1) { - /* The reason of EINVAL may be other than SOCK_CLOEXEC. - * So disable SOCK_CLOEXEC only if socketpair() succeeds without SOCK_CLOEXEC. - * Ex. Socket.pair(:UNIX, 0xff) fails with EINVAL. - */ - try_sock_cloexec = 0; - } + ret = socketpair(domain, type, protocol, sv); + if (ret != -1) { + /* The reason of EINVAL may be other than SOCK_CLOEXEC. + * So disable SOCK_CLOEXEC only if socketpair() succeeds without SOCK_CLOEXEC. + * Ex. Socket.pair(:UNIX, 0xff) fails with EINVAL. + */ + try_sock_cloexec = 0; } } } |