summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-20 12:35:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-20 12:35:33 (GMT)
commit05119eaad1bb3205fa0a31abacf99d6ae33f20e1 (patch)
treeb98cb01fe41df5966bd8d72899a6daae1e312e26 /generic
parent3441489729c72b8349c301779704d5448cd27958 (diff)
downloadtcl-05119eaad1bb3205fa0a31abacf99d6ae33f20e1.zip
tcl-05119eaad1bb3205fa0a31abacf99d6ae33f20e1.tar.gz
tcl-05119eaad1bb3205fa0a31abacf99d6ae33f20e1.tar.bz2
Make options -reuseaddr/-reuseport forbidden without -server, no matter the value being true or false. Some additional test-cases.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIOCmd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index e64e31d..682eaf4 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1492,8 +1492,8 @@ Tcl_SocketObjCmd(
SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_REUSEADDR, SKT_REUSEPORT,
SKT_SERVER
};
- int optionIndex, a, server = 0, myport = 0, async = 0, reusep = 0,
- reusea = 0;
+ int optionIndex, a, server = 0, myport = 0, async = 0, reusep = -1,
+ reusea = -1;
unsigned int flags = 0;
const char *host, *port, *myaddr = NULL;
Tcl_Obj *script = NULL;
@@ -1553,8 +1553,6 @@ Tcl_SocketObjCmd(
return TCL_ERROR;
}
server = 1;
- /* [TIP#456] Set for backward-compatibility. */
- reusea = 1;
a++;
if (a >= objc) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -1613,15 +1611,15 @@ Tcl_SocketObjCmd(
return TCL_ERROR;
}
- if (!server && (reusea != 0 || reusep != 0)) {
+ if (!server && (reusea != -1 || reusep != -1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"options -reuseaddr and -reuseport are only valid for servers",
-1));
return TCL_ERROR;
}
- flags |= reusea ? TCL_TCPSERVER_REUSEADDR : 0;
- flags |= reusep ? TCL_TCPSERVER_REUSEPORT : 0;
+ if (reusea!=0) flags |= TCL_TCPSERVER_REUSEADDR;
+ if (reusep==1) flags |= TCL_TCPSERVER_REUSEPORT;
// All the arguments should have been parsed by now, 'a' points to the last
// one, the port number.