summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2014-06-05 19:09:51 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2014-06-05 19:09:51 (GMT)
commitf1bac0e8becc22f505069ad52dae904eae5e004d (patch)
treec5175906e8b8d81926dedaeea30254ef3875ff6f /win
parent852f44abf1e24dce23b456d6cfa857bb5649300e (diff)
downloadtcl-f1bac0e8becc22f505069ad52dae904eae5e004d.zip
tcl-f1bac0e8becc22f505069ad52dae904eae5e004d.tar.gz
tcl-f1bac0e8becc22f505069ad52dae904eae5e004d.tar.bz2
Robust async connect tests by temporarely switching off auto continuation. Ticket [13d3af3ad5]
Diffstat (limited to 'win')
-rw-r--r--win/tclWinSock.c38
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) {