diff options
| author | harald.oehlmann@elmicron.de <oehhar> | 2014-10-17 12:52:15 (GMT) | 
|---|---|---|
| committer | harald.oehlmann@elmicron.de <oehhar> | 2014-10-17 12:52:15 (GMT) | 
| commit | 57f4a770bab065b0cceee8ea83ecebc102d90c60 (patch) | |
| tree | be3de78d31378f969e402b18be8388fe7ba20689 /unix/tclUnixSock.c | |
| parent | 4556b0c45bbc8ded0ca02e44ee2f5dc8f7a68157 (diff) | |
| parent | ccae7f87b4ac290d65ee01edb60e11c32abe3a54 (diff) | |
| download | tcl-57f4a770bab065b0cceee8ea83ecebc102d90c60.zip tcl-57f4a770bab065b0cceee8ea83ecebc102d90c60.tar.gz tcl-57f4a770bab065b0cceee8ea83ecebc102d90c60.tar.bz2  | |
fconfigure -peername and -sockname return empty string while async connect running.
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) {  | 
