From d4daeaf6fdc234980b6b7e28b281185896c2dd11 Mon Sep 17 00:00:00 2001 From: limeboy Date: Tue, 20 Dec 2016 10:22:22 +0000 Subject: Correct the handling of -server and its options. --- generic/tclIOCmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 0eb8f99..fb37ff6 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -1493,7 +1493,7 @@ Tcl_SocketObjCmd( SKT_SERVER }; int optionIndex, a, server = 0, myport = 0, async = 0, boolTmp; - unsigned int flags = TCL_TCPSERVER_REUSEADDR; + unsigned int flags = 0; const char *host, *port, *myaddr = NULL; Tcl_Obj *script = NULL; Tcl_Channel chan; @@ -1552,6 +1552,7 @@ Tcl_SocketObjCmd( return TCL_ERROR; } server = 1; + flags |= TCL_TCPSERVER_REUSEADDR; a++; if (a >= objc) { Tcl_SetObjResult(interp, Tcl_NewStringObj( -- cgit v0.12 From bbe8ae73e2e5c693a20ea16c964949279ff83045 Mon Sep 17 00:00:00 2001 From: limeboy Date: Tue, 20 Dec 2016 10:56:53 +0000 Subject: Decouple the switch handling. --- generic/tclIOCmd.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index fb37ff6..e64e31d 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -1492,7 +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, boolTmp; + 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; @@ -1552,7 +1553,8 @@ Tcl_SocketObjCmd( return TCL_ERROR; } server = 1; - flags |= TCL_TCPSERVER_REUSEADDR; + /* [TIP#456] Set for backward-compatibility. */ + reusea = 1; a++; if (a >= objc) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -1568,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++; @@ -1584,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"); @@ -1621,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) { -- cgit v0.12 n value='4'>4space:mode:
authorFred Drake <fdrake@acm.org>2000-07-03 13:44:25 (GMT)
committerFred Drake <fdrake@acm.org>2000-07-03 13:44:25 (GMT)
commit0ea1fc8acf33bdbfe578d8ccaba6e030da6bde40 (patch)
tree3c6ae867ea392a7806fec6a6e7cf49251642299d /Lib/pty.py
parentae96aab1fedb23c5527906eef17bbfc54d7c04f7 (diff)
downloadcpython-0ea1fc8acf33bdbfe578d8ccaba6e030da6bde40.zip
cpython-0ea1fc8acf33bdbfe578d8ccaba6e030da6bde40.tar.gz
cpython-0ea1fc8acf33bdbfe578d8ccaba6e030da6bde40.tar.bz2
Fix bug #379, reported by Phillip Porch <root@theproch.com>:
openpty(): Fallback code when os.openpty() does not exist attempted to call _slave_open(), which should have been slave_open(). This bug only showed on platforms which do not provide a working openpty() in the C library.
EADME.s606817logstatsplain