summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-20 11:47:11 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-12-20 11:47:11 (GMT)
commit3441489729c72b8349c301779704d5448cd27958 (patch)
tree48638766f8a51100e359bc918dda003534c086c3
parent1c8b2b280f3d85688ac53e997df447281672a44a (diff)
parentbbe8ae73e2e5c693a20ea16c964949279ff83045 (diff)
downloadtcl-3441489729c72b8349c301779704d5448cd27958.zip
tcl-3441489729c72b8349c301779704d5448cd27958.tar.gz
tcl-3441489729c72b8349c301779704d5448cd27958.tar.bz2
merge fork
-rw-r--r--generic/tclIOCmd.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 0eb8f99..e64e31d 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -1492,8 +1492,9 @@ Tcl_SocketObjCmd(
SKT_ASYNC, SKT_MYADDR, SKT_MYPORT, SKT_REUSEADDR, SKT_REUSEPORT,
SKT_SERVER
};
- int optionIndex, a, server = 0, myport = 0, async = 0, boolTmp;
- unsigned int flags = TCL_TCPSERVER_REUSEADDR;
+ int optionIndex, a, server = 0, myport = 0, async = 0, reusep = 0,
+ reusea = 0;
+ unsigned int flags = 0;
const char *host, *port, *myaddr = NULL;
Tcl_Obj *script = NULL;
Tcl_Channel chan;
@@ -1552,6 +1553,8 @@ Tcl_SocketObjCmd(
return TCL_ERROR;
}
server = 1;
+ /* [TIP#456] Set for backward-compatibility. */
+ reusea = 1;
a++;
if (a >= objc) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -1567,14 +1570,9 @@ Tcl_SocketObjCmd(
"no argument given for -reuseaddr option", -1));
return TCL_ERROR;
}
- if (Tcl_GetBooleanFromObj(interp, objv[a], &boolTmp) != TCL_OK) {
+ if (Tcl_GetBooleanFromObj(interp, objv[a], &reusea) != TCL_OK) {
return TCL_ERROR;
}
- if (boolTmp) {
- flags |= TCL_TCPSERVER_REUSEADDR;
- } else {
- flags &= ~TCL_TCPSERVER_REUSEADDR;
- }
break;
case SKT_REUSEPORT:
a++;
@@ -1583,14 +1581,9 @@ Tcl_SocketObjCmd(
"no argument given for -reuseport option", -1));
return TCL_ERROR;
}
- if (Tcl_GetBooleanFromObj(interp, objv[a], &boolTmp) != TCL_OK) {
+ if (Tcl_GetBooleanFromObj(interp, objv[a], &reusep) != TCL_OK) {
return TCL_ERROR;
}
- if (boolTmp) {
- flags |= TCL_TCPSERVER_REUSEPORT;
- } else {
- flags &= ~TCL_TCPSERVER_REUSEPORT;
- }
break;
default:
Tcl_Panic("Tcl_SocketObjCmd: bad option index to SocketOptions");
@@ -1620,13 +1613,16 @@ Tcl_SocketObjCmd(
return TCL_ERROR;
}
- if (!server && flags != 0) {
+ if (!server && (reusea != 0 || reusep != 0)) {
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;
+
// All the arguments should have been parsed by now, 'a' points to the last
// one, the port number.
if (a != objc-1) {