diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-06-11 06:53:33 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-06-11 06:53:33 +0900 |
commit | de4b2930f71a88358c8f1968e410f420c54853bd (patch) | |
tree | 9a4b8419a177a261d0a4c990570cc069365ed5ed /ext/socket | |
parent | 6096baea5db6505206f0e636c4e5272b4eb72da4 (diff) |
ext/socket/ipsocket.c: Use SO_REUSEADDR for local_host/port
Sometimes ruby/spec fails when trying to specify local_host and
local_port for TCPSocket.open.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris11s-sunc/ruby-master/log/20190610T192504Z.fail.html.gz
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/ipsocket.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index dadf10f6a5..4a444b3680 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -99,6 +99,11 @@ init_inetsock_internal(struct inetsock_arg *arg) } else { if (lres) { +#if !defined(_WIN32) && !defined(__CYGWIN__) + status = 1; + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, + (char*)&status, (socklen_t)sizeof(status)); +#endif status = bind(fd, lres->ai_addr, lres->ai_addrlen); local = status; syscall = "bind(2)"; |