summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authorvasiljevic <zv@archiware.com>2006-09-06 13:08:25 (GMT)
committervasiljevic <zv@archiware.com>2006-09-06 13:08:25 (GMT)
commit17f0d7c6ab239c4f20fb94d2f67a6e365c507143 (patch)
treeddfae99ef563e357ad94090bb150e55a7200e44d /unix/tclUnixSock.c
parentd5c12918537c09220dff6836aa6ff2a1287d54d5 (diff)
downloadtcl-17f0d7c6ab239c4f20fb94d2f67a6e365c507143.zip
tcl-17f0d7c6ab239c4f20fb94d2f67a6e365c507143.tar.gz
tcl-17f0d7c6ab239c4f20fb94d2f67a6e365c507143.tar.bz2
Added MT-safe implementation of some library calls.
See Tcl Bug 999544 for more information.
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index a85fee4..8d6114f 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixSock.c,v 1.6.2.1 2006/03/10 14:23:50 vasiljevic Exp $
+ * RCS: @(#) $Id: tclUnixSock.c,v 1.6.2.2 2006/09/06 13:08:30 vasiljevic Exp $
*/
#include "tcl.h"
@@ -72,6 +72,11 @@ Tcl_GetHostName()
char buffer[sizeof(hostname)];
#endif
CONST char *native;
+#ifdef TCL_THREADS
+ int buflen = 1024, herrno;
+ char buf[1024];
+ struct hostent he;
+#endif
Tcl_MutexLock(&hostMutex);
if (hostnameInited) {
@@ -83,7 +88,12 @@ Tcl_GetHostName()
#ifndef NO_UNAME
(VOID *) memset((VOID *) &u, (int) 0, sizeof(struct utsname));
if (uname(&u) > -1) { /* INTL: Native. */
+#ifdef TCL_THREADS
+ hp = TclpGetHostByName( /* INTL: Native. */
+ u.nodename, &he, buf, buflen, &herrno);
+#else
hp = gethostbyname(u.nodename); /* INTL: Native. */
+#endif
if (hp == NULL) {
/*
* Sometimes the nodename is fully qualified, but gets truncated
@@ -95,7 +105,11 @@ Tcl_GetHostName()
char *node = ckalloc((unsigned) (dot - u.nodename + 1));
memcpy(node, u.nodename, (size_t) (dot - u.nodename));
node[dot - u.nodename] = '\0';
+#ifdef TCL_THREADS
+ hp = TclpGetHostByName(node, &he, buf, buflen, &herrno);
+#else
hp = gethostbyname(node);
+#endif
ckfree(node);
}
}