mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if
SOCK_CLOEXEC is not a reason for EINVAL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c3749b6a6d
commit
385a7d4594
2 changed files with 23 additions and 22 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Nov 5 17:55:52 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if
|
||||||
|
SOCK_CLOEXEC is not a reason for EINVAL.
|
||||||
|
|
||||||
Sat Nov 5 16:27:52 2011 Kazuki Tsujimoto <kazuki@callcc.net>
|
Sat Nov 5 16:27:52 2011 Kazuki Tsujimoto <kazuki@callcc.net>
|
||||||
|
|
||||||
* ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,
|
* ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,
|
||||||
|
|
|
@ -240,34 +240,30 @@ rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rsock_socket0(int domain, int type0, int proto)
|
rsock_socket0(int domain, int type, int proto)
|
||||||
{
|
{
|
||||||
int ret, type;
|
int ret;
|
||||||
|
|
||||||
#ifdef SOCK_CLOEXEC
|
#ifdef SOCK_CLOEXEC
|
||||||
static int try_sock_cloexec = 1;
|
static int try_sock_cloexec = 1;
|
||||||
if (try_sock_cloexec)
|
if (try_sock_cloexec) {
|
||||||
type = type0|SOCK_CLOEXEC;
|
ret = socket(domain, type|SOCK_CLOEXEC, proto);
|
||||||
else
|
if (ret == -1 && errno == EINVAL) {
|
||||||
type = type0;
|
/* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */
|
||||||
retry_without_sock_cloexec:;
|
ret = socket(domain, type, proto);
|
||||||
#else
|
if (ret != -1) {
|
||||||
type = type0;
|
try_sock_cloexec = 0;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
ret = socket(domain, type, proto);
|
|
||||||
|
|
||||||
if (ret == -1) {
|
|
||||||
#ifdef SOCK_CLOEXEC
|
|
||||||
/* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */
|
|
||||||
if (try_sock_cloexec && errno == EINVAL) {
|
|
||||||
try_sock_cloexec = 0;
|
|
||||||
type = type0;
|
|
||||||
goto retry_without_sock_cloexec;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ret = socket(domain, type, proto);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ret = socket(domain, type, proto);
|
||||||
|
#endif
|
||||||
|
if (ret == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
rb_fd_fix_cloexec(ret);
|
rb_fd_fix_cloexec(ret);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue