summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2011-09-01 21:03:12 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2011-09-01 21:03:12 (GMT)
commit9d11f87f176b6d4318a556e83316e338759a426a (patch)
tree4633faee0c9a9589a50ba7e0cd94a48509d16bc5
parent4a4571c9fe2d509639a55f8a366fd631e67a6800 (diff)
downloadtcl-9d11f87f176b6d4318a556e83316e338759a426a.zip
tcl-9d11f87f176b6d4318a556e83316e338759a426a.tar.gz
tcl-9d11f87f176b6d4318a556e83316e338759a426a.tar.bz2
[Bug 3401422] Cache script-level changes to the nonblocking flag of an async client socket in progress, and commit them on completion.
-rw-r--r--ChangeLog6
-rw-r--r--unix/tclUnixSock.c8
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 06ece36..a5bac84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-01 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
+
+ * unix/tclUnixSock.c: [Bug 3401422] Cache script-level changes to
+ the nonblocking flag of an async client socket in progress, and
+ commit them on completion.
+
2011-09-01 Don Porter <dgp@users.sourceforge.net>
* generic/tclStrToD.c: [Bug 3402540] Corrections to TclParseNumber()
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 35c00c5..7b5c9e0 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -68,6 +68,7 @@ struct TcpState {
int filehandlers; /* Caches FileHandlers that get set up while
* an async socket is not yet connected */
int status; /* Cache status of async socket */
+ int cachedBlocking; /* Cache blocking mode of async socket */
};
/*
@@ -348,6 +349,10 @@ TcpBlockModeProc(
} else {
SET_BITS(statePtr->flags, TCP_ASYNC_SOCKET);
}
+ if (statePtr->flags & TCP_ASYNC_CONNECT) {
+ statePtr->cachedBlocking = mode;
+ return 0;
+ }
if (TclUnixSetBlockingMode(statePtr->fds.fd, mode) < 0) {
return errno;
}
@@ -1038,7 +1043,7 @@ out:
*/
CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
TcpWatchProc(state, state->filehandlers);
- TclUnixSetBlockingMode(state->fds.fd, TCL_MODE_BLOCKING);
+ TclUnixSetBlockingMode(state->fds.fd, state->cachedBlocking);
/*
* We need to forward the writable event that brought us here, bcasue
@@ -1122,6 +1127,7 @@ Tcl_OpenTcpClient(
state = ckalloc(sizeof(TcpState));
memset(state, 0, sizeof(TcpState));
state->flags = async ? TCP_ASYNC_CONNECT : 0;
+ state->cachedBlocking = TCL_MODE_BLOCKING;
state->addrlist = addrlist;
state->myaddrlist = myaddrlist;
state->fds.fd = -1;