summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-13 22:06:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-13 22:06:10 (GMT)
commit8c3eb78cf7bd96819cbf50c6552954c785098f69 (patch)
treeef70c73ff15c99c137682381b9c15c4871fe505c /unix/tclUnixSock.c
parent14b5289e4aa4945dd080d1d3d2dad7f54537eec8 (diff)
parent73cc9cd62f844146e1d9a835511da3b641aafac0 (diff)
downloadtcl-8c3eb78cf7bd96819cbf50c6552954c785098f69.zip
tcl-8c3eb78cf7bd96819cbf50c6552954c785098f69.tar.gz
tcl-8c3eb78cf7bd96819cbf50c6552954c785098f69.tar.bz2
Merge 8.7
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 993ee95..31095bd 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -689,32 +689,22 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = (TcpState *)instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* 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) {
- errorCode = errno;
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->fds.fd, SHUT_RD) < 0)) {
+ readError = errno;
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0)) {
+ writeError = errno;
+ }
+ return (readError != 0) ? readError : writeError;
}
/*