Attachment "patch" to
ticket [0b9d3ba2ba]
added by
cklein
2016-11-17 17:14:33.
Index: unix/tclUnixSock.c
==================================================================
--- unix/tclUnixSock.c
+++ unix/tclUnixSock.c
@@ -1428,10 +1428,13 @@
/* Callback for accepting connections from new
* clients. */
ClientData acceptProcData) /* Data for the callback. */
{
int status = 0, sock = -1, reuseaddr = 1, chosenport;
+#ifdef SO_REUSEPORT
+ int reuseport = 1;
+#endif
struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */
TcpState *statePtr = NULL;
char channelName[SOCK_CHAN_LENGTH];
const char *errorMsg = NULL;
TcpFdList *fds = NULL, *newfds;
@@ -1509,10 +1512,19 @@
* specified port.
*/
(void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(char *) &reuseaddr, sizeof(reuseaddr));
+
+#ifdef SO_REUSEPORT
+ /*
+ * Set up to allows multiple sockets on the same host to bind to the same port.
+ */
+
+ (void) setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
+ (char *) &reuseport, sizeof(reuseport));
+#endif
/*
* Make sure we use the same port number when opening two server
* sockets for IPv4 and IPv6 on a random port.
*