summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-05 11:56:24 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-05 11:56:24 (GMT)
commit7f9190f5dbec461782b2ecad2f30159912f6a459 (patch)
tree17968d873808c74a2d384d833f34ac2099471f88
parent2328e4a58e51a3259283f9ce1cac2edfae259fdc (diff)
parent6daca5d73a73ae0fc2aa25376f8c72eb500d93e5 (diff)
downloadtcl-7f9190f5dbec461782b2ecad2f30159912f6a459.zip
tcl-7f9190f5dbec461782b2ecad2f30159912f6a459.tar.gz
tcl-7f9190f5dbec461782b2ecad2f30159912f6a459.tar.bz2
Merge 8.7
-rw-r--r--generic/tclIO.c31
-rw-r--r--unix/tclUnixSock.c19
2 files changed, 19 insertions, 31 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 49bdc96..f365557 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -377,15 +377,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);
-}
-
/*
*---------------------------------------------------------------------------
*
@@ -3475,7 +3466,7 @@ TclClose(
*/
result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp, TCL_CLOSE_READ);
- if (result == EINVAL) {
+ if ((result == EINVAL) || result == ENOTCONN) {
result = 0;
}
@@ -3520,13 +3511,17 @@ TclClose(
* 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;
@@ -3822,7 +3817,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
@@ -4227,7 +4222,7 @@ WillRead(
* Prevent read attempts on a closed channel.
*/
- DiscardInputQueued(chanPtr->state, 0);
+ DiscardInputQueued(chanPtr->state, 0);
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -4243,9 +4238,9 @@ WillRead(
* blocking mode.
*/
- if (FlushChannel(NULL, chanPtr, 0) != 0) {
- return -1;
- }
+ if (FlushChannel(NULL, chanPtr, 0) != 0) {
+ return -1;
+ }
}
return 0;
}
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index a90a72f..781ef33 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -624,11 +624,12 @@ TcpOutputProc(
static int
TcpCloseProc(
void *instanceData, /* The socket to close. */
- Tcl_Interp *interp) /* For error reporting */
+ Tcl_Interp *dummy) /* For error reporting - unused */
{
TcpState *statePtr = (TcpState *)instanceData;
int errorCode = 0;
TcpFdList *fds;
+ (void)dummy;
/*
* Delete a file handler that may be active for this socket if this is a
@@ -662,9 +663,6 @@ TcpCloseProc(
freeaddrinfo(statePtr->myaddrlist);
}
Tcl_Free(statePtr);
- if (interp && errorCode) {
- Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
- }
return errorCode;
}
@@ -688,19 +686,19 @@ TcpCloseProc(
static int
TcpClose2Proc(
void *instanceData, /* The socket to close. */
- Tcl_Interp *interp, /* For error reporting. */
+ Tcl_Interp *dummy, /* For error reporting. */
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = (TcpState *)instanceData;
int readError = 0;
int writeError = 0;
- int errorCode = 0;
+ (void)dummy;
/*
* Shutdown the OS socket handle.
*/
if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
- return TcpCloseProc(instanceData, interp);
+ return TcpCloseProc(instanceData, NULL);
}
if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->fds.fd, SHUT_RD) < 0)) {
readError = errno;
@@ -708,12 +706,7 @@ TcpClose2Proc(
if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0)) {
writeError = errno;
}
-
- errorCode = (readError != 0) ? readError : writeError;
- if (interp && errorCode) {
- Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
- }
- return errorCode;
+ return (readError != 0) ? readError : writeError;
}
/*