From ac2dd722a683e433db8138b06332f1ce1ac8e7a8 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Wed, 30 Apr 2003 00:44:16 +0000 Subject: [PATCH] Bug 203317: getipnodebyxxx routines are not thread-safe on OpenVMS, so we need to lock around them. The patch is contributed by Colin Blake . r=wtc. Modified Files: configure configure.in prnetdb.c --- nsprpub/configure | 48 +++++++++++++++++++---------------- nsprpub/configure.in | 1 + nsprpub/pr/src/misc/prnetdb.c | 18 +++++++++++++ 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/nsprpub/configure b/nsprpub/configure index d88d6a1ea18..cf036d80fed 100755 --- a/nsprpub/configure +++ b/nsprpub/configure @@ -4145,6 +4145,10 @@ EOF cat >> confdefs.h <<\EOF #define VMS 1 +EOF + + cat >> confdefs.h <<\EOF +#define PR_GETIPNODE_NOT_THREADSAFE 1 EOF RESOLVE_LINK_SYMBOLS=1 @@ -4194,17 +4198,17 @@ EOF _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 -echo "configure:4198: checking for machine/builtins.h" >&5 +echo "configure:4202: checking for machine/builtins.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4208: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4212: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4715,12 +4719,12 @@ esac if test -z "$SKIP_LIBRARY_CHECKS"; then echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4719: checking for dlopen" >&5 +echo "configure:4723: checking for dlopen" >&5 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dlopen=yes" else @@ -4762,7 +4766,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4766: checking for dlopen in -ldl" >&5 +echo "configure:4770: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4770,7 +4774,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4809,13 +4813,13 @@ fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4813: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:4817: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -4833,7 +4837,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -4857,12 +4861,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4861: checking for $ac_func" >&5 +echo "configure:4865: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4924,7 +4928,7 @@ hpux*) if test -z "$GNU_CC"; then echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 -echo "configure:4928: checking for +Olit support" >&5 +echo "configure:4932: checking for +Olit support" >&5 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4958,7 +4962,7 @@ esac echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:4962: checking for pthread_create in -lpthreads" >&5 +echo "configure:4966: checking for pthread_create in -lpthreads" >&5 echo " #include void *foo(void *v) { return v; } @@ -4980,7 +4984,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:4984: checking for pthread_create in -lpthread" >&5 +echo "configure:4988: checking for pthread_create in -lpthread" >&5 echo " #include void *foo(void *v) { return v; } @@ -5002,7 +5006,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:5006: checking for pthread_create in -lc_r" >&5 +echo "configure:5010: checking for pthread_create in -lc_r" >&5 echo " #include void *foo(void *v) { return v; } @@ -5024,7 +5028,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:5028: checking for pthread_create in -lc" >&5 +echo "configure:5032: checking for pthread_create in -lc" >&5 echo " #include void *foo(void *v) { return v; } @@ -5176,7 +5180,7 @@ if test -n "$USE_PTHREADS"; then rm -f conftest* ac_cv_have_dash_pthread=no echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6 -echo "configure:5180: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5184: checking whether ${CC-cc} accepts -pthread" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then @@ -5199,7 +5203,7 @@ echo "configure:5180: checking whether ${CC-cc} accepts -pthread" >&5 ac_cv_have_dash_pthreads=no if test "$ac_cv_have_dash_pthread" = "no"; then echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 -echo "configure:5203: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5207: checking whether ${CC-cc} accepts -pthreads" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then diff --git a/nsprpub/configure.in b/nsprpub/configure.in index 51894a79c19..b0ef0821c2c 100644 --- a/nsprpub/configure.in +++ b/nsprpub/configure.in @@ -1501,6 +1501,7 @@ mips-sony-newsos*) *-openvms*) AC_DEFINE(XP_UNIX) AC_DEFINE(VMS) + AC_DEFINE(PR_GETIPNODE_NOT_THREADSAFE) RESOLVE_LINK_SYMBOLS=1 AR_FLAGS='c $@' MDCPUCFG_H=_openvms.cfg diff --git a/nsprpub/pr/src/misc/prnetdb.c b/nsprpub/pr/src/misc/prnetdb.c index c9206af799a..dc89b89137f 100644 --- a/nsprpub/pr/src/misc/prnetdb.c +++ b/nsprpub/pr/src/misc/prnetdb.c @@ -874,7 +874,12 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( #endif /* _PR_HAVE_GETHOSTBYNAME2 */ #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME) if (_pr_ipv6_is_present == PR_TRUE) + { +#ifdef PR_GETIPNODE_NOT_THREADSAFE + LOCK_DNS(); +#endif h = (*((_pr_getipnodebyname_t)_pr_getipnodebyname_fp))(name, md_af, tmp_flags, &error_num); + } else { LOCK_DNS(); @@ -934,8 +939,12 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( UNLOCK_DNS(); #endif /* _PR_HAVE_GETHOSTBYNAME2 */ #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME) +#ifdef PR_GETIPNODE_NOT_THREADSAFE + UNLOCK_DNS(); +#else if (_pr_ipv6_is_present == PR_FALSE) UNLOCK_DNS(); +#endif #else /* _PR_INET6 */ UNLOCK_DNS(); #endif /* _PR_INET6 */ @@ -1035,8 +1044,13 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( h = getipnodebyaddr(addr, addrlen, af, &error_num); #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE) if (_pr_ipv6_is_present == PR_TRUE) + { +#ifdef PR_GETIPNODE_NOT_THREADSAFE + LOCK_DNS(); +#endif h = (*((_pr_getipnodebyaddr_t)_pr_getipnodebyaddr_fp))(addr, addrlen, af, &error_num); + } else { LOCK_DNS(); @@ -1092,8 +1106,12 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( /* Must match the convoluted logic above for LOCK_DNS() */ #if defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6) #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE) +#ifdef PR_GETIPNODE_NOT_THREADSAFE + UNLOCK_DNS(); +#else if (_pr_ipv6_is_present == PR_FALSE) UNLOCK_DNS(); +#endif #else /* _PR_HAVE_GETIPNODEBYADDR */ UNLOCK_DNS(); #endif /* _PR_HAVE_GETIPNODEBYADDR */