summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 11:21:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 11:21:00 (GMT)
commit490b4bf1f8778fddb9814d30cdf2c4bd89d9581d (patch)
treecd198dc363de934042ae24b29a7b911ad4e7c580 /unix
parented80f025f6f87f144ee7b63931890efb4421ee78 (diff)
downloadtcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.zip
tcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.tar.gz
tcl-490b4bf1f8778fddb9814d30cdf2c4bd89d9581d.tar.bz2
Added stub entry for tip #456. Documentation and tests still missing. Doesn't conform to TIP yet.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index d8a33f9..6286b2f 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -115,7 +115,7 @@ struct TcpState {
#ifdef SO_REUSEPORT
/* Bitmask to check if the setting of SO_REUSEPORT was requested by the caller. */
-#define USE_SOCK_REUSEPORT (1 << 16)
+#define USE_SOCK_REUSEPORT 1
#endif
/*
@@ -1410,7 +1410,7 @@ TclpMakeTcpClientChannelMode(
/*
*----------------------------------------------------------------------
*
- * Tcl_OpenTcpServer --
+ * Tcl_OpenTcpServerEx --
*
* Opens a TCP server socket and creates a channel around it.
*
@@ -1425,10 +1425,11 @@ TclpMakeTcpClientChannelMode(
*/
Tcl_Channel
-Tcl_OpenTcpServer(
+Tcl_OpenTcpServerEx(
Tcl_Interp *interp, /* For error reporting - may be NULL. */
int port, /* Port number to open. */
const char *myHost, /* Name of local host. */
+ int flags, /* Flags. */
Tcl_TcpAcceptProc *acceptProc,
/* Callback for accepting connections from new
* clients. */
@@ -1440,10 +1441,6 @@ Tcl_OpenTcpServer(
char channelName[SOCK_CHAN_LENGTH];
const char *errorMsg = NULL;
TcpFdList *fds = NULL, *newfds;
-#ifdef SO_REUSEPORT
- int reuseport = port & USE_SOCK_REUSEPORT;
- CLEAR_BITS(port, USE_SOCK_REUSEPORT);
-#endif
/*
* Try to record and return the most meaningful error message, i.e. the
@@ -1526,7 +1523,8 @@ Tcl_OpenTcpServer(
* Set up to allows multiple sockets on the same host to bind to the same port.
* The flag can be switched on by setting the lowest bit above the valid maximum port (0xffff).
*/
- if(reuseport) {
+ if (flags & USE_SOCK_REUSEPORT) {
+ int reuseport = 1;
(void) setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
(char *) &reuseport, sizeof(reuseport));
}