diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-05 11:32:43 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-05 11:32:43 (GMT) |
commit | 38aabeeca86a4a08cdf5def1c47588c02aafcf9c (patch) | |
tree | 16d556c4119d7f871d904ada6bbf6511c12f1c11 /generic | |
parent | dd7b6e22451427342c566bd331192a76a3d32d32 (diff) | |
download | tcl-38aabeeca86a4a08cdf5def1c47588c02aafcf9c.zip tcl-38aabeeca86a4a08cdf5def1c47588c02aafcf9c.tar.gz tcl-38aabeeca86a4a08cdf5def1c47588c02aafcf9c.tar.bz2 |
Move setting of interpreter error-message from tclUnixSock.c to tclIO.c, since the same should be done for all channel types. (Thanks, Don, for noticing this!)
Also, ENOTCONN for a half-close should not be fatal, just a EINVAL, when doing it as part of a full close. See: [65c9cd1534]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 36f0a8e..67264a0 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -365,15 +365,6 @@ ChanClose( } } -static inline int -ChanCloseHalf( - Channel *chanPtr, - Tcl_Interp *interp, - int flags) -{ - return chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, flags); -} - /* *--------------------------------------------------------------------------- * @@ -3466,7 +3457,7 @@ Tcl_Close( if (chanPtr->typePtr->closeProc == TCL_CLOSE2PROC) { result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ); - if (result == EINVAL) { + if ((result == EINVAL) || result == ENOTCONN) { result = 0; } } @@ -3512,13 +3503,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; @@ -3816,7 +3811,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 @@ -4220,12 +4215,12 @@ WillRead( * Prevent read attempts on a closed channel. */ - DiscardInputQueued(chanPtr->state, 0); + DiscardInputQueued(chanPtr->state, 0); Tcl_SetErrno(EINVAL); return -1; } if ((Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL) - && (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) { + && (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) { /* * CAVEAT - The assumption here is that FlushChannel() will push out @@ -4237,9 +4232,9 @@ WillRead( * blocking mode. */ - if (FlushChannel(NULL, chanPtr, 0) != 0) { - return -1; - } + if (FlushChannel(NULL, chanPtr, 0) != 0) { + return -1; + } } return 0; } |