summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormax <max@tclers.tk>2012-09-26 21:02:33 (GMT)
committermax <max@tclers.tk>2012-09-26 21:02:33 (GMT)
commit301282088d6b7961c502f111c171db6e6a341ab9 (patch)
tree4ab7562c5658167bcb610add94704809fee0b9c3
parent772953aa7f24fe39a87d949c789344bed284d75c (diff)
downloadtcl-301282088d6b7961c502f111c171db6e6a341ab9.zip
tcl-301282088d6b7961c502f111c171db6e6a341ab9.tar.gz
tcl-301282088d6b7961c502f111c171db6e6a341ab9.tar.bz2
Workaround for &#91;socket -server foo -myaddr localhost 0&#93; failure on OSX.
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclIOSock.c15
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d18242..9f10890 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-09-26 Reinhard Max <max@suse.de>
+
+ * generic/tclIOSock.c (TclCreateSocketAddress): Work around a bug
+ in getaddrinfo() on OSX that caused name resolution to fail for
+ [socket -server foo -myaddr localhost 0].
+
2012-09-20 Jan Nijtmans <nijtmans@users.sf.net>
* win/configure.in: New import libraries for zlib 1.2.7,
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index e603c91..694501f 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -151,7 +151,7 @@ TclCreateSocketAddress(
struct addrinfo *p;
struct addrinfo *v4head = NULL, *v4ptr = NULL;
struct addrinfo *v6head = NULL, *v6ptr = NULL;
- char *native = NULL, portstring[TCL_INTEGER_SPACE];
+ char *native = NULL, portbuf[TCL_INTEGER_SPACE], *portstring;
const char *family = NULL;
Tcl_DString ds;
int result, i;
@@ -159,7 +159,18 @@ TclCreateSocketAddress(
if (host != NULL) {
native = Tcl_UtfToExternalDString(NULL, host, -1, &ds);
}
- TclFormatInt(portstring, port);
+
+ /*
+ * Workaround for OSX's apparent inability to resolve "localhost", "0"
+ * when the loopback device is the only available network interface.
+ */
+ if (host != NULL && port == 0) {
+ portstring = NULL;
+ } else {
+ TclFormatInt(portbuf, port);
+ portstring = portbuf;
+ }
+
(void) memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;