Patchwork [v4,2/5] gdbstub: call socket_set_fast_reuse instead of setting SO_REUSEADDR

login
register
mail settings
Submitter Sebastian Ottlik
Date Sept. 16, 2013, 8:25 a.m.
Message ID <1379319907-14950-3-git-send-email-ottlik@fzi.de>
Download mbox | patch
Permalink /patch/275144/
State New
Headers show

Comments

Sebastian Ottlik - Sept. 16, 2013, 8:25 a.m.
SO_REUSEADDR should be avoided on Windows but is desired on other operating
systems. So instead of setting it we call socket_set_fast_reuse that will result
in the appropriate behaviour on all operating systems.

Signed-off-by: Sebastian Ottlik <ottlik@fzi.de>
---
 gdbstub.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Eric Blake - Sept. 16, 2013, 2:03 p.m.
On 09/16/2013 02:25 AM, Sebastian Ottlik wrote:
> SO_REUSEADDR should be avoided on Windows but is desired on other operating
> systems. So instead of setting it we call socket_set_fast_reuse that will result
> in the appropriate behaviour on all operating systems.
> 
> Signed-off-by: Sebastian Ottlik <ottlik@fzi.de>
> ---
>  gdbstub.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/gdbstub.c b/gdbstub.c
> index 2b7f22b..f43291a 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1553,7 +1553,7 @@ static void gdb_accept(void)
>  static int gdbserver_open(int port)
>  {
>      struct sockaddr_in sockaddr;
> -    int fd, val, ret;
> +    int fd, ret;
>  
>      fd = socket(PF_INET, SOCK_STREAM, 0);
>      if (fd < 0) {
> @@ -1564,9 +1564,7 @@ static int gdbserver_open(int port)
>      fcntl(fd, F_SETFD, FD_CLOEXEC);
>  #endif
>  
> -    /* allow fast reuse */
> -    val = 1;
> -    qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
> +    socket_set_fast_reuse(fd, false);

Changed from silent to noisy.  Intentional?
Sebastian Ottlik - Sept. 16, 2013, 2:07 p.m.
On 16.09.2013 16:03, Eric Blake wrote:
> On 09/16/2013 02:25 AM, Sebastian Ottlik wrote:
>> SO_REUSEADDR should be avoided on Windows but is desired on other operating
>> systems. So instead of setting it we call socket_set_fast_reuse that will result
>> in the appropriate behaviour on all operating systems.
>>
>> Signed-off-by: Sebastian Ottlik <ottlik@fzi.de>
>> ---
>>   gdbstub.c |    6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/gdbstub.c b/gdbstub.c
>> index 2b7f22b..f43291a 100644
>> --- a/gdbstub.c
>> +++ b/gdbstub.c
>> @@ -1553,7 +1553,7 @@ static void gdb_accept(void)
>>   static int gdbserver_open(int port)
>>   {
>>       struct sockaddr_in sockaddr;
>> -    int fd, val, ret;
>> +    int fd, ret;
>>   
>>       fd = socket(PF_INET, SOCK_STREAM, 0);
>>       if (fd < 0) {
>> @@ -1564,9 +1564,7 @@ static int gdbserver_open(int port)
>>       fcntl(fd, F_SETFD, FD_CLOEXEC);
>>   #endif
>>   
>> -    /* allow fast reuse */
>> -    val = 1;
>> -    qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
>> +    socket_set_fast_reuse(fd, false);
> Changed from silent to noisy.  Intentional?
>

Not intentional, I will resubmit this patch set asap.

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 2b7f22b..f43291a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1553,7 +1553,7 @@  static void gdb_accept(void)
 static int gdbserver_open(int port)
 {
     struct sockaddr_in sockaddr;
-    int fd, val, ret;
+    int fd, ret;
 
     fd = socket(PF_INET, SOCK_STREAM, 0);
     if (fd < 0) {
@@ -1564,9 +1564,7 @@  static int gdbserver_open(int port)
     fcntl(fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-    /* allow fast reuse */
-    val = 1;
-    qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+    socket_set_fast_reuse(fd, false);
 
     sockaddr.sin_family = AF_INET;
     sockaddr.sin_port = htons(port);