diff options
author | dgp <dgp@users.sourceforge.net> | 2016-09-08 12:36:59 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-09-08 12:36:59 (GMT) |
commit | e36a7a2e7fa1f1afb57f5e6b06917180e429cd72 (patch) | |
tree | 0790c02161f6cdec20d21508c7d67661383df3b3 /unix/tclUnixSock.c | |
parent | 90bd7a732609ca0664078461027a02ae6f357d97 (diff) | |
parent | d18e6da3e471bdaecc24da3e4dfb28620b880daa (diff) | |
download | tcl-e36a7a2e7fa1f1afb57f5e6b06917180e429cd72.zip tcl-e36a7a2e7fa1f1afb57f5e6b06917180e429cd72.tar.gz tcl-e36a7a2e7fa1f1afb57f5e6b06917180e429cd72.tar.bz2 |
merge 8.6.3
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r-- | unix/tclUnixSock.c | 32 |
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) { |