bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] set SO_REUSE* before bind(), not after


From: Bruno Haible
Subject: Re: [PATCH] set SO_REUSE* before bind(), not after
Date: Tue, 02 Oct 2012 01:52:38 +0200
User-agent: KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; )

Hi,

Ed Maste wrote:
> While investigating skipped tests on FreeBSD I found that test-poll
> and test-select were skipped due to bind() returning EADDRINUSE.  It
> turns out that these tests call setsockopt(..., SO_REUSE... after
> calling bind(), not before.

You're obviously right. SO_REUSEADDR can have no effect if it comes
after the bind() call.

The patch you attached was syntactically malformed. I committed this
one in your name; I hope it is what you meant.

The "tiny change" marker means "small enough to not require the exchange
of legal paperwork". Feel free to report more bugs like this, that you find!


2012-10-01  Ed Maste  <address@hidden>  (tiny change)

        select, poll tests: Make setsockopt invocation effective.
        * tests/test-poll.c (open_server_socket): Move setsockopt() call before
        the bind() call.
        * tests/test-select.h (open_server_socket): Likewise.

--- tests/test-poll.c.orig      Tue Oct  2 01:48:04 2012
+++ tests/test-poll.c   Tue Oct  2 01:43:34 2012
@@ -96,6 +96,9 @@
 
   s = socket (AF_INET, SOCK_STREAM, 0);
 
+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
   memset (&ia, 0, sizeof (ia));
   ia.sin_family = AF_INET;
   inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
@@ -106,9 +109,6 @@
       exit (77);
     }
 
-  x = 1;
-  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
-
   if (listen (s, 1) < 0)
     {
       perror ("listen");
--- tests/test-select.h.orig    Tue Oct  2 01:48:05 2012
+++ tests/test-select.h Tue Oct  2 01:44:07 2012
@@ -84,6 +84,9 @@
 
   s = socket (AF_INET, SOCK_STREAM, 0);
 
+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
   memset (&ia, 0, sizeof (ia));
   ia.sin_family = AF_INET;
   inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
@@ -94,9 +97,6 @@
       exit (77);
     }
 
-  x = 1;
-  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
-
   if (listen (s, 1) < 0)
     {
       perror ("listen");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]