summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2010-03-01 15:22:17 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2010-03-01 15:22:17 (GMT)
commit4d8d10a3839ee12d865c3ec30a29b2384e9ddfdf (patch)
treecde81dd0aa3373d643a9b680e4e2817f64e11e7b /unix
parentefd26ca494a8ac14d5d66d17967f4c7617bf90b9 (diff)
downloadtcl-4d8d10a3839ee12d865c3ec30a29b2384e9ddfdf.zip
tcl-4d8d10a3839ee12d865c3ec30a29b2384e9ddfdf.tar.gz
tcl-4d8d10a3839ee12d865c3ec30a29b2384e9ddfdf.tar.bz2
[backported] Refrain from a possibly lengthy reverse-DNS lookup on 0.0.0.0 when
calling [fconfigure -sockname] on an universally-bound (default) server socket.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 33b52b8..f23f44e 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixChan.c,v 1.42.2.11 2008/03/03 15:01:14 rmax Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.42.2.12 2010/03/01 15:22:17 ferrieux Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
@@ -2356,12 +2356,21 @@ TcpGetOptionProc(instanceData, interp, optionName, dsPtr)
Tcl_DStringStartSublist(dsPtr);
}
Tcl_DStringAppendElement(dsPtr, inet_ntoa(sockname.sin_addr));
- hostEntPtr = TclpGetHostByAddr( /* INTL: Native. */
- (char *) &sockname.sin_addr,
- sizeof(sockname.sin_addr), AF_INET);
+ if (sockname.sin_addr.s_addr == INADDR_ANY) {
+ /*
+ * We don't want to resolve INADDR_ANY; it can sometimes cause
+ * problems (and never has a name).
+ */
+
+ hostEntPtr = NULL;
+ } else {
+ hostEntPtr = TclpGetHostByAddr( /* INTL: Native. */
+ (char *) &sockname.sin_addr,
+ sizeof(sockname.sin_addr), AF_INET);
+ }
if (hostEntPtr != (struct hostent *) NULL) {
Tcl_DString ds;
-
+
Tcl_ExternalToUtfDString(NULL, hostEntPtr->h_name, -1, &ds);
Tcl_DStringAppendElement(dsPtr, Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
@@ -3357,4 +3366,14 @@ FileThreadActionProc (instanceData, action)
}
}
#endif /* DEPRECATED */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */