summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-01-30 13:00:12 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-01-30 13:00:12 (GMT)
commit56f2fc4f042a67bb4211d55850c10c1639795dd6 (patch)
tree1e13b44a4ee525126f84111417e0d4284c07166b /unix
parent92c8a53689ae3aed2756704c0497352e686c3ae2 (diff)
downloadtcl-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 'unix')
-rw-r--r--unix/tclUnixSock.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 90c72c0..ba36d7b 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -659,30 +659,19 @@ TcpClose2Proc(
{
TcpState *statePtr = instanceData;
int errorCode = 0;
- int sd;
/*
* Shutdown the OS socket handle.
*/
-
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SHUT_RD;
- break;
- case TCL_CLOSE_WRITE:
- sd = SHUT_WR;
- 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);
}
- if (shutdown(statePtr->fds.fd,sd) < 0) {
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->fds.fd, SHUT_RD) < 0)) {
+ errorCode = errno;
+ }
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0) && (errorCode != 0)) {
errorCode = errno;
}
-
return errorCode;
}