diff options
| author | ferrieux@users.sourceforge.net <ferrieux> | 2011-09-01 21:03:12 (GMT) |
|---|---|---|
| committer | ferrieux@users.sourceforge.net <ferrieux> | 2011-09-01 21:03:12 (GMT) |
| commit | f5161cfc4b3c7036e33c87c98abee9231a260f5c (patch) | |
| tree | 4633faee0c9a9589a50ba7e0cd94a48509d16bc5 /unix/tclUnixSock.c | |
| parent | 5e054e1ce430333746db917361609f04fdd3ee4e (diff) | |
| download | tcl-f5161cfc4b3c7036e33c87c98abee9231a260f5c.zip tcl-f5161cfc4b3c7036e33c87c98abee9231a260f5c.tar.gz tcl-f5161cfc4b3c7036e33c87c98abee9231a260f5c.tar.bz2 | |
[Bug 3401422] Cache script-level changes to the nonblocking flag of an async client socket in progress, and commit them on completion.
Diffstat (limited to 'unix/tclUnixSock.c')
| -rw-r--r-- | unix/tclUnixSock.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; |
