summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authormax <max@tclers.tk>2012-06-22 15:25:24 (GMT)
committermax <max@tclers.tk>2012-06-22 15:25:24 (GMT)
commitffda352cbe3ef13481ae52a01a3da337ad3778fc (patch)
tree5a0211bba7ea00dcd0859e0f68639c2ecd9d8d99 /unix/tclUnixSock.c
parent90e7d603fcf06a4c1c35ebde8e4ddf74134d5844 (diff)
downloadtcl-ffda352cbe3ef13481ae52a01a3da337ad3778fc.zip
tcl-ffda352cbe3ef13481ae52a01a3da337ad3778fc.tar.gz
tcl-ffda352cbe3ef13481ae52a01a3da337ad3778fc.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/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c23
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) {