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

This commit is contained in:
Erik M. Bray 2017-01-09 17:36:47 +01:00 committed by Corinna Vinschen
parent 5367b96a4b
commit 387521976d
1 changed files with 8 additions and 0 deletions

View File

@ -925,6 +925,14 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval,
res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid); res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid);
__leave; __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. */ /* Old applications still use the old WinSock1 IPPROTO_IP values. */
if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES) if (level == IPPROTO_IP && CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES)
optname = convert_ws1_ip_optname (optname); optname = convert_ws1_ip_optname (optname);