diff options
author | max <max@tclers.tk> | 2012-06-22 15:25:24 (GMT) |
---|---|---|
committer | max <max@tclers.tk> | 2012-06-22 15:25:24 (GMT) |
commit | 5a8367e149f598717dab86e248272257f4517f04 (patch) | |
tree | 5a0211bba7ea00dcd0859e0f68639c2ecd9d8d99 /unix | |
parent | 52c7ab0373f510018f799d3937d4ced51b2a481e (diff) | |
download | tcl-5a8367e149f598717dab86e248272257f4517f04.zip tcl-5a8367e149f598717dab86e248272257f4517f04.tar.gz tcl-5a8367e149f598717dab86e248272257f4517f04.tar.bz2 |
Rework the error message generation of [socket], so that the error
code of getaddrinfo is used instead of errno unless it is EAI_SYSTEM.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixSock.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 12e5a9a..f6abfd5 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -1117,10 +1117,11 @@ Tcl_OpenTcpClient( freeaddrinfo(addrlist); } if (interp != NULL) { - Tcl_AppendResult(interp, "couldn't open socket: ", - Tcl_PosixError(interp), NULL); - if (errorMsg != NULL) { - Tcl_AppendResult(interp, " (", errorMsg, ")", NULL); + Tcl_AppendResult(interp, "couldn't open socket: ", NULL); + if (errorMsg == NULL) { + Tcl_AppendResult(interp, Tcl_PosixError(interp), NULL); + } else { + Tcl_AppendResult(interp, errorMsg, NULL); } } return NULL; @@ -1261,10 +1262,11 @@ Tcl_OpenTcpServer( * Try to record and return the most meaningful error message, i.e. the * one from the first socket that went the farthest before it failed. */ - enum { START, SOCKET, BIND, LISTEN } howfar = START; + enum { LOOKUP, SOCKET, BIND, LISTEN } howfar = LOOKUP; int my_errno = 0; if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) { + my_errno = errno; goto error; } @@ -1392,11 +1394,12 @@ Tcl_OpenTcpServer( return statePtr->channel; } if (interp != NULL) { - errno = my_errno; - Tcl_AppendResult(interp, "couldn't open socket: ", - Tcl_PosixError(interp), NULL); - if (errorMsg != NULL) { - Tcl_AppendResult(interp, " (", errorMsg, ")", NULL); + Tcl_AppendResult(interp, "couldn't open socket: ", NULL); + if (errorMsg == NULL) { + errno = my_errno; + Tcl_AppendResult(interp, Tcl_PosixError(interp), NULL); + } else { + Tcl_AppendResult(interp, errorMsg, NULL); } } if (sock != -1) { |