summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 10:06:18 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-22 10:06:18 (GMT)
commited80f025f6f87f144ee7b63931890efb4421ee78 (patch)
tree072a9197dbf06651e219e0e12e395d9fda2885e1 /generic
parenta3271d4360790d34a08896e46f0a6a37aa344568 (diff)
downloadtcl-ed80f025f6f87f144ee7b63931890efb4421ee78.zip
tcl-ed80f025f6f87f144ee7b63931890efb4421ee78.tar.gz
tcl-ed80f025f6f87f144ee7b63931890efb4421ee78.tar.bz2
This is patch.002 from ticket [0b9d3ba2ba3e1e3fc33c97d5a9fa7ef85d11a696|0b9d3ba2ba], as first start of tip-456 implementation
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIOCmd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index de65da5..9dc8f07 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1485,12 +1485,12 @@ Tcl_SocketObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const socketOptions[] = {
- "-async", "-myaddr", "-myport", "-server", NULL
+ "-async", "-myaddr", "-myport", "-server", "-reuseport", NULL
};
enum socketOptions {
- SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER
+ SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_SERVER, SKT_REUSEPORT
};
- int optionIndex, a, server = 0, port, myport = 0, async = 0;
+ int optionIndex, a, server = 0, port, myport = 0, async = 0, reuseport = 0;
const char *host, *myaddr = NULL;
Tcl_Obj *script = NULL;
Tcl_Channel chan;
@@ -1557,6 +1557,9 @@ Tcl_SocketObjCmd(
}
script = objv[a];
break;
+ case SKT_REUSEPORT:
+ reuseport = 1;
+ break;
default:
Tcl_Panic("Tcl_SocketObjCmd: bad option index to SocketOptions");
}
@@ -1600,6 +1603,12 @@ Tcl_SocketObjCmd(
Tcl_IncrRefCount(script);
acceptCallbackPtr->script = script;
acceptCallbackPtr->interp = interp;
+
+ /* Hint for Tcl_OpenTcpServer to set socket option REUSEPORT */
+ if(reuseport) {
+ port |= (1 << 16);
+ }
+
chan = Tcl_OpenTcpServer(interp, port, host, AcceptCallbackProc,
acceptCallbackPtr);
if (chan == NULL) {