diff options
author | vasiljevic <vasiljevic@noemail.net> | 2006-09-06 13:08:24 (GMT) |
---|---|---|
committer | vasiljevic <vasiljevic@noemail.net> | 2006-09-06 13:08:24 (GMT) |
commit | 04b0c5ed5aaa46bd3bbc7100bd121133f89100e0 (patch) | |
tree | ddfae99ef563e357ad94090bb150e55a7200e44d /unix/tclUnixChan.c | |
parent | 9cc699c13e075864cf97b4806977778d0e5e2eea (diff) | |
download | tcl-04b0c5ed5aaa46bd3bbc7100bd121133f89100e0.zip tcl-04b0c5ed5aaa46bd3bbc7100bd121133f89100e0.tar.gz tcl-04b0c5ed5aaa46bd3bbc7100bd121133f89100e0.tar.bz2 |
Added MT-safe implementation of some library calls.
See Tcl Bug 999544 for more information.
FossilOrigin-Name: fa1da032d77a63dbe9ece8e7f3883953fb6a8ea8
Diffstat (limited to 'unix/tclUnixChan.c')
-rw-r--r-- | unix/tclUnixChan.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 2be6cbc..22da743 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.7 2006/08/18 11:23:31 das Exp $ + * RCS: @(#) $Id: tclUnixChan.c,v 1.42.2.8 2006/09/06 13:08:30 vasiljevic Exp $ */ #include "tclInt.h" /* Internal definitions for Tcl. */ @@ -2301,14 +2301,25 @@ TcpGetOptionProc(instanceData, interp, optionName, dsPtr) (strncmp(optionName, "-peername", len) == 0))) { if (getpeername(statePtr->fd, (struct sockaddr *) &peername, &size) >= 0) { +#ifdef TCL_THREADS + int buflen = 1024, herrno; + char hbuf[1024]; + struct hostent he; +#endif if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-peername"); Tcl_DStringStartSublist(dsPtr); } Tcl_DStringAppendElement(dsPtr, inet_ntoa(peername.sin_addr)); +#ifdef TCL_THREADS + hostEntPtr = TclpGetHostByAddr( /* INTL: Native. */ + (char *) &peername.sin_addr, sizeof(peername.sin_addr), + AF_INET, &he, hbuf, buflen, &herrno); +#else hostEntPtr = gethostbyaddr( /* INTL: Native. */ (char *) &peername.sin_addr, sizeof(peername.sin_addr), AF_INET); +#endif if (hostEntPtr != NULL) { Tcl_DString ds; @@ -2348,14 +2359,25 @@ TcpGetOptionProc(instanceData, interp, optionName, dsPtr) (strncmp(optionName, "-sockname", len) == 0))) { if (getsockname(statePtr->fd, (struct sockaddr *) &sockname, &size) >= 0) { +#ifdef TCL_THREADS + int buflen = 1024, herrno; + char hbuf[1024]; + struct hostent he; +#endif if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-sockname"); Tcl_DStringStartSublist(dsPtr); } Tcl_DStringAppendElement(dsPtr, inet_ntoa(sockname.sin_addr)); +#ifdef TCL_THREADS + hostEntPtr = TclpGetHostByAddr( /* INTL: Native. */ + (char *) &sockname.sin_addr, sizeof(sockname.sin_addr), + AF_INET, &he, hbuf, buflen, &herrno); +#else hostEntPtr = gethostbyaddr( /* INTL: Native. */ (char *) &sockname.sin_addr, sizeof(sockname.sin_addr), AF_INET); +#endif if (hostEntPtr != (struct hostent *) NULL) { Tcl_DString ds; @@ -2686,7 +2708,15 @@ CreateSocketAddress(sockaddrPtr, host, port) * on either 32 or 64 bits systems. */ if (addr.s_addr == 0xFFFFFFFF) { +#ifdef TCL_THREADS + int buflen = 1024, herrno; + char hbuf[1024]; + struct hostent he; + hostent = TclpGetHostByName( /* INTL: Native. */ + native, &he, hbuf, buflen, &herrno); +#else hostent = gethostbyname(native); /* INTL: Native. */ +#endif if (hostent != NULL) { memcpy((VOID *) &addr, (VOID *) hostent->h_addr_list[0], |