diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-10 12:39:54 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-10 12:39:54 (GMT) |
commit | f15e17cb4325805681b5479390866fae1621a4d9 (patch) | |
tree | db47406be713ada278bfad3b9fd62c29c2c30b39 /unix | |
parent | 22946a554a465a115602ba3324fb7fd8ea5590b4 (diff) | |
parent | 27be6e4e9ada6489a2bb9de775cab72378825b2b (diff) | |
download | tcl-f15e17cb4325805681b5479390866fae1621a4d9.zip tcl-f15e17cb4325805681b5479390866fae1621a4d9.tar.gz tcl-f15e17cb4325805681b5479390866fae1621a4d9.tar.bz2 |
Merge Harald's "robust-async-connect-tests" branch. Thanks!
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixSock.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index a64157e..0ae500b 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -52,6 +52,8 @@ typedef struct TcpFdList { struct TcpState { Tcl_Channel channel; /* Channel associated with this file. */ + int testFlags; /* bit field for tests. Is set by testsocket + * test procedure */ TcpFdList fds; /* The file descriptors of the sockets. */ int flags; /* ORed combination of the bitfields defined * below. */ @@ -93,6 +95,15 @@ struct TcpState { #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ /* + * These bits may be ORed together into the "testFlags" field of a TcpState + * structure. + */ + +#define TCP_ASYNC_TEST_MODE (1<<0) /* Async testing activated + * Do not automatically continue connection + * process */ + +/* * The following defines the maximum length of the listen queue. This is the * number of outstanding yet-to-be-serviced requests for a connection on a * server socket, more than this number of outstanding requests and the @@ -444,6 +455,19 @@ WaitForConnect( return 0; } + /* + * In socket test mode do not continue with the connect + * Exceptions are: + * - Call by recv/send and blocking socket + * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) + */ + + if ( (statePtr->testFlags & TCP_ASYNC_TEST_MODE) + && ! (errorCodePtr != NULL && ! (statePtr->flags & TCP_NONBLOCKING))) { + *errorCodePtr = EWOULDBLOCK; + return -1; + } + if (errorCodePtr == NULL || (statePtr->flags & TCP_NONBLOCKING)) { timeout = 0; } else { |