From 387521976d7639d9ec3506a5a422f951e2760d2e Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Mon, 9 Jan 2017 17:36:47 +0100 Subject: [PATCH] Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1). --- winsup/cygwin/net.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index e4805d3e1..2ff2148f0 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -925,6 +925,14 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval, res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid); __leave; } + else if (optname == SO_REUSEADDR && level == SOL_SOCKET) + { + unsigned int *reuseaddr = (unsigned int *) optval; + *reuseaddr = fh->saw_reuseaddr(); + *optlen = sizeof *reuseaddr; + res = 0; + __leave; + } /* Old applications still use the old WinSock1 IPPROTO_IP values. */ if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES) optname = convert_ws1_ip_optname (optname);