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)
commit5de4bf898178951f38508bd5a5dfc2972e68a897 (patch)
treee517c6351c44d566f834479febaea0af17f17928 /unix
parentd08f5c564cdf386195a15eb198187050f25ae82a (diff)
downloadtcl-5de4bf898178951f38508bd5a5dfc2972e68a897.zip
tcl-5de4bf898178951f38508bd5a5dfc2972e68a897.tar.gz
tcl-5de4bf898178951f38508bd5a5dfc2972e68a897.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.
*/