summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2014-10-17 12:52:15 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2014-10-17 12:52:15 (GMT)
commitfc47c8aae5f8c68455ee588cfbe4f707e91bde7d (patch)
treebe3de78d31378f969e402b18be8388fe7ba20689 /unix
parentceff856085045650b5b10e2d2fea1355ba78e4c4 (diff)
parenta9606871f5ddb7d6a8cd69f3fa0c41fe8b3c0396 (diff)
downloadtcl-fc47c8aae5f8c68455ee588cfbe4f707e91bde7d.zip
tcl-fc47c8aae5f8c68455ee588cfbe4f707e91bde7d.tar.gz
tcl-fc47c8aae5f8c68455ee588cfbe4f707e91bde7d.tar.bz2
fconfigure -peername and -sockname return empty string while async connect running.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 96700ce..d06e7f1 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -823,7 +823,20 @@ TcpGetOptionProc(
address peername;
socklen_t size = sizeof(peername);
- if (getpeername(statePtr->fds.fd, &peername.sa, &size) >= 0) {
+ if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ /*
+ * In async connect output an empty string
+ */
+ if (len == 0) {
+ Tcl_DStringAppendElement(dsPtr, "-peername");
+ Tcl_DStringAppendElement(dsPtr, "");
+ } else {
+ return TCL_OK;
+ }
+ } else if (getpeername(statePtr->fds.fd, &peername.sa, &size) >= 0) {
+ /*
+ * Peername fetch succeeded - output list
+ */
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-peername");
Tcl_DStringStartSublist(dsPtr);
@@ -863,11 +876,18 @@ TcpGetOptionProc(
Tcl_DStringAppendElement(dsPtr, "-sockname");
Tcl_DStringStartSublist(dsPtr);
}
- for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
- size = sizeof(sockname);
- if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) {
- found = 1;
- TcpHostPortList(interp, dsPtr, sockname, size);
+ if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
+ /*
+ * In async connect output an empty string
+ */
+ found = 1;
+ } else {
+ for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
+ size = sizeof(sockname);
+ if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) {
+ found = 1;
+ TcpHostPortList(interp, dsPtr, sockname, size);
+ }
}
}
if (found) {