diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2014-06-05 19:09:51 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2014-06-05 19:09:51 (GMT) |
commit | 85daeb5e16f187030b6d62005b52f897fb7a102d (patch) | |
tree | c5175906e8b8d81926dedaeea30254ef3875ff6f /win/tclWinSock.c | |
parent | 45fd54872fa0bcff3d89f8077d9a7ca220bba89f (diff) | |
download | tcl-85daeb5e16f187030b6d62005b52f897fb7a102d.zip tcl-85daeb5e16f187030b6d62005b52f897fb7a102d.tar.gz tcl-85daeb5e16f187030b6d62005b52f897fb7a102d.tar.bz2 |
Robust async connect tests by temporarely switching off auto continuation. Ticket [13d3af3ad5]
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index f343f82..2703309 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -191,6 +191,9 @@ struct TcpState { * flag indicates that reentry is * still pending */ #define TCP_ASYNC_FAILED (1<<5) /* An async connect finally failed */ +#define TCP_ASYNC_TEST_MODE (1<<6) /* Async testing activated + * Do not automatically continue connection + * process */ /* * The following structure is what is added to the Tcl event queue when a @@ -602,6 +605,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->flags & 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. */ @@ -1123,6 +1140,7 @@ TcpSetOptionProc( const char *optionName, /* Name of the option to set. */ const char *value) /* New value for option. */ { + TcpState *statePtr = instanceData; #ifdef TCL_FEATURE_KEEPALIVE_NAGLE TcpState *statePtr = instanceData; SOCKET sock; @@ -1142,6 +1160,22 @@ TcpSetOptionProc( return TCL_ERROR; } + /* + * Set socket test int value + */ + if (!strcmp(optionName, "-unsupported1")) { + int intValue; + if (Tcl_GetInt(interp, value, &intValue) != TCL_OK) { + return TCL_ERROR; + } + if (intValue & 1) { + SET_BITS(statePtr->flags,TCP_ASYNC_TEST_MODE); + } else { + CLEAR_BITS(statePtr->flags,TCP_ASYNC_TEST_MODE); + } + return TCL_OK; + } + #ifdef TCL_FEATURE_KEEPALIVE_NAGLE #error "TCL_FEATURE_KEEPALIVE_NAGLE not reviewed for whether to treat statePtr->sockets as single fd or list" sock = statePtr->sockets->fd; @@ -1254,7 +1288,9 @@ TcpGetOptionProc( * Go one step in async connect * If any error is thrown save it as backround error to report eventually below */ - WaitForConnect(statePtr, NULL); + if (! (statePtr->flags & TCP_ASYNC_TEST_MODE) ) { + WaitForConnect(statePtr, NULL); + } sock = statePtr->sockets->fd; if (optionName != NULL) { |