This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1).


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=387521976d7639d9ec3506a5a422f951e2760d2e

commit 387521976d7639d9ec3506a5a422f951e2760d2e
Author: Erik M. Bray <erik.bray@lri.fr>
Date:   Mon Jan 9 17:36:47 2017 +0100

    Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1).

Diff:
---
 winsup/cygwin/net.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index e4805d3..2ff2148 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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]