summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixChan.c
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)
commit58031cfb11e3f6825fa69aebd2ff69e42850e9b9 (patch)
treecde81dd0aa3373d643a9b680e4e2817f64e11e7b /unix/tclUnixChan.c
parentbf3967bd2ef27474befb6257b15322b9a9fa7333 (diff)
downloadtcl-58031cfb11e3f6825fa69aebd2ff69e42850e9b9.zip
tcl-58031cfb11e3f6825fa69aebd2ff69e42850e9b9.tar.gz
tcl-58031cfb11e3f6825fa69aebd2ff69e42850e9b9.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/tclUnixChan.c')
-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:
+ */