summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-05 11:48:21 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-05 11:48:21 (GMT)
commit6daca5d73a73ae0fc2aa25376f8c72eb500d93e5 (patch)
tree5c38685f87eb9dfb22557e63d0a40f5e111aa45a
parent0bee61f5cdb81ebd07d6d0d4f2874abc11554612 (diff)
parent38aabeeca86a4a08cdf5def1c47588c02aafcf9c (diff)
downloadtcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.zip
tcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.tar.gz
tcl-6daca5d73a73ae0fc2aa25376f8c72eb500d93e5.tar.bz2
Merge 8.6
-rw-r--r--generic/tclIO.c35
-rw-r--r--unix/tclUnixSock.c19
2 files changed, 21 insertions, 33 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;
}
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index c94ee4e..dd8ca30 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -627,11 +627,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
@@ -665,9 +666,6 @@ TcpCloseProc(
freeaddrinfo(statePtr->myaddrlist);
}
ckfree(statePtr);
- if (interp && errorCode) {
- Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
- }
return errorCode;
}
@@ -691,19 +689,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;
@@ -711,12 +709,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;
}
/*