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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Erik Bray
From: Erik M. Bray <[hidden email]>

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

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1).

Corinna Vinschen-2
On Jan  9 17:36, Erik Bray wrote:

> ---
>  winsup/cygwin/net.cc | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
> index e4805d3..b02f9e3 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);
                        ^^^
                        space missing

> +      res = 0;
> +      __leave;
> +    }

Indentation of this block is wrong.

Still, good catch.  I fixed the above manually and applied the patch
as obvious (otherwise we're still needing your BSD sign-off).


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1).

Erik Bray
On Mon, Jan 9, 2017 at 5:58 PM, Corinna Vinschen
<[hidden email]> wrote:

> On Jan  9 17:36, Erik Bray wrote:
>> ---
>>  winsup/cygwin/net.cc | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
>> index e4805d3..b02f9e3 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);
>                         ^^^
>                         space missing
>
>> +      res = 0;
>> +      __leave;
>> +    }
>
> Indentation of this block is wrong.
>
> Still, good catch.  I fixed the above manually and applied the patch
> as obvious (otherwise we're still needing your BSD sign-off).

Great, thanks!

I'll get back to you on the BSD sign-off and your comments on my other
patches tomorrow.

Thanks,
Erik
Loading...