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 | 1e3fa455c9367e0c369d4d5be7b02751ffbcaeab (patch) | |
tree | db47406be713ada278bfad3b9fd62c29c2c30b39 /win/tclWinSock.c | |
parent | d00198bd14d66e196b9640683d02023b8a0b2dd7 (diff) | |
parent | fad7a0e23def29ea35f22dcf310f964124286378 (diff) | |
download | tcl-1e3fa455c9367e0c369d4d5be7b02751ffbcaeab.zip tcl-1e3fa455c9367e0c369d4d5be7b02751ffbcaeab.tar.gz tcl-1e3fa455c9367e0c369d4d5be7b02751ffbcaeab.tar.bz2 |
Merge Harald's "robust-async-connect-tests" branch. Thanks!
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index d6aca1b..a5d98ae 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -124,6 +124,8 @@ typedef struct TcpFdList { struct TcpState { Tcl_Channel channel; /* Channel associated with this socket. */ + int testFlags; /* bit field for tests. Is set by testsocket + * test procedure */ struct TcpFdList *sockets; /* Windows SOCKET handle. */ int flags; /* Bit field comprised of the flags described * below. */ @@ -184,6 +186,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 structure is what is added to the Tcl event queue when a * socket event occurs. */ @@ -599,6 +610,20 @@ WaitForConnect( } /* + * In socket test mode do not continue with the connect + * Exceptions are: + * - Call by recv/send and blocking socket + * (errorCodePtr != NULL && ! flags & TCP_NONBLOCKING) + * - Call by the event queue (errorCodePtr == NULL) + */ + + if ( (statePtr->testFlags & TCP_ASYNC_TEST_MODE) + && errorCodePtr != NULL && (statePtr->flags & TCP_NONBLOCKING)) { + *errorCodePtr = EWOULDBLOCK; + return -1; + } + + /* * Be sure to disable event servicing so we are truly modal. */ @@ -1292,7 +1317,9 @@ TcpGetOptionProc( * below. */ - WaitForConnect(statePtr, NULL); + if (! (statePtr->testFlags & TCP_ASYNC_TEST_MODE) ) { + WaitForConnect(statePtr, NULL); + } sock = statePtr->sockets->fd; if (optionName != NULL) { |