ruby-changes:56074
From: Yusuke <ko1@a...>
Date: Tue, 11 Jun 2019 06:56:49 +0900 (JST)
Subject: [ruby-changes:56074] Yusuke Endoh: de4b2930f7 (trunk): ext/socket/ipsocket.c: Use SO_REUSEADDR for local_host/port
https://git.ruby-lang.org/ruby.git/commit/?id=de4b2930f7 From de4b2930f71a88358c8f1968e410f420c54853bd Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Tue, 11 Jun 2019 06:53:33 +0900 Subject: 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 diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c index dadf10f..4a444b3 100644 --- a/ext/socket/ipsocket.c +++ b/ext/socket/ipsocket.c @@ -99,6 +99,11 @@ init_inetsock_internal(struct inetsock_arg *arg) https://github.com/ruby/ruby/blob/trunk/ext/socket/ipsocket.c#L99 } 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)"; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/