diff options
author | ferrieux <ferrieux@users.sourceforge.net> | 2011-09-01 21:03:12 (GMT) |
---|---|---|
committer | ferrieux <ferrieux@users.sourceforge.net> | 2011-09-01 21:03:12 (GMT) |
commit | 9d11f87f176b6d4318a556e83316e338759a426a (patch) | |
tree | 4633faee0c9a9589a50ba7e0cd94a48509d16bc5 /unix/tclUnixSock.c | |
parent | 4a4571c9fe2d509639a55f8a366fd631e67a6800 (diff) | |
download | tcl-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.
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; |