diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-05 11:48:21 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-05 11:48:21 (GMT) |
commit | 6daca5d73a73ae0fc2aa25376f8c72eb500d93e5 (patch) | |
tree | 5c38685f87eb9dfb22557e63d0a40f5e111aa45a /generic/tclIO.c | |
parent | 0bee61f5cdb81ebd07d6d0d4f2874abc11554612 (diff) | |
parent | 38aabeeca86a4a08cdf5def1c47588c02aafcf9c (diff) | |
download | tcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.zip tcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.tar.gz tcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.tar.bz2 |
Merge 8.6
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index d21c9f3..3eca7cc 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -382,15 +382,6 @@ ChanClose( return chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, 0); } -static inline int -ChanCloseHalf( - Channel *chanPtr, - Tcl_Interp *interp, - int flags) -{ - return chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, flags); -} - /* *--------------------------------------------------------------------------- * @@ -3502,15 +3493,15 @@ Tcl_Close( #ifndef TCL_NO_DEPRECATED if ((chanPtr->typePtr->closeProc == TCL_CLOSE2PROC) || (chanPtr->typePtr->closeProc == NULL)) { - /* If this half-close gives a EINVAL, just continue the full close */ + /* If this half-close gives a EINVAL or ENOTCONN, just continue the full close */ result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); - if (result == EINVAL) { + if ((result == EINVAL) || result == ENOTCONN) { result = 0; } } #else result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); - if (result == EINVAL) { + if ((result == EINVAL) || result == ENOTCONN) { result = 0; } #endif @@ -3556,13 +3547,17 @@ Tcl_Close( * message set up to now. */ - if (flushcode != 0 && interp != NULL + if (flushcode != 0) { + /* flushcode has precedence, if available */ + result = flushcode; + } + if ((result != 0) && (result != TCL_ERROR) && (interp != NULL) && 0 == Tcl_GetCharLength(Tcl_GetObjResult(interp))) { - Tcl_SetErrno(flushcode); + Tcl_SetErrno(result); Tcl_SetObjResult(interp, Tcl_NewStringObj(Tcl_PosixError(interp), -1)); } - if ((flushcode != 0) || (result != 0)) { + if (result != 0) { return TCL_ERROR; } return TCL_OK; @@ -3858,7 +3853,7 @@ CloseChannelPart( * message in the interp. */ - result = ChanCloseHalf(chanPtr, interp, flags); + result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, NULL, flags); /* * If we are being called synchronously, report either any latent error on @@ -4265,7 +4260,7 @@ WillRead( * Prevent read attempts on a closed channel. */ - DiscardInputQueued(chanPtr->state, 0); + DiscardInputQueued(chanPtr->state, 0); Tcl_SetErrno(EINVAL); return -1; } @@ -4284,9 +4279,9 @@ WillRead( * blocking mode. */ - if (FlushChannel(NULL, chanPtr, 0) != 0) { - return -1; - } + if (FlushChannel(NULL, chanPtr, 0) != 0) { + return -1; + } } return 0; } |