summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authormax <max@tclers.tk>2014-03-10 12:08:44 (GMT)
committermax <max@tclers.tk>2014-03-10 12:08:44 (GMT)
commit3c84887dc4fac9f47f2c1b5521c6d889ab6f9dc1 (patch)
treee517c6351c44d566f834479febaea0af17f17928 /unix
parentbc91d5aa1ef2be26a0f1a6d3de3fb05724964afe (diff)
downloadtcl-3c84887dc4fac9f47f2c1b5521c6d889ab6f9dc1.zip
tcl-3c84887dc4fac9f47f2c1b5521c6d889ab6f9dc1.tar.gz
tcl-3c84887dc4fac9f47f2c1b5521c6d889ab6f9dc1.tar.bz2
* tclUnixSock.c: Fix WaitForConnect() for client sockets that have to try more than one address.
* socket.test: Extend and improve tests for [socket -async] * socket.test: Add latency measuring and calculation for Windows.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index c866903..41d729e 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -163,6 +163,8 @@ static TclInitProcessGlobalValueProc InitializeHostName;
static ProcessGlobalValue hostName =
{0, 0, NULL, NULL, InitializeHostName, NULL, NULL};
+#if 0
+/* printf debugging */
void printaddrinfo(struct addrinfo *addrlist, char *prefix)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
@@ -175,6 +177,7 @@ void printaddrinfo(struct addrinfo *addrlist, char *prefix)
fprintf(stderr,"%s: %s:%s\n", prefix, host, port);
}
}
+#endif
/*
*----------------------------------------------------------------------
*
@@ -409,18 +412,20 @@ WaitForConnect(
timeOut = 0;
} else {
timeOut = -1;
+ CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
}
errno = 0;
state = TclUnixWaitForFile(statePtr->fds.fd,
TCL_WRITABLE | TCL_EXCEPTION, timeOut);
- if (state & TCL_EXCEPTION) {
- return -1;
- }
- if (state & TCL_WRITABLE) {
- CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
- } else if (timeOut == 0) {
+ CreateClientSocket(NULL, statePtr);
+ if (statePtr->flags & TCP_ASYNC_CONNECT) {
+ /* We are still in progress, so ignore the result of the last
+ * attempt */
*errorCodePtr = errno = EWOULDBLOCK;
return -1;
+ }
+ if (state & TCL_EXCEPTION) {
+ return -1;
}
}
return 0;
@@ -1172,9 +1177,6 @@ Tcl_OpenTcpClient(
return NULL;
}
- printaddrinfo(myaddrlist, "local");
- printaddrinfo(addrlist, "remote");
-
/*
* Allocate a new TcpState for this socket.
*/