diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-30 13:00:12 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-30 13:00:12 (GMT) |
commit | 56f2fc4f042a67bb4211d55850c10c1639795dd6 (patch) | |
tree | 1e13b44a4ee525126f84111417e0d4284c07166b /win | |
parent | 92c8a53689ae3aed2756704c0497352e686c3ae2 (diff) | |
download | tcl-56f2fc4f042a67bb4211d55850c10c1639795dd6.zip tcl-56f2fc4f042a67bb4211d55850c10c1639795dd6.tar.gz tcl-56f2fc4f042a67bb4211d55850c10c1639795dd6.tar.bz2 |
According to the [https://core.tcl-lang.org/tcl/artifact?udc=1&ln=469-471&name=5ac7827cd282bbda|documentation], close2Proc(...., 0) should operate the same as closeProc(). Fix the UNIX/Windows socket channels to behave like that.
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinSock.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index a397a30..565b525 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -1069,34 +1069,25 @@ TcpClose2Proc( { TcpState *statePtr = instanceData; int errorCode = 0; - int sd; /* * Shutdown the OS socket handle. */ - switch(flags) { - case TCL_CLOSE_READ: - sd = SD_RECEIVE; - break; - case TCL_CLOSE_WRITE: - sd = SD_SEND; - break; - default: - if (interp) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "socket close2proc called bidirectionally", -1)); - } - return TCL_ERROR; + if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) { + return TcpCloseProc(instanceData, interp); } /* single fd operation: Tcl_OpenTcpServer() does not set TCL_READABLE or * TCL_WRITABLE so this should never be called for a server socket. */ - if (shutdown(statePtr->sockets->fd, sd) == SOCKET_ERROR) { + if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) { + TclWinConvertError((DWORD) WSAGetLastError()); + errorCode = Tcl_GetErrno(); + } + if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR) && (errorCode != 0)) { TclWinConvertError((DWORD) WSAGetLastError()); errorCode = Tcl_GetErrno(); } - return errorCode; } |