summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-11-13 22:18:33 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-11-13 22:18:33 (GMT)
commitc98fcd0e26b54fdecfb35efd6bfc1cbb0a59ce88 (patch)
tree943f7f8415f92979155cc5b4887d76492e483542
parent1800d115208f543141885fa0884e39644328a12e (diff)
parent695df45b409f7e616dc4cdfa24528d9900477663 (diff)
downloadtcl-c98fcd0e26b54fdecfb35efd6bfc1cbb0a59ce88.zip
tcl-c98fcd0e26b54fdecfb35efd6bfc1cbb0a59ce88.tar.gz
tcl-c98fcd0e26b54fdecfb35efd6bfc1cbb0a59ce88.tar.bz2
merge trunk
-rw-r--r--doc/Tcl.n2
-rw-r--r--tests/socket.test28
-rw-r--r--unix/tclUnixSock.c19
3 files changed, 43 insertions, 6 deletions
diff --git a/doc/Tcl.n b/doc/Tcl.n
index be0b24d..8b17f93 100644
--- a/doc/Tcl.n
+++ b/doc/Tcl.n
@@ -28,7 +28,7 @@ First, the Tcl interpreter breaks the command into \fIwords\fR
and performs substitutions as described below.
These substitutions are performed in the same way for all
commands.
-The first word is used to locate a command procedure to
+Secondly, the first word is used to locate a command procedure to
carry out the command, then all of the words of the command are
passed to the command procedure.
The command procedure is free to interpret each of its words
diff --git a/tests/socket.test b/tests/socket.test
index 5542c09..51219e6 100644
--- a/tests/socket.test
+++ b/tests/socket.test
@@ -1841,6 +1841,7 @@ test socket-14.4 {[socket -async] and both, readdable and writable fileevents} \
after cancel $after
close $client
close $server
+ unset x
} -result {{} bye}
test socket-14.5 {[socket -async] which fails before any connect() can be made} \
-constraints [list socket supported_any] \
@@ -1850,6 +1851,33 @@ test socket-14.5 {[socket -async] which fails before any connect() can be made}
} \
-returnCodes 1 \
-result {couldn't open socket: cannot assign requested address}
+test socket-14.6 {[socket -async] with no event loop and [fconfigure -error] before the socket is connected} \
+ -constraints [list socket supported_inet supported_inet6] \
+ -setup {
+ proc accept {s a p} {
+ puts $s bye
+ close $s
+ }
+ set server [socket -server accept -myaddr 127.0.0.1 0]
+ set port [lindex [fconfigure $server -sockname] 2]
+ set x ""
+ } \
+ -body {
+ set client [socket -async localhost $port]
+ foreach _ {1 2} {
+ lappend x [lindex [fconfigure $client -sockname] 0]
+ lappend x [fconfigure $client -error]
+ update
+ }
+ lappend x [gets $client]
+ } \
+ -cleanup {
+ close $server
+ close $client
+ unset x
+ } \
+ -result [list ::1 "connection refused" 127.0.0.1 "" bye]
+
::tcltest::cleanupTests
flush stdout
return
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index a6360c2..7ef28d8 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.