summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 31daa62..49a6460 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -737,7 +737,10 @@ TcpGetOptionProc(
if (statePtr->status == 0) {
ret = getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
- (char *) &err, &optlen);
+ (char *) &err, &optlen);
+ if (statePtr->flags & TCP_ASYNC_CONNECT) {
+ statePtr->status = err;
+ }
if (ret < 0) {
err = errno;
}
@@ -1054,12 +1057,17 @@ CreateClientSocket(
*/
optlen = sizeof(int);
- getsockopt(state->fds.fd, SOL_SOCKET, SO_ERROR,
- (char *) &status, &optlen);
- state->status = status;
+
+ if (state->status == 0) {
+ getsockopt(state->fds.fd, SOL_SOCKET, SO_ERROR,
+ (char *) &status, &optlen);
+ state->status = status;
+ } else {
+ status = state->status;
+ state->status = 0;
+ }
}
if (status == 0) {
- CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
goto out;
}
}
@@ -1067,6 +1075,7 @@ CreateClientSocket(
out:
+ CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
if (async_callback) {
/*
* An asynchonous connection has finally succeeded or failed.
@@ -1202,7 +1211,7 @@ Tcl_Channel
Tcl_MakeTcpClientChannel(
ClientData sock) /* The socket to wrap up into a channel. */
{
- return TclpMakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
+ return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
}
/*
@@ -1222,9 +1231,9 @@ Tcl_MakeTcpClientChannel(
*----------------------------------------------------------------------
*/
-Tcl_Channel
+void *
TclpMakeTcpClientChannelMode(
- ClientData sock, /* The socket to wrap up into a channel. */
+ void *sock, /* The socket to wrap up into a channel. */
int mode) /* ORed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
@@ -1357,6 +1366,7 @@ Tcl_OpenTcpServer(
my_errno = errno;
}
close(sock);
+ sock = -1;
continue;
}
if (port == 0 && chosenport == 0) {
@@ -1379,6 +1389,7 @@ Tcl_OpenTcpServer(
my_errno = errno;
}
close(sock);
+ sock = -1;
continue;
}
if (statePtr == NULL) {