]> Savannah Git Hosting - gnulib.git/commitdiff
sys_socket: Make SO_REUSEPORT available across platforms.
authorBruno Haible <bruno@clisp.org>
Tue, 24 Apr 2018 18:04:05 +0000 (20:04 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 24 Apr 2018 18:05:12 +0000 (20:05 +0200)
Reported by Tom G. Christensen <tgc@jupiterrise.com>.

* lib/sys_socket.in.h (SO_REUSEPORT): New macro.
* doc/posix-headers/sys_socket.texi: Mention the issue.
* tests/test-poll.c (SO_REUSEPORT): Remove.
* tests/test-select.h: Include <sys/socket.h>.
(SO_REUSEPORT): Remove.
* modules/select-tests (Depends-on): Add 'sys_socket'.

ChangeLog
doc/posix-headers/sys_socket.texi
lib/sys_socket.in.h
modules/select-tests
tests/test-poll.c
tests/test-select.h

index 1c6f3229465f2b651729849bdf8b262802e8f632..9f809cce844c6d51fb8bff8a6c8ff0326bc59e40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-04-24  Bruno Haible  <bruno@clisp.org>
+
+       sys_socket: Make SO_REUSEPORT available across platforms.
+       Reported by Tom G. Christensen <tgc@jupiterrise.com>.
+       * lib/sys_socket.in.h (SO_REUSEPORT): New macro.
+       * doc/posix-headers/sys_socket.texi: Mention the issue.
+       * tests/test-poll.c (SO_REUSEPORT): Remove.
+       * tests/test-select.h: Include <sys/socket.h>.
+       (SO_REUSEPORT): Remove.
+       * modules/select-tests (Depends-on): Add 'sys_socket'.
+
 2018-04-21  Benno Schulenberg  <bensberg@telfort.nl>  (tiny change)
 
        localcharset: short-circuit the search for an alias on a Mac
index 380a0ae8629313e4c54f789f2f9670221e5d0bfe..2fa748e7e40da446591f1831333cccdb40da6ac2 100644 (file)
@@ -32,6 +32,10 @@ AIX 7.1.
 The @code{CMSG_SPACE} and @code{CMSG_LEN} macros are not provided on some
 platforms:
 OpenVMS.
+@item
+This header file does not define the @code{SO_REUSEPORT} macro on some
+platforms:
+Minix 3.1.8, Solaris 10, Cygwin, mingw, MSVC 14.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 7102588a316465477b183c0fcb48fd33536a424a..cbaf5cf11cceede226c112acf2b3fa8576256e9b 100644 (file)
@@ -215,6 +215,15 @@ struct msghdr {
 
 #endif
 
+/* Ensure SO_REUSEPORT is defined.  */
+/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
+   https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
+   and https://lwn.net/Articles/542629/
+ */
+#ifndef SO_REUSEPORT
+# define SO_REUSEPORT SO_REUSEADDR
+#endif
+
 /* Fix some definitions from <winsock2.h>.  */
 
 #if @HAVE_WINSOCK2_H@
index bd7b7313712eba813fc483b3ab62a182e670e9e7..899b50cddfcf8901ac13ec84e64e35888b991520 100644 (file)
@@ -10,6 +10,7 @@ tests/test-select-stdin.c
 
 Depends-on:
 stdbool
+sys_socket
 netinet_in
 arpa_inet
 unistd
index c5e0a92deb1aaf00bc50162e9560e0eedd9d642e..ebace0f1864e3148c541add11edcf7212f93c520 100644 (file)
@@ -52,10 +52,6 @@ SIGNATURE_CHECK (poll, int, (struct pollfd[], nfds_t, int));
 #include <sys/wait.h>
 #endif
 
-#ifndef SO_REUSEPORT
-#define SO_REUSEPORT    SO_REUSEADDR
-#endif
-
 #define TEST_PORT       12345
 
 
index d751e42450d30d55f338cc2256144b0069a4eb65..364687b6c567523ed635d9337dc8726e5d39bea0 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <unistd.h>
 # include <sys/wait.h>
 #endif
 
-#ifndef SO_REUSEPORT
-# define SO_REUSEPORT    SO_REUSEADDR
-#endif
-
 #define TEST_PORT       12345