From: Kurt Zeilenga Date: Thu, 28 Jan 1999 04:34:55 +0000 (+0000) Subject: Use -lldap_r instead of -lldap -lthread. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~687 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72ba4cfb715001d30a6e48a2d7012f060f29d684;p=openldap Use -lldap_r instead of -lldap -lthread. Likely broke things for non-posix threadings.... Update -lldap_r implementation to: remove attribute support hide thread detachment provide concurrency accessors provide initialization function fix gethostby{addr,name}_r codes (not coverred by HAVE_REENTRANT_FUNCTIONS) Update servers/libraries to use ldap_pvt_thread_ calls. Cleanup server codes (no #ifdef HAVE_PTHREAD_THIS or _THATs)! Removed -llthread --- diff --git a/configure b/configure index 9e6131d45c..d37e287782 100755 --- a/configure +++ b/configure @@ -4219,67 +4219,15 @@ fi fi if test $ac_cv_func_sched_yield = no -a \ $ac_cv_func_pthread_yield = no ; then - echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 -echo "configure:4224: checking for sched_yield in -lposix4" >&5 -ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lposix4 $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LTHREAD_LIBS="$LTHREAD_LIBS -lposix4" - cat >> confdefs.h <<\EOF -#define HAVE_SCHED_YIELD 1 -EOF - - ac_cv_func_sched_yield=yes -else - echo "$ac_t""no" 1>&6 -ac_cv_func_sched_yield=no -fi - - fi - if test $ac_cv_func_sched_yield = no -a \ - $ac_cv_func_pthread_yield = no ; then - echo "configure: warning: could not locate sched_yield() or pthread_yield()" 1>&2 - fi - - for ac_func in pthread_kill pthread_detach + for ac_func in thr_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4278: checking for $ac_func" >&5 +echo "configure:4226: 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; then +if { (eval echo configure:4254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4326,20 +4274,22 @@ else fi done + fi + if test $ac_cv_func_sched_yield = no -a \ + $ac_cv_func_pthread_yield = no -a \ + "$ac_cv_func_thr_yield" = no ; then + echo "configure: warning: could not locate sched_yield() or pthread_yield()" 1>&2 + fi - for ac_func in \ - pthread_attr_create pthread_attr_init \ - pthread_attr_destroy pthread_attr_delete \ - pthread_attr_setdetachstate pthread_attr_setdetach_np \ - + for ac_func in pthread_kill pthread_detach do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4338: checking for $ac_func" >&5 +echo "configure:4288: 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; then +if { (eval echo configure:4316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4387,18 +4337,24 @@ fi done + if test $ac_cv_func_pthread_detach = no ; then + { echo "configure: error: could not locate pthread_detach()" 1>&2; exit 1; } + fi + for ac_func in \ pthread_setconcurrency \ + pthread_getconcurrency \ thr_setconcurrency \ + thr_getconcurrency \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4397: checking for $ac_func" >&5 +echo "configure:4353: 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; then +if { (eval echo configure:4381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4447,7 +4403,7 @@ done echo $ac_n "checking if pthread_create() works""... $ac_c" 1>&6 -echo "configure:4451: checking if pthread_create() works" >&5 +echo "configure:4407: checking if pthread_create() works" >&5 if eval "test \"`echo '$''{'ol_cv_pthread_create_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4456,7 +4412,7 @@ else ol_cv_pthread_create_works=yes else cat > conftest.$ac_ext < @@ -4479,7 +4435,7 @@ int main(argc, argv) } EOF -if { (eval echo configure:4483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ol_cv_pthread_create_works=yes else @@ -4501,7 +4457,7 @@ fi if test $ol_with_yielding_select = auto ; then echo $ac_n "checking if select yields when using pthreads""... $ac_c" 1>&6 -echo "configure:4505: checking if select yields when using pthreads" >&5 +echo "configure:4461: checking if select yields when using pthreads" >&5 if eval "test \"`echo '$''{'ol_cv_pthread_select_yields'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4511,7 +4467,7 @@ else { echo "configure: error: crossing compiling: use --with-yielding_select=yes|no|manual" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -4583,7 +4539,7 @@ int main(argc, argv) exit(2); } EOF -if { (eval echo configure:4587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ol_cv_pthread_select_yields=no else @@ -4623,17 +4579,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4627: checking for $ac_hdr" >&5 +echo "configure:4583: checking for $ac_hdr" >&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:4637: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4593: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4663,12 +4619,12 @@ done ol_with_threads=found echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6 -echo "configure:4667: checking for cthread_fork" >&5 +echo "configure:4623: checking for cthread_fork" >&5 if eval "test \"`echo '$''{'ac_cv_func_cthread_fork'+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; then +if { (eval echo configure:4651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_cthread_fork=yes" else @@ -4713,7 +4669,7 @@ fi if test $ol_link_threads = no ; then echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6 -echo "configure:4717: checking for cthread_fork with -all_load" >&5 +echo "configure:4673: checking for cthread_fork with -all_load" >&5 if eval "test \"`echo '$''{'ol_cv_cthread_all_load'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4721,7 +4677,7 @@ else save_LIBS="$LIBS" LIBS="-all_load $LIBS" cat > conftest.$ac_ext < int main() { @@ -4730,7 +4686,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_cthread_all_load=yes else @@ -4775,17 +4731,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4779: checking for $ac_hdr" >&5 +echo "configure:4735: checking for $ac_hdr" >&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:4789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4813,7 +4769,7 @@ done if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:4817: checking for thr_create in -lthread" >&5 +echo "configure:4773: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4821,7 +4777,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4866,43 +4822,64 @@ EOF ol_with_yielding_select=yes fi - echo $ac_n "checking for misplaced posix thread in headers""... $ac_c" 1>&6 -echo "configure:4871: checking for misplaced posix thread in headers" >&5 -if eval "test \"`echo '$''{'ol_cv_header_misplaced_pthreads'+set}'`\" = set"; then + for ac_func in \ + thr_setconcurrency \ + thr_getconcurrency \ + +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4832: 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 < conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); -#include -typedef double pthread_t; - int main() { - pthread_t thread = 0.0; - +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + ; return 0; } EOF -if { (eval echo configure:4889: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* - ol_cv_header_misplaced_pthreads=no + eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - ol_cv_header_misplaced_pthreads=yes + eval "ac_cv_func_$ac_func=no" fi rm -f conftest* - fi -echo "$ac_t""$ol_cv_header_misplaced_pthreads" 1>&6 +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done - if test "$ol_cv_header_misplaced_pthreads" = yes ; then - { echo "configure: error: pthread types are misplaced, use --with-threads=posix" 1>&2; exit 1; }; - fi fi fi @@ -4910,17 +4887,17 @@ echo "$ac_t""$ol_cv_header_misplaced_pthreads" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4914: checking for $ac_hdr" >&5 +echo "configure:4891: checking for $ac_hdr" >&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:4924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4901: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -4948,7 +4925,7 @@ done if test $ac_cv_header_lwp_lwp_h = yes ; then echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6 -echo "configure:4952: checking for lwp_create in -llwp" >&5 +echo "configure:4929: checking for lwp_create in -llwp" >&5 ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4956,7 +4933,7 @@ else ac_save_LIBS="$LIBS" LIBS="-llwp $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5020,17 +4997,17 @@ if test $ol_with_threads = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5024: checking for $ac_hdr" >&5 +echo "configure:5001: checking for $ac_hdr" >&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:5034: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5011: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5059,12 +5036,12 @@ done for ac_func in sched_yield pthread_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5063: checking for $ac_func" >&5 +echo "configure:5040: 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; then +if { (eval echo configure:5068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5113,7 +5090,7 @@ done echo $ac_n "checking for LinuxThreads""... $ac_c" 1>&6 -echo "configure:5117: checking for LinuxThreads" >&5 +echo "configure:5094: checking for LinuxThreads" >&5 if eval "test \"`echo '$''{'ol_cv_linux_threads'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5134,17 +5111,17 @@ echo "$ac_t""$ol_cv_linux_threads" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5138: checking for $ac_hdr" >&5 +echo "configure:5115: checking for $ac_hdr" >&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:5148: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5125: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5174,17 +5151,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5178: checking for $ac_hdr" >&5 +echo "configure:5155: checking for $ac_hdr" >&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:5188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5214,17 +5191,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5218: checking for $ac_hdr" >&5 +echo "configure:5195: checking for $ac_hdr" >&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:5228: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5205: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5279,13 +5256,13 @@ EOF echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6 -echo "configure:5283: checking for thread specific errno" >&5 +echo "configure:5260: checking for thread specific errno" >&5 if eval "test \"`echo '$''{'ol_cv_errno_thread_specific'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5296,7 +5273,7 @@ int x = errno; ; return 0; } EOF -if { (eval echo configure:5300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_errno_thread_specific=yes else @@ -5329,44 +5306,6 @@ if test $ol_link_threads = no ; then ol_with_threads=no fi - echo $ac_n "checking for misplaced posix thread in headers""... $ac_c" 1>&6 -echo "configure:5334: checking for misplaced posix thread in headers" >&5 -if eval "test \"`echo '$''{'ol_cv_header_misplaced_pthreads'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - - cat > conftest.$ac_ext < -typedef double pthread_t; - -int main() { - - pthread_t thread = 0.0; - -; return 0; } -EOF -if { (eval echo configure:5352: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ol_cv_header_misplaced_pthreads=no -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ol_cv_header_misplaced_pthreads=yes -fi -rm -f conftest* - -fi - -echo "$ac_t""$ol_cv_header_misplaced_pthreads" 1>&6 - - if test "$ol_cv_header_misplaced_pthreads" = yes ; then - { echo "configure: error: pthread types are misplaced, use --with-threads=posix" 1>&2; exit 1; }; - fi - cat >> confdefs.h <<\EOF #define NO_THREADS 1 EOF @@ -5377,13 +5316,13 @@ fi ol_link_ldbm=no if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then echo $ac_n "checking for DB2 library""... $ac_c" 1>&6 -echo "configure:5381: checking for DB2 library" >&5 +echo "configure:5320: checking for DB2 library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6 -echo "configure:5387: checking for db_open in -ldb" >&5 +echo "configure:5326: checking for db_open in -ldb" >&5 ac_lib_var=`echo db'_'db_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5391,7 +5330,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5433,17 +5372,17 @@ for ac_hdr in db.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5437: checking for $ac_hdr" >&5 +echo "configure:5376: checking for $ac_hdr" >&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:5447: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5386: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5471,13 +5410,13 @@ done if test $ac_cv_header_db_h = yes ; then echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6 -echo "configure:5475: checking if db.h is DB2" >&5 +echo "configure:5414: checking if db.h is DB2" >&5 if eval "test \"`echo '$''{'ol_cv_header_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5509,7 +5448,7 @@ fi echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6 -echo "configure:5513: checking for Berkeley DB2" >&5 +echo "configure:5452: checking for Berkeley DB2" >&5 if eval "test \"`echo '$''{'ol_cv_berkeley_db2'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5555,18 +5494,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6 -echo "configure:5559: checking for Berkeley DB library" >&5 +echo "configure:5498: checking for Berkeley DB library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_db'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for dbopen""... $ac_c" 1>&6 -echo "configure:5565: checking for dbopen" >&5 +echo "configure:5504: checking for dbopen" >&5 if eval "test \"`echo '$''{'ac_cv_func_dbopen'+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; then +if { (eval echo configure:5532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_dbopen=yes" else @@ -5608,7 +5547,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6 -echo "configure:5612: checking for dbopen in -ldb" >&5 +echo "configure:5551: checking for dbopen in -ldb" >&5 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5616,7 +5555,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5662,17 +5601,17 @@ for ac_hdr in db_185.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5666: checking for $ac_hdr" >&5 +echo "configure:5605: checking for $ac_hdr" >&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:5676: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5615: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5708,7 +5647,7 @@ fi echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6 -echo "configure:5712: checking for Berkeley DB" >&5 +echo "configure:5651: checking for Berkeley DB" >&5 if eval "test \"`echo '$''{'ol_cv_berkeley_db'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5761,17 +5700,17 @@ if test $ol_with_ldbm_api = manual ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5765: checking for $ac_hdr" >&5 +echo "configure:5704: checking for $ac_hdr" >&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:5775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5714: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5806,18 +5745,18 @@ fi if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then echo $ac_n "checking for GDBM library""... $ac_c" 1>&6 -echo "configure:5810: checking for GDBM library" >&5 +echo "configure:5749: checking for GDBM library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_gdbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6 -echo "configure:5816: checking for gdbm_open" >&5 +echo "configure:5755: checking for gdbm_open" >&5 if eval "test \"`echo '$''{'ac_cv_func_gdbm_open'+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; then +if { (eval echo configure:5783: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_gdbm_open=yes" else @@ -5859,7 +5798,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6 -echo "configure:5863: checking for gdbm_open in -lgdbm" >&5 +echo "configure:5802: checking for gdbm_open in -lgdbm" >&5 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5867,7 +5806,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lgdbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5913,17 +5852,17 @@ echo "$ac_t""$ol_cv_lib_gdbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5917: checking for $ac_hdr" >&5 +echo "configure:5856: checking for $ac_hdr" >&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:5927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5866: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5950,7 +5889,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:5954: checking for db" >&5 +echo "configure:5893: checking for db" >&5 if eval "test \"`echo '$''{'ol_cv_gdbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5986,18 +5925,18 @@ if test $ol_with_ldbm_api = auto ; then echo "configure: warning: skipping automatic checking for NDBM, must be manually enabled." 1>&2 elif test $ol_with_ldbm_api = ndbm ; then echo $ac_n "checking for NDBM library""... $ac_c" 1>&6 -echo "configure:5990: checking for NDBM library" >&5 +echo "configure:5929: checking for NDBM library" >&5 if eval "test \"`echo '$''{'ol_cv_lib_ndbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ol_LIBS="$LIBS" echo $ac_n "checking for dbm_open""... $ac_c" 1>&6 -echo "configure:5996: checking for dbm_open" >&5 +echo "configure:5935: checking for dbm_open" >&5 if eval "test \"`echo '$''{'ac_cv_func_dbm_open'+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; then +if { (eval echo configure:5963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_dbm_open=yes" else @@ -6039,7 +5978,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6 -echo "configure:6043: checking for dbm_open in -lndbm" >&5 +echo "configure:5982: checking for dbm_open in -lndbm" >&5 ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6047,7 +5986,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lndbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6078,7 +6017,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6 -echo "configure:6082: checking for dbm_open in -ldbm" >&5 +echo "configure:6021: checking for dbm_open in -ldbm" >&5 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6086,7 +6025,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldbm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6134,17 +6073,17 @@ echo "$ac_t""$ol_cv_lib_ndbm" 1>&6 do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6138: checking for $ac_hdr" >&5 +echo "configure:6077: checking for $ac_hdr" >&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:6148: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -6171,7 +6110,7 @@ fi done echo $ac_n "checking for db""... $ac_c" 1>&6 -echo "configure:6175: checking for db" >&5 +echo "configure:6114: checking for db" >&5 if eval "test \"`echo '$''{'ol_cv_ndbm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6218,17 +6157,17 @@ if test $ol_enable_wrappers != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6222: checking for $ac_hdr" >&5 +echo "configure:6161: checking for $ac_hdr" >&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:6232: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6171: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -6259,7 +6198,7 @@ done have_wrappers=no else echo $ac_n "checking for main in -lwrap""... $ac_c" 1>&6 -echo "configure:6263: checking for main in -lwrap" >&5 +echo "configure:6202: checking for main in -lwrap" >&5 ac_lib_var=`echo wrap'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6267,14 +6206,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lwrap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6316,12 +6255,12 @@ fi if test $ol_enable_syslog != no ; then echo $ac_n "checking for openlog""... $ac_c" 1>&6 -echo "configure:6320: checking for openlog" >&5 +echo "configure:6259: checking for openlog" >&5 if eval "test \"`echo '$''{'ac_cv_func_openlog'+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; then +if { (eval echo configure:6287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_openlog=yes" else @@ -6374,17 +6313,17 @@ if test $ol_enable_dmalloc != no ; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6378: checking for $ac_hdr" >&5 +echo "configure:6317: checking for $ac_hdr" >&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:6388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6327: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -6411,7 +6350,7 @@ fi done echo $ac_n "checking for dmalloc_shutdown in -ldmalloc""... $ac_c" 1>&6 -echo "configure:6415: checking for dmalloc_shutdown in -ldmalloc" >&5 +echo "configure:6354: checking for dmalloc_shutdown in -ldmalloc" >&5 ac_lib_var=`echo dmalloc'_'dmalloc_shutdown | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6419,7 +6358,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldmalloc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6465,17 +6404,17 @@ for ac_hdr in termcap.h ncurses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6469: checking for $ac_hdr" >&5 +echo "configure:6408: checking for $ac_hdr" >&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:6479: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6418: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -6504,7 +6443,7 @@ done if test $ol_link_termcap = no ; then echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6 -echo "configure:6508: checking for tputs in -ltermcap" >&5 +echo "configure:6447: checking for tputs in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6512,7 +6451,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6556,7 +6495,7 @@ fi if test $ol_link_termcap = no ; then echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6 -echo "configure:6560: checking for initscr in -lncurses" >&5 +echo "configure:6499: checking for initscr in -lncurses" >&5 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6564,7 +6503,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6617,12 +6556,12 @@ fi # FreeBSD (and others) have crypt(3) in -lcrypt if test $ol_enable_crypt != no ; then echo $ac_n "checking for crypt""... $ac_c" 1>&6 -echo "configure:6621: checking for crypt" >&5 +echo "configure:6560: checking for crypt" >&5 if eval "test \"`echo '$''{'ac_cv_func_crypt'+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; then +if { (eval echo configure:6588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_crypt=yes" else @@ -6664,7 +6603,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:6668: checking for crypt in -lcrypt" >&5 +echo "configure:6607: checking for crypt in -lcrypt" >&5 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6672,7 +6611,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6727,12 +6666,12 @@ fi # FreeBSD (and others) have setproctitle(3) in -lutil if test $ol_enable_proctitle != no ; then echo $ac_n "checking for setproctitle""... $ac_c" 1>&6 -echo "configure:6731: checking for setproctitle" >&5 +echo "configure:6670: checking for setproctitle" >&5 if eval "test \"`echo '$''{'ac_cv_func_setproctitle'+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; then +if { (eval echo configure:6698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_setproctitle=yes" else @@ -6774,7 +6713,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6 -echo "configure:6778: checking for setproctitle in -lutil" >&5 +echo "configure:6717: checking for setproctitle in -lutil" >&5 ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6782,7 +6721,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lutil $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6828,12 +6767,12 @@ EOF fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:6832: checking for ANSI C header files" >&5 +echo "configure:6771: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -6841,7 +6780,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -6858,7 +6797,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -6876,7 +6815,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -6897,7 +6836,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -6908,7 +6847,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:6912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then : else @@ -6941,12 +6880,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:6945: checking for $ac_hdr that defines DIR" >&5 +echo "configure:6884: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -6954,7 +6893,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:6958: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6897: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -6979,7 +6918,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:6983: checking for opendir in -ldir" >&5 +echo "configure:6922: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6987,7 +6926,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7020,7 +6959,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:7024: checking for opendir in -lx" >&5 +echo "configure:6963: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7028,7 +6967,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7062,12 +7001,12 @@ fi fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:7066: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:7005: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7083,7 +7022,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:7087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7026: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -7104,12 +7043,12 @@ EOF fi echo $ac_n "checking POSIX termios""... $ac_c" 1>&6 -echo "configure:7108: checking POSIX termios" >&5 +echo "configure:7047: checking POSIX termios" >&5 if eval "test \"`echo '$''{'am_cv_sys_posix_termios'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7119,7 +7058,7 @@ int main() { tcgetattr(0, 0); ; return 0; } EOF -if { (eval echo configure:7123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* am_cv_sys_posix_termios=yes else @@ -7135,7 +7074,7 @@ echo "$ac_t""$am_cv_sys_posix_termios" 1>&6 echo $ac_n "checking whether use of TIOCGWINSZ requires sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:7139: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5 +echo "configure:7078: checking whether use of TIOCGWINSZ requires sys/ioctl.h" >&5 if eval "test \"`echo '$''{'am_cv_sys_tiocgwinsz_needs_sys_ioctl_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7144,7 +7083,7 @@ else gwinsz_in_termios_h=no if test $am_cv_sys_posix_termios = yes; then cat > conftest.$ac_ext < # include @@ -7164,7 +7103,7 @@ rm -f conftest* if test $gwinsz_in_termios_h = no; then cat > conftest.$ac_ext < # include @@ -7234,17 +7173,17 @@ for ac_hdr in \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:7238: checking for $ac_hdr" >&5 +echo "configure:7177: checking for $ac_hdr" >&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:7248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7187: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -7272,12 +7211,12 @@ done echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:7276: checking for uid_t in sys/types.h" >&5 +echo "configure:7215: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -7306,7 +7245,7 @@ EOF fi echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 -echo "configure:7310: checking type of array argument to getgroups" >&5 +echo "configure:7249: checking type of array argument to getgroups" >&5 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7314,7 +7253,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_type_getgroups=gid_t else @@ -7353,7 +7292,7 @@ fi if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -7376,12 +7315,12 @@ cat >> confdefs.h <&6 -echo "configure:7380: checking for mode_t" >&5 +echo "configure:7319: checking for mode_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -7409,12 +7348,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:7413: checking for off_t" >&5 +echo "configure:7352: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -7442,12 +7381,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:7446: checking for pid_t" >&5 +echo "configure:7385: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -7475,19 +7414,19 @@ EOF fi echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6 -echo "configure:7479: checking for ptrdiff_t" >&5 +echo "configure:7418: checking for ptrdiff_t" >&5 if eval "test \"`echo '$''{'am_cv_type_ptrdiff_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { ptrdiff_t p ; return 0; } EOF -if { (eval echo configure:7491: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7430: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_type_ptrdiff_t=yes else @@ -7508,12 +7447,12 @@ EOF fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:7512: checking return type of signal handlers" >&5 +echo "configure:7451: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7530,7 +7469,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:7534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7473: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -7549,19 +7488,19 @@ EOF echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6 -echo "configure:7553: checking for sig_atomic_t" >&5 +echo "configure:7492: checking for sig_atomic_t" >&5 if eval "test \"`echo '$''{'ol_cv_type_sig_atomic_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { sig_atomic_t atomic; ; return 0; } EOF -if { (eval echo configure:7565: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7504: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_type_sig_atomic_t=yes else @@ -7582,12 +7521,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:7586: checking for size_t" >&5 +echo "configure:7525: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -7615,12 +7554,12 @@ EOF fi echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6 -echo "configure:7619: checking for st_blksize in struct stat" >&5 +echo "configure:7558: checking for st_blksize in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7628,7 +7567,7 @@ int main() { struct stat s; s.st_blksize; ; return 0; } EOF -if { (eval echo configure:7632: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blksize=yes else @@ -7649,12 +7588,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:7653: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:7592: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7663,7 +7602,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:7667: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7606: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -7684,12 +7623,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:7688: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:7627: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -7697,7 +7636,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:7701: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7640: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -7720,7 +7659,7 @@ fi echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6 -echo "configure:7724: checking if toupper() requires islower()" >&5 +echo "configure:7663: checking if toupper() requires islower()" >&5 if eval "test \"`echo '$''{'ol_cv_c_upper_lower'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7729,7 +7668,7 @@ else ol_cv_c_upper_lower=safe else cat > conftest.$ac_ext < @@ -7741,7 +7680,7 @@ main() exit(1); } EOF -if { (eval echo configure:7745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7684: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ol_cv_c_upper_lower=no else @@ -7764,12 +7703,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:7768: checking for working const" >&5 +echo "configure:7707: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -7839,12 +7778,12 @@ EOF fi echo $ac_n "checking if compiler understands volatile""... $ac_c" 1>&6 -echo "configure:7843: checking if compiler understands volatile" >&5 +echo "configure:7782: checking if compiler understands volatile" >&5 if eval "test \"`echo '$''{'ol_cv_c_volatile'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7796: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_c_volatile=yes else @@ -7883,14 +7822,14 @@ EOF else echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:7887: checking whether byte ordering is bigendian" >&5 +echo "configure:7826: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -7901,11 +7840,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:7905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7844: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -7916,7 +7855,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:7920: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7859: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -7936,7 +7875,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -7973,7 +7912,7 @@ EOF fi echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:7977: checking size of short" >&5 +echo "configure:7916: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7981,7 +7920,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -7992,7 +7931,7 @@ main() exit(0); } EOF -if { (eval echo configure:7996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -8012,7 +7951,7 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:8016: checking size of int" >&5 +echo "configure:7955: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8020,7 +7959,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -8031,7 +7970,7 @@ main() exit(0); } EOF -if { (eval echo configure:8035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -8051,7 +7990,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:8055: checking size of long" >&5 +echo "configure:7994: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8059,7 +7998,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -8070,7 +8009,7 @@ main() exit(0); } EOF -if { (eval echo configure:8074: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -8092,7 +8031,7 @@ EOF fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:8096: checking for 8-bit clean memcmp" >&5 +echo "configure:8035: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8100,7 +8039,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -8128,12 +8067,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o" echo $ac_n "checking for strftime""... $ac_c" 1>&6 -echo "configure:8132: checking for strftime" >&5 +echo "configure:8071: checking for strftime" >&5 if eval "test \"`echo '$''{'ac_cv_func_strftime'+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; then +if { (eval echo configure:8099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_strftime=yes" else @@ -8178,7 +8117,7 @@ else echo "$ac_t""no" 1>&6 # strftime is in -lintl on SCO UNIX. echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6 -echo "configure:8182: checking for strftime in -lintl" >&5 +echo "configure:8121: checking for strftime in -lintl" >&5 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -8186,7 +8125,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:8140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -8224,12 +8163,12 @@ fi fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:8228: checking for vprintf" >&5 +echo "configure:8167: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+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; then +if { (eval echo configure:8195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -8276,12 +8215,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:8280: checking for _doprnt" >&5 +echo "configure:8219: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+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; then +if { (eval echo configure:8247: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -8333,12 +8272,12 @@ if test $ac_cv_func_vprintf = yes ; then for ac_func in vsnprintf vsprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8337: checking for $ac_func" >&5 +echo "configure:8276: 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; then +if { (eval echo configure:8304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8420,12 +8359,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8424: checking for $ac_func" >&5 +echo "configure:8363: 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; then +if { (eval echo configure:8391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8482,12 +8421,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8486: checking for $ac_func" >&5 +echo "configure:8425: 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; then +if { (eval echo configure:8453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8537,19 +8476,19 @@ done if test "$ac_cv_func_ctime_r" = yes ; then echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6 -echo "configure:8541: checking number of arguments of ctime_r" >&5 +echo "configure:8480: checking number of arguments of ctime_r" >&5 if eval "test \"`echo '$''{'ol_cv_func_ctime_r_nargs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { time_t ti; char *buffer; ctime_r(&ti,buffer,32); ; return 0; } EOF -if { (eval echo configure:8553: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs=3 else @@ -8561,7 +8500,7 @@ fi rm -f conftest* if test $ol_cv_func_ctime_r_nargs = 0 ; then cat > conftest.$ac_ext < int main() { @@ -8569,7 +8508,7 @@ time_t ti; char *buffer; ctime_r(&ti,buffer); ; return 0; } EOF -if { (eval echo configure:8573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8512: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_func_ctime_r_nargs=2 else @@ -8618,12 +8557,12 @@ fi for ac_func in getopt tempnam do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:8622: checking for $ac_func" >&5 +echo "configure:8561: 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; then +if { (eval echo configure:8589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8676,13 +8615,13 @@ done # Check Configuration echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6 -echo "configure:8680: checking declaration of sys_errlist" >&5 +echo "configure:8619: checking declaration of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -8692,7 +8631,7 @@ int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:8696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8635: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ol_cv_dcl_sys_errlist=yes else @@ -8713,20 +8652,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then EOF echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6 -echo "configure:8717: checking existence of sys_errlist" >&5 +echo "configure:8656: checking existence of sys_errlist" >&5 if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *c = (char *) *sys_errlist ; return 0; } EOF -if { (eval echo configure:8730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:8669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ol_cv_have_sys_errlist=yes else @@ -9017,7 +8956,6 @@ libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib. libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk \ libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk \ -libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk \ servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \ servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \ @@ -9174,7 +9112,6 @@ libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib. libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk \ libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk \ -libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk \ servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \ servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \ diff --git a/configure.in b/configure.in index 0dba55a18d..cfefc79769 100644 --- a/configure.in +++ b/configure.in @@ -618,30 +618,28 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ if test $ac_cv_func_sched_yield = no -a \ $ac_cv_func_pthread_yield = no ; then dnl Solaris has sched_yield() in -lposix4 - AC_CHECK_LIB(posix4, sched_yield, - [LTHREAD_LIBS="$LTHREAD_LIBS -lposix4" - AC_DEFINE(HAVE_SCHED_YIELD,1) - ac_cv_func_sched_yield=yes], - [ac_cv_func_sched_yield=no]) + dnl but we'll use thr_yield instead. + AC_CHECK_FUNCS(thr_yield) fi if test $ac_cv_func_sched_yield = no -a \ - $ac_cv_func_pthread_yield = no ; then + $ac_cv_func_pthread_yield = no -a \ + "$ac_cv_func_thr_yield" = no ; then AC_MSG_WARN([could not locate sched_yield() or pthread_yield()]) fi dnl Check functions for compatibility AC_CHECK_FUNCS(pthread_kill pthread_detach) - AC_CHECK_FUNCS( \ - pthread_attr_create pthread_attr_init \ - pthread_attr_destroy pthread_attr_delete \ - pthread_attr_setdetachstate pthread_attr_setdetach_np \ - ) + if test $ac_cv_func_pthread_detach = no ; then + AC_MSG_ERROR([could not locate pthread_detach()]) + fi dnl Check for setconcurreny functions AC_CHECK_FUNCS( \ pthread_setconcurrency \ + pthread_getconcurrency \ thr_setconcurrency \ + thr_getconcurrency \ ) AC_MSG_CHECKING([if pthread_create() works]) @@ -834,21 +832,11 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \ ol_with_yielding_select=yes fi - AC_CACHE_CHECK([for misplaced posix thread in headers], - [ol_cv_header_misplaced_pthreads], [ - AC_TRY_COMPILE([ -#include -typedef double pthread_t; - ], [ - pthread_t thread = 0.0; - ], - [ol_cv_header_misplaced_pthreads=no], - [ol_cv_header_misplaced_pthreads=yes]) - ]) - - if test "$ol_cv_header_misplaced_pthreads" = yes ; then - AC_MSG_ERROR([pthread types are misplaced, use --with-threads=posix]); - fi + dnl Check for setconcurreny functions + AC_CHECK_FUNCS( \ + thr_setconcurrency \ + thr_getconcurrency \ + ) fi fi @@ -983,22 +971,6 @@ if test $ol_link_threads = no ; then ol_with_threads=no fi - AC_CACHE_CHECK([for misplaced posix thread in headers], - [ol_cv_header_misplaced_pthreads], [ - AC_TRY_COMPILE([ -#include -typedef double pthread_t; - ], [ - pthread_t thread = 0.0; - ], - [ol_cv_header_misplaced_pthreads=no], - [ol_cv_header_misplaced_pthreads=yes]) - ]) - - if test "$ol_cv_header_misplaced_pthreads" = yes ; then - AC_MSG_ERROR([pthread types are misplaced, use --with-threads=posix]); - fi - AC_DEFINE(NO_THREADS,1) LTHREAD_LIBS="" fi @@ -1479,7 +1451,6 @@ libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib. libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk \ libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk \ -libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk \ libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk \ servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \ servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \ diff --git a/include/getopt-compat.h b/include/getopt-compat.h index a32e8b5b36..438eb53388 100644 --- a/include/getopt-compat.h +++ b/include/getopt-compat.h @@ -15,9 +15,13 @@ #include +LDAP_BEGIN_DECL + extern char *optarg; extern int optind, opterr, optopt; LDAP_F int getopt LDAP_P((int, char * const [], const char *)); +LDAP_END_DECL + #endif /* _GETOPT_COMPAT_H */ diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h index 224dc19138..a14a2a80a2 100644 --- a/include/ldap_pvt.h +++ b/include/ldap_pvt.h @@ -21,22 +21,22 @@ LDAP_BEGIN_DECL struct hostent; /* avoid pulling in */ -extern char *ldap_pvt_ctime( const time_t *tp, char *buf ); -extern int ldap_pvt_gethostbyname_a( +LDAP_F char *ldap_pvt_ctime LDAP_P(( const time_t *tp, char *buf )); +LDAP_F int ldap_pvt_gethostbyname_a LDAP_P(( const char *name, struct hostent *resbuf, char **buf, struct hostent **result, - int *herrno_ptr ); -extern int ldap_pvt_gethostbyaddr_a( + int *herrno_ptr )); +LDAP_F int ldap_pvt_gethostbyaddr_a LDAP_P(( const char *addr, int len, int type, struct hostent *resbuf, char **buf, struct hostent **result, - int *herrno_ptr ); -extern void ldap_pvt_init_utils( void ); + int *herrno_ptr )); +LDAP_F void ldap_pvt_init_utils LDAP_P(( void )); LDAP_END_DECL diff --git a/include/ldap_pvt_thread.h b/include/ldap_pvt_thread.h index a1ccea6f04..dd73e7fbfd 100644 --- a/include/ldap_pvt_thread.h +++ b/include/ldap_pvt_thread.h @@ -29,14 +29,8 @@ LDAP_BEGIN_DECL typedef pthread_t ldap_pvt_thread_t; -typedef pthread_attr_t ldap_pvt_thread_attr_t; typedef pthread_mutex_t ldap_pvt_thread_mutex_t; -typedef pthread_mutexattr_t ldap_pvt_thread_mutexattr_t; typedef pthread_cond_t ldap_pvt_thread_cond_t; -typedef pthread_condattr_t ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED -#define LDAP_PVT_THREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE #if defined( _POSIX_REENTRANT_FUNCTIONS ) || \ defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \ @@ -44,6 +38,16 @@ typedef pthread_condattr_t ldap_pvt_thread_condattr_t; #define HAVE_REENTRANT_FUNCTIONS 1 #endif +#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \ + defined( HAVE_THR_GETCONCURRENCY ) +#define HAVE_GETCONCURRENCY 1 +#endif + +#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \ + defined( HAVE_THR_SETCONCURRENCY ) +#define HAVE_SETCONCURRENCY 1 +#endif + LDAP_END_DECL #elif defined ( HAVE_MACH_CTHREADS ) @@ -58,23 +62,17 @@ LDAP_END_DECL LDAP_BEGIN_DECL typedef cthread_t ldap_pvt_thread_t; -typedef int ldap_pvt_thread_attr_t; typedef struct mutex ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_mutexattr_t; typedef struct condition ldap_pvt_thread_cond_t; -typedef int ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED 1 -#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 LDAP_END_DECL #elif defined( HAVE_THR ) -/************************************** - * * - * thread definitions for Solaris LWP * - * * - **************************************/ +/******************************************** + * * + * thread definitions for Solaris LWP (THR) * + * * + ********************************************/ #include #include @@ -82,17 +80,18 @@ LDAP_END_DECL LDAP_BEGIN_DECL typedef thread_t ldap_pvt_thread_t; -typedef int ldap_pvt_thread_attr_t; typedef mutex_t ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_mutexattr_t; typedef cond_t ldap_pvt_thread_cond_t; -typedef int ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED THR_DETACHED -#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 #define HAVE_REENTRANT_FUNCTIONS 1 +#ifdef HAVE_THR_GETCONCURRENCY +#define HAVE_GETCONCURRENCY 1 +#endif +#ifdef HAVE_THR_SETCONCURRENCY +#define HAVE_SETCONCURRENCY 1 +#endif + LDAP_END_DECL #elif defined( HAVE_LWP ) @@ -108,24 +107,15 @@ LDAP_END_DECL LDAP_BEGIN_DECL typedef thread_t ldap_pvt_thread_t; -typedef int ldap_pvt_thread_attr_t; typedef mon_t ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_mutexattr_t; struct lwpcv { int lcv_created; cv_t lcv_cv; }; typedef struct lwpcv ldap_pvt_thread_cond_t; -typedef int ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED 1 -#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 #define HAVE_REENTRANT_FUNCTIONS 1 -stkalign_t *ldap_pvt_thread_get_stack( int *stacknop ); -void ldap_pvt_thread_free_stack( int *stackno ); - LDAP_END_DECL #elif HAVE_NT_THREADS @@ -136,14 +126,8 @@ LDAP_END_DECL LDAP_BEGIN_DECL typedef HANDLE ldap_pvt_thread_t; -typedef int ldap_pvt_thread_attr_t; typedef HANDLE ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_mutexattr_t; typedef HANDLE ldap_pvt_thread_cond_t; -typedef int ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED 0 -#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 LDAP_END_DECL @@ -163,14 +147,8 @@ LDAP_BEGIN_DECL #endif typedef int ldap_pvt_thread_t; -typedef int ldap_pvt_thread_attr_t; typedef int ldap_pvt_thread_mutex_t; -typedef int ldap_pvt_thread_mutexattr_t; typedef int ldap_pvt_thread_cond_t; -typedef int ldap_pvt_thread_condattr_t; - -#define LDAP_PVT_THREAD_CREATE_DETACHED 0 -#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 LDAP_END_DECL @@ -178,22 +156,42 @@ LDAP_END_DECL #ifndef NO_THREADS # define HAVE_THREADS 1 + #endif LDAP_BEGIN_DECL +LDAP_F int +ldap_pvt_thread_initialize LDAP_P(( void )); + +LDAP_F unsigned int +ldap_pvt_thread_sleep LDAP_P(( unsigned int s )); + +#ifdef HAVE_GETCONCURRENCY +LDAP_F int +ldap_pvt_thread_getconcurrency LDAP_P(( void )); +#endif +#ifdef HAVE_SETCONCURRENCY +# ifndef LDAP_THREAD_CONCURRENCY + /* three concurrent threads should be enough */ +# define LDAP_THREAD_CONCURRENCY 3 +# endif +LDAP_F int +ldap_pvt_thread_setconcurrency LDAP_P(( int )); +#endif + LDAP_F int -ldap_pvt_thread_create LDAP_P(( ldap_pvt_thread_t * thread, - ldap_pvt_thread_attr_t *attr, - void *(*start_routine)( void *), - void *arg)); +ldap_pvt_thread_create LDAP_P(( + ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg)); LDAP_F void ldap_pvt_thread_exit LDAP_P(( void *retval )); LDAP_F int -ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, - void **thread_return )); +ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status )); LDAP_F int ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo )); @@ -202,18 +200,7 @@ LDAP_F int ldap_pvt_thread_yield LDAP_P(( void )); LDAP_F int -ldap_pvt_thread_attr_init LDAP_P(( ldap_pvt_thread_attr_t *attr )); - -LDAP_F int -ldap_pvt_thread_attr_destroy LDAP_P(( ldap_pvt_thread_attr_t *attr )); - -LDAP_F int -ldap_pvt_thread_attr_setdetachstate LDAP_P(( ldap_pvt_thread_attr_t *attr, - int dstate )); - -LDAP_F int -ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_condattr_t *attr )); +ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond )); LDAP_F int ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond )); @@ -222,12 +209,12 @@ LDAP_F int ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond )); LDAP_F int -ldap_pvt_thread_cond_wait LDAP_P(( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex )); +ldap_pvt_thread_cond_wait LDAP_P(( + ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex )); LDAP_F int -ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex, - ldap_pvt_thread_mutexattr_t *attr )); +ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); LDAP_F int ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); @@ -235,21 +222,24 @@ ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); LDAP_F int ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); +LDAP_F int +ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); + LDAP_F int ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); typedef struct ldap_pvt_thread_rdwr_var { - int readers_reading; - int writer_writing; - ldap_pvt_thread_mutex_t mutex; - ldap_pvt_thread_cond_t lock_free; + int lt_readers_reading; + int lt_writer_writing; + ldap_pvt_thread_mutex_t lt_mutex; + ldap_pvt_thread_cond_t lt_lock_free; } ldap_pvt_thread_rdwr_t; -typedef void * ldap_pvt_thread_rdwrattr_t; +#define LDAP_PVT_THREAD_CREATE_DETACHED 1 +#define LDAP_PVT_THREAD_CREATE_JOINABLE 0 LDAP_F int -ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp, - ldap_pvt_thread_rdwrattr_t *attrp)); +ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); LDAP_F int ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); LDAP_F int diff --git a/include/ldbm.h b/include/ldbm.h index dfdb4ea06e..3f55a6ffea 100644 --- a/include/ldbm.h +++ b/include/ldbm.h @@ -37,12 +37,16 @@ #endif +LDAP_BEGIN_DECL + typedef DBT Datum; #define dsize size #define dptr data typedef DB *LDBM; +LDAP_END_DECL + #define DB_TYPE DB_BTREE /* for ldbm_open */ @@ -90,12 +94,16 @@ typedef DB *LDBM; # endif #endif +LDAP_BEGIN_DECL + typedef DBT Datum; #define dsize size #define dptr data typedef DB *LDBM; +LDAP_END_DECL + #define DB_TYPE DB_HASH /* for ldbm_open */ @@ -129,12 +137,16 @@ typedef DB *LDBM; #include +LDAP_BEGIN_DECL + typedef datum Datum; typedef GDBM_FILE LDBM; extern gdbm_error gdbm_errno; +LDAP_END_DECL + /* for ldbm_open */ #define LDBM_READER GDBM_READER #define LDBM_WRITER GDBM_WRITER @@ -164,10 +176,14 @@ extern gdbm_error gdbm_errno; #include #endif +LDAP_BEGIN_DECL + typedef datum Datum; typedef DBM *LDBM; +LDAP_END_DECL + /* for ldbm_open */ #define LDBM_READER O_RDONLY #define LDBM_WRITER O_WRONLY diff --git a/include/ldif.h b/include/ldif.h index d42dfaec86..139d6ba749 100644 --- a/include/ldif.h +++ b/include/ldif.h @@ -47,10 +47,17 @@ extern int ldif_debug; ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 )) -int ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen)); -char * ldif_getline LDAP_P(( char **next )); -void ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen )); -char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen )); +LDAP_F int +ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen)); + +LDAP_F char * +ldif_getline LDAP_P(( char **next )); + +LDAP_F void +ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen )); + +LDAP_F char +*ldif_type_and_value LDAP_P(( char *type, char *val, int vlen )); LDAP_END_DECL diff --git a/include/lthread.h b/include/lthread.h deleted file mode 100644 index b6ba12b3b6..0000000000 --- a/include/lthread.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted only - * as authorized by the OpenLDAP Public License. A copy of this - * license is available at http://www.OpenLDAP.org/license.html or - * in file LICENSE in the top-level directory of the distribution. - */ -/* lthread.h - ldap threads header file */ - -#ifndef _LTHREAD_H -#define _LTHREAD_H - -#include "portable.h" - -#if defined( HAVE_PTHREADS ) -/********************************** - * * - * definitions for POSIX Threads * - * * - **********************************/ - -#include -#ifdef HAVE_SCHED_H -#include -#endif - -LDAP_BEGIN_DECL - -#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \ - defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \ - defined( _POSIX_THREADSAFE_FUNCTIONS ) -#define HAVE_REENTRANT_FUNCTIONS 1 -#endif - -#if !defined( HAVE_PTHREAD_ATTR_INIT ) && \ - defined( HAVE_PTHREAD_ATTR_CREATE ) -#define pthread_attr_init( a ) pthread_attr_create( a ) -#endif - -#if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \ - defined( HAVE_PTHREAD_ATTR_DELETE ) -#define pthread_attr_destroy( a ) pthread_attr_delete( a ) -#endif - -#if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \ - defined( HAVE_PTHREAD_ATTR_SETDETACH_NP ) -#define pthread_attr_setdetachstate( a, b ) \ - pthread_attr_setdetach_np( a, b ) -#endif - -#ifndef HAVE_PTHREAD_KILL -/* missing pthread_kill(), define prototype */ -LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig )); -#endif - -#ifndef HAVE_PTHREADS_D4 -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -#ifdef HAVE_SCHED_YIELD -#define pthread_yield sched_yield -#endif -#endif - -LDAP_END_DECL - -#elif defined ( HAVE_MACH_CTHREADS ) -/********************************** - * * - * definitions for Mach CThreads * - * * - **********************************/ - -#include - -LDAP_BEGIN_DECL - -typedef cthread_fn_t VFP; -typedef int pthread_attr_t; -typedef cthread_t pthread_t; - -/* default attr states */ -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -/* thread state - joinable or not */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 1 -/* thread scope - who is in scheduling pool */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM 1 - -/* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef struct mutex pthread_mutex_t; - -/* mutex and condition variable scope - process or system */ -#define PTHREAD_SHARE_PRIVATE 0 -#define PTHREAD_SHARE_PROCESS 1 - -/* condition variable attributes and condition variable type */ -typedef int pthread_condattr_t; -typedef struct condition pthread_cond_t; - -LDAP_END_DECL - -#elif defined( HAVE_THR ) -/************************************** - * * - * thread definitions for Solaris LWP * - * * - **************************************/ - -#include -#include - -LDAP_BEGIN_DECL - -#define HAVE_REENTRANT_FUNCTIONS 1 - -typedef void *(*VFP)(); - -/* default attr states */ -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -/* thread state - joinable or not */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED THR_DETACHED -/* thread scope - who is in scheduling pool */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM THR_BOUND -/* mutex and condition variable scope - process or system */ -#define PTHREAD_SHARE_PRIVATE USYNC_THREAD -#define PTHREAD_SHARE_PROCESS USYNC_PROCESS - -/* thread attributes and thread type */ -typedef int pthread_attr_t; -typedef thread_t pthread_t; - -/* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef mutex_t pthread_mutex_t; - -/* condition variable attributes and condition variable type */ -typedef int pthread_condattr_t; -typedef cond_t pthread_cond_t; - -LDAP_END_DECL - -#elif defined( HAVE_LWP ) -/************************************* - * * - * thread definitions for SunOS LWP * - * * - *************************************/ - -#include -#include - -LDAP_BEGIN_DECL - -#define HAVE_REENTRANT_FUNCTIONS 1 - -stkalign_t *get_stack( int *stacknop ); -void free_stack( int *stackno ); - -typedef void *(*VFP)(); - -/* thread attributes and thread type */ -typedef int pthread_attr_t; -typedef thread_t pthread_t; - -/* default attr states */ -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -/* thread state - joinable or not */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 1 -/* thread scope - who is in scheduling pool */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM 1 - -/* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef mon_t pthread_mutex_t; - -/* mutex and condition variable scope - process or system */ -#define PTHREAD_SHARE_PRIVATE 0 -#define PTHREAD_SHARE_PROCESS 1 - -/* condition variable attributes and condition variable type */ -typedef int pthread_condattr_t; -typedef struct ldap_int_thread_cv { - int lcv_created; - cv_t lcv_cv; -} pthread_cond_t; - -LDAP_END_DECL - -#elif HAVE_NT_THREADS - -#include -#include - -typedef void (*VFP)(void*); - -/* thread attributes and thread type */ -typedef int pthread_attr_t; -typedef HANDLE pthread_t; - -/* default attr states */ -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -/* thread state - joinable or not */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 0 -/* thread scope - who is in scheduling pool */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM 0 - -/* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef HANDLE pthread_mutex_t; - -/* mutex and condition variable scope - process or system */ -#define PTHREAD_SHARE_PRIVATE USYNC_THREAD -#define PTHREAD_SHARE_PROCESS USYNC_PROCESS - -/* condition variable attributes and condition variable type */ -typedef int pthread_condattr_t; -typedef HANDLE pthread_cond_t; -typedef int any_t; - - -#else - -/*********************************** - * * - * thread definitions for no * - * underlying library support * - * * - ***********************************/ - -LDAP_BEGIN_DECL - -#ifndef NO_THREADS -#define NO_THREADS 1 -#endif - -typedef void *(*VFP)(); - -/* thread attributes and thread type */ -typedef int pthread_attr_t; -typedef int pthread_t; - -/* default attr states */ -#define pthread_mutexattr_default NULL -#define pthread_condattr_default NULL - -/* thread state - joinable or not */ -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 0 -/* thread scope - who is in scheduling pool */ -#define PTHREAD_SCOPE_PROCESS 0 -#define PTHREAD_SCOPE_SYSTEM 0 - -/* mutex attributes and mutex type */ -typedef int pthread_mutexattr_t; -typedef int pthread_mutex_t; - -/* mutex and condition variable scope - process or system */ -#define PTHREAD_SHARE_PRIVATE 0 -#define PTHREAD_SHARE_PROCESS 0 - -/* condition variable attributes and condition variable type */ -typedef int pthread_condattr_t; -typedef int pthread_cond_t; - -LDAP_END_DECL - -#endif /* no threads support */ - -#ifndef NO_THREADS -# define HAVE_THREADS 1 -#endif - -#endif /* _LTHREAD_H */ diff --git a/include/lthread_rdwr.h b/include/lthread_rdwr.h deleted file mode 100644 index c09a7c5523..0000000000 --- a/include/lthread_rdwr.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted only - * as authorized by the OpenLDAP Public License. A copy of this - * license is available at http://www.OpenLDAP.org/license.html or - * in file LICENSE in the top-level directory of the distribution. - */ - -#ifndef _LTHREAD_RDWR_H -#define _LTHREAD_RDWR_H 1 - -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * - * Include file for reader/writer locks - * - */ - -#include - -LDAP_BEGIN_DECL - -typedef struct ldap_pvt_thread_rdwr_var { - int readers_reading; - int writer_writing; - pthread_mutex_t mutex; - pthread_cond_t lock_free; -} pthread_rdwr_t; - -typedef void * pthread_rdwrattr_t; - -#define pthread_rdwrattr_default NULL; - -LDAP_F int pthread_rdwr_init_np LDAP_P((pthread_rdwr_t *rdwrp, pthread_rdwrattr_t *attrp)); -LDAP_F int pthread_rdwr_rlock_np LDAP_P((pthread_rdwr_t *rdwrp)); -LDAP_F int pthread_rdwr_runlock_np LDAP_P((pthread_rdwr_t *rdwrp)); -LDAP_F int pthread_rdwr_wlock_np LDAP_P((pthread_rdwr_t *rdwrp)); -LDAP_F int pthread_rdwr_wunlock_np LDAP_P((pthread_rdwr_t *rdwrp)); - -#ifdef LDAP_DEBUG -LDAP_F int pthread_rdwr_rchk_np LDAP_P((pthread_rdwr_t *rdwrp)); -LDAP_F int pthread_rdwr_wchk_np LDAP_P((pthread_rdwr_t *rdwrp)); -LDAP_F int pthread_rdwr_rwchk_np LDAP_P((pthread_rdwr_t *rdwrp)); -#endif /* LDAP_DEBUG */ - -LDAP_END_DECL - -#endif /* _LTHREAD_RDWR_H */ diff --git a/include/portable.h.in b/include/portable.h.in index 0326fd6dea..f046da2113 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -331,27 +331,12 @@ /* Define if you have the mkstemp function. */ #undef HAVE_MKSTEMP -/* Define if you have the pthread_attr_create function. */ -#undef HAVE_PTHREAD_ATTR_CREATE - -/* Define if you have the pthread_attr_delete function. */ -#undef HAVE_PTHREAD_ATTR_DELETE - -/* Define if you have the pthread_attr_destroy function. */ -#undef HAVE_PTHREAD_ATTR_DESTROY - -/* Define if you have the pthread_attr_init function. */ -#undef HAVE_PTHREAD_ATTR_INIT - -/* Define if you have the pthread_attr_setdetach_np function. */ -#undef HAVE_PTHREAD_ATTR_SETDETACH_NP - -/* Define if you have the pthread_attr_setdetachstate function. */ -#undef HAVE_PTHREAD_ATTR_SETDETACHSTATE - /* Define if you have the pthread_detach function. */ #undef HAVE_PTHREAD_DETACH +/* Define if you have the pthread_getconcurrency function. */ +#undef HAVE_PTHREAD_GETCONCURRENCY + /* Define if you have the pthread_kill function. */ #undef HAVE_PTHREAD_KILL @@ -427,9 +412,15 @@ /* Define if you have the tempnam function. */ #undef HAVE_TEMPNAM +/* Define if you have the thr_getconcurrency function. */ +#undef HAVE_THR_GETCONCURRENCY + /* Define if you have the thr_setconcurrency function. */ #undef HAVE_THR_SETCONCURRENCY +/* Define if you have the thr_yield function. */ +#undef HAVE_THR_YIELD + /* Define if you have the vsnprintf function. */ #undef HAVE_VSNPRINTF diff --git a/libraries/Makefile.in b/libraries/Makefile.in index 713ffc0e97..7ffb1b9bfa 100644 --- a/libraries/Makefile.in +++ b/libraries/Makefile.in @@ -3,6 +3,5 @@ ## ## Libraries Makefile for OpenLDAP -SUBDIRS= liblutil libldif liblber libldap libavl libldbm \ - liblthread # libldap_r +SUBDIRS= liblutil libldif liblber libldap libavl libldbm libldap_r diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index 54d9d814e8..bd034a2a3f 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -32,35 +32,30 @@ #if defined( LDAP_R_COMPILE ) # include -# if !defined( HAVE_REENTRANT_FUNCTIONS ) -# if !defined( HAVE_CTIME_R ) -# define LDAP_INT_CTIME_MUTEX 1 -# endif -# if !defined( HAVE_GETHOSTBYNAME_R ) -# define LDAP_INT_GETHOSTBYNAME_MUTEX 1 -# endif -# if !defined( HAVE_GETHOSTBYADDR_R ) -# define LDAP_INT_GETHOSTBYADDR_MUTEX 1 -# endif -# endif /* defined( HAVE_REENTRANT_FUNCTIONS ) */ - -#if defined( LDAP_INT_CTIME_MUTEX ) -static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex; -#endif -#if defined( LDAP_INT_GETHOSTBYNAME_MUTEX ) -static ldap_pvt_thread_mutex_t ldap_int_gethostbyname_mutex; -#endif -#if defined( LDAP_INT_GETHOSTBYADDR_MUTEX ) -static ldap_pvt_thread_mutex_t ldap_int_gethostbyaddr_mutex; +#else +# undef HAVE_REENTRANT_FUNCTIONS #endif -#else /* LDAP_R_COMPILE */ -#undef HAVE_REENTRANT_FUNCTIONS + +#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \ + && defined( CTIME_R_NARGS ) +# define USE_CTIME_R #endif +#ifdef LDAP_COMPILING_R +# ifndef USE_CTIME_R + static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex; +# endif +# ifndef HAVE_GETHOSTBYNAME_R + static ldap_pvt_thread_mutex_t ldap_int_gethostbyname_mutex; +# endif +# ifndef HAVE_GETHOSTBYADDR_R + static ldap_pvt_thread_mutex_t ldap_int_gethostbyaddr_mutex; +# endif +#endif /* LDAP_R_COMPILE */ + char *ldap_pvt_ctime( const time_t *tp, char *buf ) { -#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \ - && defined( CTIME_R_NARGS ) +#ifdef USE_CTIME_R # if (CTIME_R_NARGS > 3) || (CTIME_R_NARGS < 2) choke me! nargs should have 2 or 3 # elif CTIME_R_NARGS > 2 @@ -68,14 +63,15 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf ) # else return ctime_r(tp,buf); # endif + #else -# if defined( LDAP_INT_CTIME_MUTEX ) +# ifdef LDAP_COMPILNG_R ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex ); -# endif +# endif memcpy( buf, ctime(tp), 26 ); -# if defined( LDAP_INT_CTIME_MUTEX ) +# ifdef LDAP_COMPILNG_R ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex ); -# endif +# endif return buf; #endif } @@ -93,7 +89,7 @@ int ldap_pvt_gethostbyname_a( struct hostent **result, int *herrno_ptr ) { -#if defined( HAVE_GETHOSTBYNAME_R ) || defined( HAVE_REENTRANT_FUNCTIONS ) +#if defined( HAVE_GETHOSTBYNAME_R ) # define NEED_SAFE_REALLOC 1 int r=-1; int buflen=BUFSTART; @@ -115,7 +111,7 @@ int ldap_pvt_gethostbyname_a( return r; } return -1; -#elif defined( LDAP_INT_GETHOSTBYNAME_MUTEX ) +#elif defined( LDAP_COMPILING_R ) # define NEED_COPY_HOSTENT struct hostent *he; int retval; @@ -160,7 +156,7 @@ int ldap_pvt_gethostbyaddr_a( struct hostent **result, int *herrno_ptr ) { -#if defined( HAVE_GETHOSTBYADDR_R ) || defined( HAVE_REENTRANT_FUNCTIONS ) +#if defined( HAVE_GETHOSTBYADDR_R ) # undef NEED_SAFE_REALLOC # define NEED_SAFE_REALLOC int r=-1; @@ -184,7 +180,7 @@ int ldap_pvt_gethostbyaddr_a( return r; } return -1; -#elif defined( LDAP_INT_GETHOSTBYADDR_MUTEX ) +#elif defined( LDAP_COMPILING_R ) # undef NEED_COPY_HOSTENT # define NEED_COPY_HOSTENT struct hostent *he; @@ -227,18 +223,23 @@ void ldap_pvt_init_utils( void ) if (done) return; done=1; -#if defined( LDAP_INT_CTIME_MUTEX ) + +#ifdef LDAP_COMPILING_R + +#if !defined( USE_CTIME_R ) && !defined( HAVE_REENTRANT_FUNCTIONS ) ldap_pvt_thread_mutex_init( &ldap_int_ctime_mutex, NULL ); -#endif -#if defined( LDAP_INT_GETHOSTBYNAME_MUTEX ) +#endif + +#if !defined( HAVE_GETHOSTBYNAME_R ) ldap_pvt_thread_mutex_init( &ldap_int_gethostbyname_mutex, NULL ); #endif -#if defined( LDAP_INT_GETHOSTBYADDR_MUTEX ) + +#if !defined( HAVE_GETHOSTBYADDR_R ) ldap_pvt_thread_mutex_init( &ldap_int_gethostbyaddr_mutex, NULL ); #endif -#if defined( LDAP_R_COMPILE ) + /* call other module init functions here... */ -#endif +#endif } #if defined( NEED_COPY_HOSTENT ) diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index 7a6cd137ec..4254889dc8 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -14,28 +14,28 @@ XXSRCS = apitest.c test.c tmpltest.c \ free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \ getdn.c getentry.c getattr.c getvalues.c addentry.c \ request.c getdxbyname.c os-ip.c url.c charset.c \ - init.c options.c string.c util-int.c + init.c options.c print.c string.c util-int.c SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \ - thr_stub.c rdwr.c + thr_sleep.c thr_stub.c rdwr.c OBJS = bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \ getfilter.lo sbind.lo kbind.lo unbind.lo friendly.lo cldap.lo \ free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \ getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \ request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \ - init.lo options.lo string.lo util-int.lo \ + init.lo options.lo print.lo string.lo util-int.lo \ thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \ - thr_stub.lo rdwr.lo + thr_sleep.lo thr_stub.lo rdwr.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries XDEFS = -DLDAP_R_COMPILE -I$(XXDIR) -XLIBS = -lldap_r -llber -llthread -llutil +XLIBS = -lldap_r -llber XXLIBS = $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) -.links : FORCE +.links : @for i in $(XXSRCS); do \ $(RM) $$i ; \ $(LN_S) $(XXDIR)/$$i . ; \ diff --git a/libraries/libldap_r/rdwr.c b/libraries/libldap_r/rdwr.c index 5e641438b9..1d43efc075 100644 --- a/libraries/libldap_r/rdwr.c +++ b/libraries/libldap_r/rdwr.c @@ -25,67 +25,66 @@ #include "ldap_pvt_thread.h" int -ldap_pvt_thread_rdwr_init(ldap_pvt_thread_rdwr_t *rdwrp, - ldap_pvt_thread_rdwrattr_t *attrp) +ldap_pvt_thread_rdwr_init(ldap_pvt_thread_rdwr_t *rdwrp ) { - rdwrp->readers_reading = 0; - rdwrp->writer_writing = 0; - ldap_pvt_thread_mutex_init(&(rdwrp->mutex), NULL ); - ldap_pvt_thread_cond_init(&(rdwrp->lock_free), NULL ); + rdwrp->lt_readers_reading = 0; + rdwrp->lt_writer_writing = 0; + ldap_pvt_thread_mutex_init(&(rdwrp->lt_mutex) ); + ldap_pvt_thread_cond_init(&(rdwrp->lt_lock_free) ); return 0; } int ldap_pvt_thread_rdwr_rlock(ldap_pvt_thread_rdwr_t *rdwrp){ - ldap_pvt_thread_mutex_lock(&(rdwrp->mutex)); - while(rdwrp->writer_writing) { - ldap_pvt_thread_cond_wait(&(rdwrp->lock_free), - &(rdwrp->mutex)); + ldap_pvt_thread_mutex_lock(&(rdwrp->lt_mutex)); + while(rdwrp->lt_writer_writing) { + ldap_pvt_thread_cond_wait(&(rdwrp->lt_lock_free), + &(rdwrp->lt_mutex)); } - rdwrp->readers_reading++; - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + rdwrp->lt_readers_reading++; + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return 0; } int ldap_pvt_thread_rdwr_runlock(ldap_pvt_thread_rdwr_t *rdwrp) { - ldap_pvt_thread_mutex_lock(&(rdwrp->mutex)); - if (rdwrp->readers_reading == 0) { - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + ldap_pvt_thread_mutex_lock(&(rdwrp->lt_mutex)); + if (rdwrp->lt_readers_reading == 0) { + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return -1; } else { - rdwrp->readers_reading--; - if (rdwrp->readers_reading == 0) { - ldap_pvt_thread_cond_signal(&(rdwrp->lock_free)); + rdwrp->lt_readers_reading--; + if (rdwrp->lt_readers_reading == 0) { + ldap_pvt_thread_cond_signal(&(rdwrp->lt_lock_free)); } - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return 0; } } int ldap_pvt_thread_rdwr_wlock(ldap_pvt_thread_rdwr_t *rdwrp) { - ldap_pvt_thread_mutex_lock(&(rdwrp->mutex)); - while(rdwrp->writer_writing || rdwrp->readers_reading) { - ldap_pvt_thread_cond_wait(&(rdwrp->lock_free), - &(rdwrp->mutex)); + ldap_pvt_thread_mutex_lock(&(rdwrp->lt_mutex)); + while(rdwrp->lt_writer_writing || rdwrp->lt_readers_reading) { + ldap_pvt_thread_cond_wait(&(rdwrp->lt_lock_free), + &(rdwrp->lt_mutex)); } - rdwrp->writer_writing++; - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + rdwrp->lt_writer_writing++; + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return 0; } int ldap_pvt_thread_rdwr_wunlock(ldap_pvt_thread_rdwr_t *rdwrp) { - ldap_pvt_thread_mutex_lock(&(rdwrp->mutex)); - if (rdwrp->writer_writing == 0) { - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + ldap_pvt_thread_mutex_lock(&(rdwrp->lt_mutex)); + if (rdwrp->lt_writer_writing == 0) { + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return -1; } else { - rdwrp->writer_writing = 0; - ldap_pvt_thread_cond_broadcast(&(rdwrp->lock_free)); - ldap_pvt_thread_mutex_unlock(&(rdwrp->mutex)); + rdwrp->lt_writer_writing = 0; + ldap_pvt_thread_cond_broadcast(&(rdwrp->lt_lock_free)); + ldap_pvt_thread_mutex_unlock(&(rdwrp->lt_mutex)); return 0; } } @@ -104,17 +103,17 @@ int ldap_pvt_thread_rdwr_wunlock(ldap_pvt_thread_rdwr_t *rdwrp) int ldap_pvt_thread_rdwr_rchk(ldap_pvt_thread_rdwr_t *rdwrp) { - return(rdwrp->readers_reading!=0); + return(rdwrp->lt_readers_reading!=0); } int ldap_pvt_thread_rdwr_wchk(ldap_pvt_thread_rdwr_t *rdwrp) { - return(rdwrp->writer_writing!=0); + return(rdwrp->lt_writer_writing!=0); } int ldap_pvt_thread_rdwr_rwchk(ldap_pvt_thread_rdwr_t *rdwrp) { - return(ldap_pvt_thread_rdwr_rchk_np(rdwrp) || - ldap_pvt_thread_rdwr_wchk_np(rdwrp)); + return(ldap_pvt_thread_rdwr_rchk(rdwrp) || + ldap_pvt_thread_rdwr_wchk(rdwrp)); } #endif /* LDAP_DEBUG */ diff --git a/libraries/libldap_r/thr_cthreads.c b/libraries/libldap_r/thr_cthreads.c index ecffe40e60..d69f029bfb 100644 --- a/libraries/libldap_r/thr_cthreads.c +++ b/libraries/libldap_r/thr_cthreads.c @@ -22,10 +22,16 @@ * * ***********************************************************************/ +int +ldap_pvt_thread_initialize( void ) +{ + return 0; +} + int ldap_pvt_thread_create( ldap_pvt_thread_t * thread, - ldap_pvt_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) + int detach, + void *(*start_routine)( void *), void *arg) { *thread = cthread_fork( (cthread_fn_t) start_routine, arg); return ( *thread == NULL ? -1 : 0 ); @@ -63,28 +69,7 @@ ldap_pvt_thread_yield( void ) } int -ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr ) -{ - return( 0 ); -} - -int -ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate ) -{ - *attr = dstate; - return( 0 ); -} - -int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_condattr_t *attr ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { condition_init( cond ); return( 0 ); @@ -113,8 +98,7 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex, - ldap_pvt_thread_mutexattr_t *attr ) +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { mutex_init( mutex ); mutex->name = NULL; diff --git a/libraries/libldap_r/thr_lwp.c b/libraries/libldap_r/thr_lwp.c index a699870134..f66a93019c 100644 --- a/libraries/libldap_r/thr_lwp.c +++ b/libraries/libldap_r/thr_lwp.c @@ -40,6 +40,24 @@ #define MAX_STACK 51200 #define MAX_THREADS 20 +/* + * Initialize LWP by spinning of a schedular + */ +int +ldap_pvt_thread_initialize( void ) +{ + thread_t tid; + stkalign_t *stack; + int stackno; + + if (( stack = get_stack( &stackno )) == NULL ) { + return -1; + } + + lwp_create( &tid, lwp_scheduler, MINPRIO, 0, stack, 1, stackno ); + return 0; +} + struct stackinfo { int stk_inuse; stkalign_t *stk_stack; @@ -101,8 +119,9 @@ lwp_create_stack( void *(*func)(), void *arg, int stackno ) int ldap_pvt_thread_create( ldap_pvt_thread_t * thread, - ldap_pvt_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) + int detach, + void *(*start_routine)( void *), + void *arg) { stkalign_t *stack; int stackno; @@ -141,35 +160,7 @@ ldap_pvt_thread_yield( void ) } int -ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr ) -{ - return( 0 ); -} - -int -ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate ) -{ - *attr = dstate; - return( 0 ); -} - -int -ldap_pvt_thread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_condattr_t *attr ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { /* * lwp cv_create requires the monitor id be passed in @@ -203,8 +194,7 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex, - ldap_pvt_thread_mutexattr_t *attr ) +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { return( mon_create( mutex ) ); } diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c index 4e81b2bad8..60276ab492 100644 --- a/libraries/libldap_r/thr_nt.c +++ b/libraries/libldap_r/thr_nt.c @@ -15,24 +15,31 @@ #if defined( HAVE_NT_THREADS ) +int +ldap_pvt_thread_initialize( void ) +{ + return 0; +} + int -openldap_thread_create( openldap_thread_t * thread, - openldap_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void *), + void *arg) { - *thread = (openldap_thread_t)_beginthread( (void *) start_routine, + *thread = (ldap_pvt_thread_t)_beginthread( (void *) start_routine, 0, arg ); return ( (unsigned long)*thread == -1 ? -1 : 0 ); } void -openldap_thread_exit( void *retval ) +ldap_pvt_thread_exit( void *retval ) { _endthread( ); } int -openldap_thread_join( openldap_thread_t thread, void **thread_return ) +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) { DWORD status; status = WaitForSingleObject( thread, INFINITE ); @@ -43,70 +50,41 @@ openldap_thread_join( openldap_thread_t thread, void **thread_return ) } int -openldap_thread_kill( openldap_thread_t thread, int signo ) +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) { return 0; } int -openldap_thread_yield( void ) +ldap_pvt_thread_yield( void ) { return 0; } int -openldap_thread_attr_init( openldap_thread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -openldap_thread_attr_destroy( openldap_thread_attr_t *attr ) -{ - return( 0 ); -} - -int -openldap_thread_attr_setdetachstate( openldap_thread_attr_t *attr, int dstate ) -{ - *attr = dstate; - return( 0 ); -} - -int -openldap_thread_attr_getdetachstate( openldap_thread_attr_t *attr, - int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -openldap_thread_cond_init( openldap_thread_cond_t *cond, - openldap_thread_condattr_t *attr ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { *cond = CreateEvent( NULL, FALSE, FALSE, NULL ); return( 0 ); } int -openldap_thread_cond_destroy( openldap_thread_cond_t *cv ) +ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) { CloseHandle( *cv ); return( 0 ); } int -openldap_thread_cond_signal( openldap_thread_cond_t *cond ) +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) { SetEvent( *cond ); return( 0 ); } int -openldap_thread_cond_wait( openldap_thread_cond_t *cond, - openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) { ReleaseMutex( *mutex ); WaitForSingleObject( *cond, INFINITE ); @@ -115,43 +93,42 @@ openldap_thread_cond_wait( openldap_thread_cond_t *cond, } int -openldap_thread_cond_broadcast( openldap_thread_cond_t *cv ) +ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv ) { SetEvent( *cv ); return( 0 ); } int -openldap_thread_mutex_init( openldap_thread_mutex_t *mutex, - openldap_thread_mutexattr_t *attr ) +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { *mutex = CreateMutex( NULL, 0, NULL ); return ( 0 ); } int -openldap_thread_mutex_destroy( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) { CloseHandle( *mutex ); return ( 0 ); } int -openldap_thread_mutex_lock( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) { WaitForSingleObject( *mutex, INFINITE ); return ( 0 ); } int -openldap_thread_mutex_unlock( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) { ReleaseMutex( *mutex ); return ( 0 ); } int -openldap_thread_mutex_trylock( openldap_thread_mutex_t *mp ) +ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mp ) { DWORD status; diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c index cf6201813c..1ebb1b37d4 100644 --- a/libraries/libldap_r/thr_posix.c +++ b/libraries/libldap_r/thr_posix.c @@ -16,18 +16,59 @@ #if defined( HAVE_PTHREADS ) +int +ldap_pvt_thread_initialize( void ) +{ +#if defined( LDAP_THREAD_CONCURRENCY ) && HAVE_PTHREAD_SETCONCURRENCY + ldap_pvt_thread_setconcurrency( LDAP_THREAD_CONCURRENCY ); +#endif + return 0; +} + +#ifdef HAVE_PTHREAD_SETCONCURRENCY +int +ldap_pvt_thread_set_concurrency(int n) +{ +#ifdef HAVE_PTHREAD_SETCONCURRENCY + return pthread_setconcurrency( n ); +#elif HAVE_THR_SETCONCURRENCY + return pthread_setconcurrency( n ); +#else + return 0; +#endif +} +#endif + +#ifdef HAVE_PTHREAD_GETCONCURRENCY +int +ldap_pvt_thread_get_concurrency(void) +{ +#ifdef HAVE_PTHREAD_GETCONCURRENCY + return pthread_getconcurrency(); +#elif HAVE_THR_GETCONCURRENCY + return pthread_getconcurrency(); +#else + return 0; +#endif +} +#endif + int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, - ldap_pvt_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)( void * ), + void *arg) { -#if !defined( HAVE_PTHREADS_D4 ) - /* This is a standard pthreads implementation. */ - return pthread_create( thread, attr, start_routine, arg ); + int rtn = pthread_create( thread, NULL, start_routine, arg ); + + if( detach ) { +#ifdef HAVE_PTHREADS_FINAL + pthread_detach( *thread ); #else - /* This is a draft 4 or earlier implementation. */ - return pthread_create( thread, *attr, start_routine, arg ); -#endif + pthread_detach( thread ); +#endif + } + return rtn; } void @@ -65,57 +106,19 @@ ldap_pvt_thread_yield( void ) { #ifdef HAVE_SCHED_YIELD return sched_yield(); -#else +#elif HAVE_PTHREAD_YIELD return pthread_yield(); -#endif -} - -int -ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr ) -{ -#if defined( HAVE_PTHREAD_ATTR_INIT ) - return pthread_attr_init( attr ); -#elif defined( HAVE_PTHREAD_ATTR_CREATE ) - return pthread_attr_create( attr ); +#elif HAVE_THR_YIELD + return thr_yield(); #else - No way to init attr, so cause an error. -#endif -} - -int -ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr ) -{ -#if defined( HAVE_PTHREAD_ATTR_DESTROY ) - return pthread_attr_destroy( attr ); -#elif defined( HAVE_PTHREAD_ATTR_DELETE ) - return pthread_attr_delete( attr ); -#else - No way to destroy attr, so cause an error. -#endif + return 0; +#endif } int -ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { -#if defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) - return pthread_attr_setdetachstate( attr, dstate ); -#elif defined( HAVE_PTHREAD_ATTR_SETDETACH_NP ) - return pthread_attr_setdetach_np( attr, dstate ); -#else - No way to set state, so cause an error. -#endif -} - -int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_condattr_t *attr ) -{ -#if defined( HAVE_PTHREADS_D4 ) - return pthread_cond_init( cond, - attr ? attr : pthread_condattr_default ); -#else - return pthread_cond_init( cond, attr ); -#endif + return pthread_cond_init( cond, NULL ); } int @@ -138,15 +141,9 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex, - ldap_pvt_thread_mutexattr_t *attr ) -{ -#if defined( HAVE_PTHREADS_D4 ) - return pthread_mutex_init( mutex, - attr ? attr : pthread_mutexattr_default ); -#else - return pthread_mutex_init( mutex, attr ); -#endif +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) +{ + return pthread_mutex_init( mutex, NULL ); } int diff --git a/libraries/libldap_r/thr_sleep.c b/libraries/libldap_r/thr_sleep.c new file mode 100644 index 0000000000..001bb1a83b --- /dev/null +++ b/libraries/libldap_r/thr_sleep.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 1996 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +/* + * ldap_pvt_thread_sleep.c - allow a thread to sleep without putting + * the whole process (e.g. pod under lwp) to sleep. + * + * Contains platform-specific code to allow this: + * + * Under non-preemptive threads packages like SunOS lwp, tsleep() adds + * the thread to a list of sleepers. The lwp_scheduler process takes + * care of resuming suspended threads. + * + * Under a fully-preemptive threads package, like Solaris threads, + * tsleep just calls sleep(), and there is no scheduler thread. Life + * is so much simpler... + */ + +#include "portable.h" + +#include +#include +#include /* get sleep() */ + +#if !defined( HAVE_LWP ) + +/* + * Here we assume we have fully preemptive threads and that sleep() + * does the right thing. + */ +unsigned int +ldap_pvt_thread_sleep( + unsigned int interval +) +{ + sleep( interval ); + return 0; +} + +#else + +unsigned int +ldap_pvt_thread_sleep( + unsigned int interval +) +{ + thread_t mylwp; + tl_t *t, *nt; + time_t now; + + + if ( lwp_self( &mylwp ) < 0 ) { + return -1; + } + + time( &now ); + + mon_enter( &sglob->tsl_mon ); + + if ( sglob->tsl_list != NULL ) { + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + if ( SAMETHREAD( t->tl_tid, mylwp )) { + /* We're already sleeping? */ + t->tl_wake = now + interval; + mon_exit( &sglob->tsl_mon ); + lwp_suspend( mylwp ); + return 0; + } + } + } + + nt = (tl_t *) malloc( sizeof( tl_t )); + + nt->tl_next = sglob->tsl_list; + nt->tl_wake = now + interval; + nt->tl_tid = mylwp; + sglob->tsl_list = nt; + + mon_exit( &sglob->tsl_mon ); + + lwp_suspend( mylwp ); + return 0; +} + +/* + * The lwp_scheduler thread periodically checks to see if any threads + * are due to be resumed. If there are, it resumes them. Otherwise, + * it computes the lesser of ( 1 second ) or ( the minimum time until + * a thread need to be resumed ) and puts itself to sleep for that amount + * of time. + */ +void +lwp_scheduler( + int stackno +) +{ + time_t now, min; + struct timeval interval; + tl_t *t; + + while ( !sglob->slurpd_shutdown ) { + mon_enter( &sglob->tsl_mon ); + + time( &now ); + min = 0L; + if ( sglob->tsl_list != NULL ) { + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + if (( t->tl_wake > 0L ) && ( t->tl_wake < now )) { + lwp_resume( t->tl_tid ); + t->tl_wake = 0L; + } + + if (( t->tl_wake > now ) && ( t->tl_wake < min )) { + min = t->tl_wake; + } + } + } + + mon_exit( &sglob->tsl_mon ); + + interval.tv_usec = 0L; + if ( min == 0L ) { + interval.tv_sec = 1L; + } else { + interval.tv_sec = min; + } + + lwp_sleep( &interval ); + } + + mon_enter( &sglob->tsl_mon ); + + for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { + lwp_resume( t->tl_tid ); + } + + mon_exit( &sglob->tsl_mon ); + + free_stack( stackno ); +} + +#endif /* HAVE_LWP */ diff --git a/libraries/libldap_r/thr_stub.c b/libraries/libldap_r/thr_stub.c index 2c801814e4..009ea170e2 100644 --- a/libraries/libldap_r/thr_stub.c +++ b/libraries/libldap_r/thr_stub.c @@ -22,98 +22,92 @@ * * ***********************************************************************/ -int -openldap_thread_create( openldap_thread_t * thread, - openldap_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) +int +ldap_pvt_thread_initialize( void ) { - start_routine( arg ); return 0; } -void -openldap_thread_exit( void *retval ) -{ - return; -} - -int -openldap_thread_join( openldap_thread_t thread, void **thread_return ) -{ - return 0; -} +static void* ldap_int_status = NULL; int -openldap_thread_kill( openldap_thread_t thread, int signo ) +ldap_pvt_thread_create( ldap_pvt_thread_t * thread, + int detach, + void *(*start_routine)(void *), + void *arg) { + if( ! detach ) ldap_int_status = NULL; + start_routine( arg ); return 0; } -int -openldap_thread_yield( void ) +void +ldap_pvt_thread_exit( void *retval ) { - return 0; + if( retval != NULL ) { + ldap_int_status = retval; + } + return; } int -openldap_thread_attr_init( openldap_thread_attr_t *attr ) +ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status ) { + if(status != NULL) *status = ldap_int_status; return 0; } int -openldap_thread_attr_destroy( openldap_thread_attr_t *attr ) +ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) { return 0; } int -openldap_thread_attr_setdetachstate( openldap_thread_attr_t *attr, int dstate ) +ldap_pvt_thread_yield( void ) { return 0; } int -openldap_thread_cond_init( openldap_thread_cond_t *cond, - openldap_thread_condattr_t *attr ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { return 0; } int -openldap_thread_cond_signal( openldap_thread_cond_t *cond ) +ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) { return 0; } int -openldap_thread_cond_wait( openldap_thread_cond_t *cond, - openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, + ldap_pvt_thread_mutex_t *mutex ) { return 0; } int -openldap_thread_mutex_init( openldap_thread_mutex_t *mutex, - openldap_thread_mutexattr_t *attr ) +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int -openldap_thread_mutex_destroy( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int -openldap_thread_mutex_lock( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) { return 0; } int -openldap_thread_mutex_unlock( openldap_thread_mutex_t *mutex ) +ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) { return 0; } diff --git a/libraries/libldap_r/thr_thr.c b/libraries/libldap_r/thr_thr.c index e677466ab5..54f2b6ba94 100644 --- a/libraries/libldap_r/thr_thr.c +++ b/libraries/libldap_r/thr_thr.c @@ -21,12 +21,36 @@ * * *******************/ +int +ldap_pvt_thread_initialize( void ) +{ +#ifdef LDAP_THREAD_CONCURRENCY + thr_setconcurrency( LDAP_THREAD_CONCURRENCY ); +#endif + return 0; +} + +int +ldap_pvt_thread_set_concurrency(int n) +{ + return thr_setconcurrency( n ); +} + +int +ldap_pvt_thread_get_concurrency(void) +{ + return thr_getconcurrency(); +} + int ldap_pvt_thread_create( ldap_pvt_thread_t * thread, - ldap_pvt_thread_attr_t *attr, - void *(*start_routine)( void *), void *arg) + int detach, + void *(*start_routine)( void *), + void *arg) { - return( thr_create( NULL, 0, start_routine, arg, *attr, thread ) ); + return( thr_create( NULL, 0, start_routine, arg, + detach ? THR_DETACHED : 0, + thread ) ); } void @@ -56,31 +80,9 @@ ldap_pvt_thread_yield( void ) } int -ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate ) -{ - *attr = detachstate; - return( 0 ); -} - -int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_condattr_t *attr ) +ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) { - return( cond_init( cond, attr ? *attr : USYNC_THREAD, NULL ) ); + return( cond_init( cond, USYNC_THREAD, NULL ) ); } int @@ -109,10 +111,9 @@ ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv ) } int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex, - ldap_pvt_thread_mutexattr_t *attr ) +ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) { - return( mutex_init( mutex, attr ? *attr : USYNC_THREAD, NULL ) ); + return( mutex_init( mutex, USYNC_THREAD, NULL ) ); } int diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index d83bde5f6d..cd0d8b74b6 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -19,7 +19,7 @@ #include #include "ldbm.h" -#include "lthread.h" +#include "ldap_pvt_thread.h" #if defined( LDBM_USE_DBHASH ) || defined( LDBM_USE_DBBTREE ) @@ -87,9 +87,9 @@ void ldbm_initialize( void ) #else /* DB 1.85 is non-reentrant */ -static pthread_mutex_t ldbm_big_mutex; -#define LDBM_LOCK (pthread_mutex_lock(&ldbm_big_mutex)) -#define LDBM_UNLOCK (pthread_mutex_unlock(&ldbm_big_mutex)) +static ldap_pvt_thread_mutex_t ldbm_big_mutex; +#define LDBM_LOCK (ldap_pvt_thread_mutex_lock(&ldbm_big_mutex)) +#define LDBM_UNLOCK (ldap_pvt_thread_mutex_unlock(&ldbm_big_mutex)) void ldbm_initialize( void ) { @@ -97,7 +97,7 @@ void ldbm_initialize( void ) if(initialized++) return; - pthread_mutex_init( &ldbm_big_mutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &ldbm_big_mutex ); } #endif @@ -373,9 +373,9 @@ ldbm_errno( LDBM ldbm ) #include /* GDBM is non-reentrant */ -static pthread_mutex_t ldbm_big_mutex; -#define LDBM_LOCK (pthread_mutex_lock(&ldbm_big_mutex)) -#define LDBM_UNLOCK (pthread_mutex_unlock(&ldbm_big_mutex)) +static ldap_pvt_thread_mutex_t ldbm_big_mutex; +#define LDBM_LOCK (ldap_pvt_thread_mutex_lock(&ldbm_big_mutex)) +#define LDBM_UNLOCK (ldap_pvt_thread_mutex_unlock(&ldbm_big_mutex)) void ldbm_initialize( void ) { @@ -383,7 +383,7 @@ void ldbm_initialize( void ) if(initialized++) return; - pthread_mutex_init( &ldbm_big_mutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &ldbm_big_mutex ); } /***************************************************************** @@ -521,9 +521,9 @@ ldbm_errno( LDBM ldbm ) #elif defined( HAVE_NDBM ) /* GDBM is non-reentrant */ -static pthread_mutex_t ldbm_big_mutex; -#define LDBM_LOCK (pthread_mutex_lock(&ldbm_big_mutex)) -#define LDBM_UNLOCK (pthread_mutex_unlock(&ldbm_big_mutex)) +static ldap_pvt_thread_mutex_t ldbm_big_mutex; +#define LDBM_LOCK (ldap_pvt_thread_mutex_lock(&ldbm_big_mutex)) +#define LDBM_UNLOCK (ldap_pvt_thread_mutex_unlock(&ldbm_big_mutex)) void ldbm_initialize( void ) { @@ -531,7 +531,7 @@ void ldbm_initialize( void ) if(initialized++) return; - pthread_mutex_init( &ldbm_big_mutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &ldbm_big_mutex ); } /***************************************************************** diff --git a/libraries/liblthread/Makefile.in b/libraries/liblthread/Makefile.in deleted file mode 100644 index 63da618a70..0000000000 --- a/libraries/liblthread/Makefile.in +++ /dev/null @@ -1,15 +0,0 @@ -## -## Makefile for -llthread -## - -LIBRARY = liblthread.a -XSRCS = version.c -SRCS = rdwr.c thread.c stack.c -OBJS = rdwr.o thread.o stack.o - -LDAP_INCDIR= ../../include -LDAP_LIBDIR= ../../libraries - -XLIBS = -lthread -XXLIBS = $(LTHREAD_LIBS) - diff --git a/libraries/liblthread/Version.c b/libraries/liblthread/Version.c deleted file mode 100644 index f9e97e663c..0000000000 --- a/libraries/liblthread/Version.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 1995 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -static char Version[] = " liblthread.a v%VERSION% (%WHEN%)\n\t%WHOANDWHERE%\n"; diff --git a/libraries/liblthread/liblthread.dsp b/libraries/liblthread/liblthread.dsp deleted file mode 100644 index c5ab6cdf6a..0000000000 --- a/libraries/liblthread/liblthread.dsp +++ /dev/null @@ -1,137 +0,0 @@ -# Microsoft Developer Studio Project File - Name="liblthread" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=liblthread - Win32 MT Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "liblthread.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "liblthread.mak" CFG="liblthread - Win32 MT Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "liblthread - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "liblthread - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "liblthread - Win32 MT Debug" (based on "Win32 (x86) Static Library") -!MESSAGE "liblthread - Win32 MT Release" (based on\ - "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe - -!IF "$(CFG)" == "liblthread - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\Release" -# PROP Intermediate_Dir "Release\" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\Release\olthread32.lib" - -!ELSEIF "$(CFG)" == "liblthread - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\Debug\olthread32.lib" - -!ELSEIF "$(CFG)" == "liblthread - Win32 MT Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "MT Debug" -# PROP BASE Intermediate_Dir "MT Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\Debug" -# PROP Intermediate_Dir "Debug\MT" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo /out:"..\Debug\olthread32.lib" -# ADD LIB32 /nologo /out:"..\Debug\olthread32mt.lib" - -!ELSEIF "$(CFG)" == "liblthread - Win32 MT Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "MT Release" -# PROP BASE Intermediate_Dir "MT Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\Release" -# PROP Intermediate_Dir "Release\MT" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo /out:"..\Release\olthread32.lib" -# ADD LIB32 /nologo /out:"..\Release\olthread32mt.lib" - -!ENDIF - -# Begin Target - -# Name "liblthread - Win32 Release" -# Name "liblthread - Win32 Debug" -# Name "liblthread - Win32 MT Debug" -# Name "liblthread - Win32 MT Release" -# Begin Source File - -SOURCE=.\rdwr.c -# End Source File -# Begin Source File - -SOURCE=.\stack.c -# End Source File -# Begin Source File - -SOURCE=.\thread.c -# End Source File -# End Target -# End Project diff --git a/libraries/liblthread/liblthread.dsw b/libraries/liblthread/liblthread.dsw deleted file mode 100644 index ee14c84283..0000000000 --- a/libraries/liblthread/liblthread.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "liblthread"=.\liblthread.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/libraries/liblthread/rdwr.c b/libraries/liblthread/rdwr.c deleted file mode 100644 index 6611bb30c9..0000000000 --- a/libraries/liblthread/rdwr.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -** This basic implementation of Reader/Writer locks does not -** protect writers from starvation. That is, if a writer is -** currently waiting on a reader, any new reader will get -** the lock before the writer. -*/ - -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * rdwr.c -- - * - * Library of functions implementing reader/writer locks - */ - -#include - -#include - -#include -#include - -int pthread_rdwr_init_np(pthread_rdwr_t *rdwrp, pthread_rdwrattr_t *attrp) -{ - rdwrp->readers_reading = 0; - rdwrp->writer_writing = 0; - pthread_mutex_init(&(rdwrp->mutex), pthread_mutexattr_default); - pthread_cond_init(&(rdwrp->lock_free), pthread_condattr_default); - return 0; -} - -int pthread_rdwr_rlock_np(pthread_rdwr_t *rdwrp){ - pthread_mutex_lock(&(rdwrp->mutex)); - while(rdwrp->writer_writing) { - pthread_cond_wait(&(rdwrp->lock_free), &(rdwrp->mutex)); - } - rdwrp->readers_reading++; - pthread_mutex_unlock(&(rdwrp->mutex)); - return 0; -} - -int pthread_rdwr_runlock_np(pthread_rdwr_t *rdwrp) -{ - pthread_mutex_lock(&(rdwrp->mutex)); - if (rdwrp->readers_reading == 0) { - pthread_mutex_unlock(&(rdwrp->mutex)); - return -1; - } - else { - rdwrp->readers_reading--; - if (rdwrp->readers_reading == 0) { - pthread_cond_signal(&(rdwrp->lock_free)); - } - pthread_mutex_unlock(&(rdwrp->mutex)); - return 0; - } -} - -int pthread_rdwr_wlock_np(pthread_rdwr_t *rdwrp) -{ - pthread_mutex_lock(&(rdwrp->mutex)); - while(rdwrp->writer_writing || rdwrp->readers_reading) { - pthread_cond_wait(&(rdwrp->lock_free), &(rdwrp->mutex)); - } - rdwrp->writer_writing++; - pthread_mutex_unlock(&(rdwrp->mutex)); - return 0; -} - -int pthread_rdwr_wunlock_np(pthread_rdwr_t *rdwrp) -{ - pthread_mutex_lock(&(rdwrp->mutex)); - if (rdwrp->writer_writing == 0) { - pthread_mutex_unlock(&(rdwrp->mutex)); - return -1; - } - else { - rdwrp->writer_writing = 0; - pthread_cond_broadcast(&(rdwrp->lock_free)); - pthread_mutex_unlock(&(rdwrp->mutex)); - return 0; - } -} - -#ifdef LDAP_DEBUG - -/* just for testing, - * return 0 if false, suitable for assert(pthread_rdwr_Xchk(rdwr)) - * - * Currently they don't check if the calling thread is the one - * that has the lock, just that there is a reader or writer. - * - * Basically sufficent for testing that places that should have - * a lock are caught. - */ - -int pthread_rdwr_rchk_np(pthread_rdwr_t *rdwrp) -{ - return(rdwrp->readers_reading!=0); -} - -int pthread_rdwr_wchk_np(pthread_rdwr_t *rdwrp) -{ - return(rdwrp->writer_writing!=0); -} -int pthread_rdwr_rwchk_np(pthread_rdwr_t *rdwrp) -{ - return(pthread_rdwr_rchk_np(rdwrp) || pthread_rdwr_wchk_np(rdwrp)); -} - -#endif /* LDAP_DEBUG */ diff --git a/libraries/liblthread/stack.c b/libraries/liblthread/stack.c deleted file mode 100644 index 0e7a249887..0000000000 --- a/libraries/liblthread/stack.c +++ /dev/null @@ -1,76 +0,0 @@ -/* stack.c - stack handling routines */ - -#include "portable.h" - -#if defined( HAVE_LWP ) - -#include - -#include -#include - -#include "lber.h" -#include "ldap.h" -#include "ldap_log.h" - -#include -#include - -#define MAX_STACK 51200 -#define MAX_THREADS 20 - -struct stackinfo { - int stk_inuse; - stkalign_t *stk_stack; -}; - -static struct stackinfo *stacks; - -stkalign_t * -get_stack( int *stacknop ) -{ - int i; - - if ( stacks == NULL ) { - stacks = (struct stackinfo *) ch_calloc( 1, MAX_THREADS * - sizeof(struct stackinfo) ); - } - - for ( i = 0; i < MAX_THREADS; i++ ) { - if ( stacks[i].stk_inuse == 0 ) { - break; - } - } - - if ( i == MAX_THREADS ) { - Debug( LDAP_DEBUG_ANY, - "no more stacks (max %d) - increase MAX_THREADS for more", - MAX_THREADS, 0, 0 ); - return( NULL ); - } - - if ( stacks[i].stk_stack == NULL ) { - stacks[i].stk_stack = (stkalign_t *) malloc( - (MAX_STACK / sizeof(stkalign_t) + 1 ) - * sizeof(stkalign_t) ); - } - - *stacknop = i; - stacks[i].stk_inuse = 1; - return( stacks[i].stk_stack + MAX_STACK / sizeof(stkalign_t) ); -} - -void -free_stack( - int stackno -) -{ - if ( stackno < 0 || stackno > MAX_THREADS ) { - Debug( LDAP_DEBUG_ANY, "free_stack of bogus stack %d", - stackno, 0, 0 ); - } - - stacks[stackno].stk_inuse = 0; -} - -#endif diff --git a/libraries/liblthread/thread.c b/libraries/liblthread/thread.c deleted file mode 100644 index a688d7223f..0000000000 --- a/libraries/liblthread/thread.c +++ /dev/null @@ -1,782 +0,0 @@ -/* thread.c - glue routines to provide a consistent thread interface */ - -#include "portable.h" - -#include - -#if defined( HAVE_PTHREADS ) - -#ifndef HAVE_PTHREAD_KILL -/* - * Some pthreads packages (ie: DCE) don't have pthread_kill() - * pthread_kill() routine) - * - */ - -/* ARGSUSED */ -void -pthread_kill( pthread_t tid, int sig ) -{ - kill( getpid(), sig ); -} -#endif /* HAVE_PTHREAD_KILL */ - -#if !defined(HAVE_SCHED_YIELD) && !defined(HAVE_PTHREAD_YIELD) -/* - * Some pthreads packages don't have sched_yield() nor - * the draft4 pthread_kill() routine, assume it's not - * needed. - */ -void -pthread_yield( void ) -{ - /* assume pthread implementation is preemptive */ -} -#endif /* missing sched_yield() */ - -#elif defined( HAVE_MACH_CTHREADS ) - -/*********************************************************************** - * * - * under NEXTSTEP or OPENSTEP use CThreads * - * lukeh@xedoc.com.au * - * * - ***********************************************************************/ - -int -pthread_attr_init( pthread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -pthread_attr_destroy( pthread_attr_t *attr ) -{ - return( 0 ); -} - -int -pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) -{ - *attr = detachstate; - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_create( - pthread_t *tid, - pthread_attr_t *attr, - VFP func, - void *arg -) -{ - *tid = cthread_fork(func, arg); - return ( *tid == NULL ? -1 : 0 ); -} - -void -pthread_yield( void ) -{ - cthread_yield(); -} - -void -pthread_exit( any_t a ) -{ - cthread_exit( a ); -} - -void -pthread_join( pthread_t tid, int *pStatus ) -{ - int status; - status = (int) cthread_join ( tid ); - if (pStatus != NULL) - { - *pStatus = status; - } -} - -/* ARGSUSED */ -void -pthread_kill( pthread_t tid, int sig ) -{ - return; -} - -/* ARGSUSED */ -int -pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) -{ - mutex_init( mp ); - mp->name = NULL; - return ( 0 ); -} - -int -pthread_mutex_destroy( pthread_mutex_t *mp ) -{ - mutex_clear( mp ); - return ( 0 ); -} - -int -pthread_mutex_lock( pthread_mutex_t *mp ) -{ - mutex_lock( mp ); - return ( 0 ); -} - -int -pthread_mutex_unlock( pthread_mutex_t *mp ) -{ - mutex_unlock( mp ); - return ( 0 ); -} - -int -pthread_mutex_trylock( pthread_mutex_t *mp ) -{ - return mutex_try_lock( mp ); -} - -int -pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) -{ - condition_init( cv ); - return( 0 ); -} - -int -pthread_cond_destroy( pthread_cond_t *cv ) -{ - condition_clear( cv ); - return( 0 ); -} - -int -pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) -{ - condition_wait( cv, mp ); - return( 0 ); -} - -int -pthread_cond_signal( pthread_cond_t *cv ) -{ - condition_signal( cv ); - return( 0 ); -} - -int -pthread_cond_broadcast( pthread_cond_t *cv ) -{ - condition_broadcast( cv ); - return( 0 ); -} - -#elif defined( HAVE_THR ) - -/******************* - * * - * Solaris Threads * - * * - *******************/ - -int -pthread_attr_init( pthread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -pthread_attr_destroy( pthread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) -{ - *attr = detachstate; - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_create( - pthread_t *tid, - pthread_attr_t *attr, - VFP func, - void *arg -) -{ - return( thr_create( NULL, 0, func, arg, *attr, tid ) ); -} - -void -pthread_yield( void ) -{ - thr_yield(); -} - -void -pthread_exit() -{ - thr_exit( NULL ); -} - -void -pthread_join( pthread_t tid, int *status ) -{ - thr_join( tid, NULL, (void **) status ); -} - -void -pthread_kill( pthread_t tid, int sig ) -{ - thr_kill( tid, sig ); -} - -/* ARGSUSED */ -int -pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) -{ - return( mutex_init( mp, attr ? *attr : USYNC_THREAD, NULL ) ); -} - -int -pthread_mutex_destroy( pthread_mutex_t *mp ) -{ - return( mutex_destroy( mp ) ); -} - -int -pthread_mutex_lock( pthread_mutex_t *mp ) -{ - return( mutex_lock( mp ) ); -} - -int -pthread_mutex_unlock( pthread_mutex_t *mp ) -{ - return( mutex_unlock( mp ) ); -} - -int -pthread_mutex_trylock( pthread_mutex_t *mp ) -{ - return( mutex_trylock( mp ) ); -} - -int -pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) -{ - return( cond_init( cv, attr ? *attr : USYNC_THREAD, NULL ) ); -} - -int -pthread_cond_destroy( pthread_cond_t *cv ) -{ - return( cond_destroy( cv ) ); -} - -int -pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) -{ - return( cond_wait( cv, mp ) ); -} - -int -pthread_cond_signal( pthread_cond_t *cv ) -{ - return( cond_signal( cv ) ); -} - -int -pthread_cond_broadcast( pthread_cond_t *cv ) -{ - return( cond_broadcast( cv ) ); -} - -#elif defined( HAVE_LWP ) - -/************* - * * - * SunOS LWP * - * * - *************/ - -int -pthread_attr_init( pthread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -pthread_attr_destroy( pthread_attr_t *attr ) -{ - return( 0 ); -} - -int -pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) -{ - *attr = detachstate; - return( 0 ); -} - -static void -lwp_create_stack( VFP func, void *arg, int stackno ) -{ - (*func)( arg ); - - free_stack( stackno ); -} - -/* ARGSUSED */ -int -pthread_create( - pthread_t *tid, - pthread_attr_t *attr, - VFP func, - void *arg -) -{ - stkalign_t *stack; - int stackno; - - if ( (stack = get_stack( &stackno )) == NULL ) { - return( -1 ); - } - return( lwp_create( tid, lwp_create_stack, MINPRIO, 0, stack, 3, func, - arg, stackno ) ); -} - -void -pthread_yield( void ) -{ - lwp_yield( SELF ); -} - -void -pthread_exit() -{ - lwp_destroy( SELF ); -} - -void -pthread_join( pthread_t tid, int *status ) -{ - lwp_join( tid ); -} - -/* ARGSUSED */ -void -pthread_kill( pthread_t tid, int sig ) -{ - return; -} - -/* ARGSUSED */ -int -pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) -{ - return( mon_create( mp ) ); -} - -int -pthread_mutex_destroy( pthread_mutex_t *mp ) -{ - return( mon_destroy( *mp ) ); -} - -int -pthread_mutex_lock( pthread_mutex_t *mp ) -{ - return( mon_enter( *mp ) ); -} - -int -pthread_mutex_unlock( pthread_mutex_t *mp ) -{ - return( mon_exit( *mp ) ); -} - -int -pthread_mutex_trylock( pthread_mutex_t *mp ) -{ - return( mon_cond_enter( *mp ) ); -} - -int -pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) -{ - /* - * lwp cv_create requires the monitor id be passed in - * when the cv is created, pthreads passes it when the - * condition is waited for. so, we fake the creation - * here and actually do it when the cv is waited for - * later. - */ - - cv->lcv_created = 0; - - return( 0 ); -} - -int -pthread_cond_destroy( pthread_cond_t *cv ) -{ - return( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 ); -} - -int -pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) -{ - if ( ! cv->lcv_created ) { - cv_create( &cv->lcv_cv, *mp ); - cv->lcv_created = 1; - } - - return( cv_wait( cv->lcv_cv ) ); -} - -int -pthread_cond_signal( pthread_cond_t *cv ) -{ - return( cv->lcv_created ? cv_notify( cv->lcv_cv ) : 0 ); -} - -int -pthread_cond_broadcast( pthread_cond_t *cv ) -{ - return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 ); -} - - -#elif defined( HAVE_NT_THREADS ) - -int -pthread_attr_init( pthread_attr_t *attr ) -{ - *attr = 0; - return( 0 ); -} - -int -pthread_attr_destroy( pthread_attr_t *attr ) -{ - return( 0 ); -} - -int -pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - *detachstate = *attr; - return( 0 ); -} - -int -pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) -{ - *attr = detachstate; - return( 0 ); -} - -int -pthread_create( - pthread_t *tid, - pthread_attr_t *attr, - VFP func, - void *arg -) -{ - *tid = (pthread_t)_beginthread( (void *) func, 0, arg ); - return ( (unsigned long)*tid == -1 ? -1 : 0 ); -} - -void -pthread_yield() -{ - -} - -void -pthread_exit( void ) -{ - _endthread( ); -} - -void -pthread_join( pthread_t tid, int *pStatus ) -{ - DWORD status; - status = WaitForSingleObject( tid, INFINITE ); - if ( pStatus != NULL) - { - if ( status != WAIT_FAILED ) - *pStatus = 0; - else - *pStatus = WAIT_ABANDONED; - } -} - - -void -pthread_kill( pthread_t tid, int sig ) -{ - return; -} - - -int -pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) -{ - *mp = CreateMutex( NULL, 0, NULL ); - return ( 0 ); -} - -int -pthread_mutex_destroy( pthread_mutex_t *mp ) -{ - CloseHandle( *mp ); - return ( 0 ); -} - -int -pthread_mutex_lock( pthread_mutex_t *mp ) -{ - WaitForSingleObject( *mp, INFINITE ); - return ( 0 ); -} - -int -pthread_mutex_unlock( pthread_mutex_t *mp ) -{ - ReleaseMutex( *mp ); - return ( 0 ); -} - -int -pthread_mutex_trylock( pthread_mutex_t *mp ) -{ - DWORD status; - - status = WaitForSingleObject( *mp, 0 ); - if ( (status == WAIT_FAILED) || (status == WAIT_TIMEOUT) ) - return 0; - else - return 1; -} - -int -pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) -{ - *cv = CreateEvent( NULL, FALSE, FALSE, NULL ); - return( 0 ); -} - -int -pthread_cond_destroy( pthread_cond_t *cv ) -{ - CloseHandle( *cv ); - return( 0 ); -} - -int -pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) -{ - ReleaseMutex( *mp ); - WaitForSingleObject( *cv, INFINITE ); - WaitForSingleObject( *mp, INFINITE ); - return( 0 ); -} - -int -pthread_cond_signal( pthread_cond_t *cv ) -{ - SetEvent( *cv ); - return( 0 ); -} - -int -pthread_cond_broadcast( pthread_cond_t *cv ) -{ - SetEvent( *cv ); - return( 0 ); -} - -#else - -/*********************************************************************** - * * - * no threads package defined for this system - fake ok returns from * - * all threads routines (making it single-threaded). * - * * - ***********************************************************************/ - -/* ARGSUSED */ -int -pthread_attr_init( pthread_attr_t *attr ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_attr_destroy( pthread_attr_t *attr ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_create( - pthread_t *tid, - pthread_attr_t *attr, - VFP func, - void *arg -) -{ - (*func)( arg ); - - return( 0 ); -} - -void -pthread_yield( void ) -{ - return; -} - -void -pthread_exit() -{ - return; -} - -/* ARGSUSED */ -void -pthread_kill( pthread_t tid, int sig ) -{ - return; -} - -void -pthread_join( pthread_t tid, int *status ) -{ - return; -} - -/* ARGSUSED */ -int -pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_mutex_destroy( pthread_mutex_t *mp ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_mutex_lock( pthread_mutex_t *mp ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_mutex_unlock( pthread_mutex_t *mp ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_mutex_trylock( pthread_mutex_t *mp ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_cond_destroy( pthread_cond_t *cv ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_cond_signal( pthread_cond_t *cv ) -{ - return( 0 ); -} - -/* ARGSUSED */ -int -pthread_cond_broadcast( pthread_cond_t *cv ) -{ - return( 0 ); -} - -#endif /* no threads package */ diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index 1c4104df15..6758fc7624 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -23,7 +23,7 @@ LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries # $(LTHREAD_LIBS) must be last -XLIBS = libbackends.a -lavl -lldbm -lldif -lldap -llber -llthread -llutil +XLIBS = libbackends.a -lavl -lldbm -lldif -lldap_r -llber -llutil XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) \ $(PERL_LDFLAGS) $(KRB_LIBS) $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index d3f3cd4896..4b5986e585 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -50,19 +50,19 @@ do_abandon( * flag and abort the operation at a convenient time. */ - pthread_mutex_lock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_opsmutex ); for ( o = conn->c_ops; o != NULL; o = o->o_next ) { if ( o->o_msgid == id ) break; } if ( o != NULL ) { - pthread_mutex_lock( &o->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &o->o_abandonmutex ); o->o_abandon = 1; - pthread_mutex_unlock( &o->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex ); } else { Debug( LDAP_DEBUG_TRACE, "do_abandon: op not found\n", 0, 0, 0 ); } - pthread_mutex_unlock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex ); } diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 2247a6b9c3..e128d81af7 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -181,7 +181,7 @@ add_created_attrs( Operation *op, Entry *e ) } attr_merge( e, "creatorsname", bvals ); - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME ltm = gmtime( ¤ttime ); strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); @@ -189,7 +189,7 @@ add_created_attrs( Operation *op, Entry *e ) ltm = localtime( ¤ttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); #endif - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 28fdc31e7b..fc592712db 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -30,17 +30,17 @@ ldbm_back_add( Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0); /* nobody else can add until we lock our parent */ - pthread_mutex_lock(&li->li_add_mutex); + ldap_pvt_thread_mutex_lock(&li->li_add_mutex); if ( ( dn2id( be, dn ) ) != NOID ) { - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); entry_free( e ); send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); return( -1 ); } if ( global_schemacheck && oc_schema_check( e ) != 0 ) { - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0, 0 ); @@ -62,7 +62,7 @@ ldbm_back_add( /* get parent with writer lock */ if ( (p = dn2entry_w( be, pdn, &matched )) == NULL ) { - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, @@ -78,7 +78,7 @@ ldbm_back_add( } /* don't need the add lock anymore */ - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); free(pdn); @@ -104,7 +104,7 @@ ldbm_back_add( } else { /* no parent, must be adding entry to root */ if ( ! be_isroot( be, op->o_ndn ) ) { - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, @@ -118,9 +118,9 @@ ldbm_back_add( * no parent, acquire the root write lock * and release the add lock. */ - pthread_mutex_lock(&li->li_root_mutex); + ldap_pvt_thread_mutex_lock(&li->li_root_mutex); rootlock = 1; - pthread_mutex_unlock(&li->li_add_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); } /* acquire required reader/writer lock */ @@ -132,7 +132,7 @@ ldbm_back_add( if ( rootlock ) { /* release root lock */ - pthread_mutex_unlock(&li->li_root_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } Debug( LDAP_DEBUG_ANY, "add: could not lock entry\n", @@ -158,7 +158,7 @@ ldbm_back_add( } if ( rootlock ) { /* release root lock */ - pthread_mutex_unlock(&li->li_root_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0, @@ -228,7 +228,7 @@ return_results:; if ( rootlock ) { /* release root lock */ - pthread_mutex_unlock(&li->li_root_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } cache_set_state( &li->li_cache, e, 0 ); diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 95b1134d00..032b3cb777 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -66,7 +66,7 @@ struct cache { Avlnode *c_idtree; Entry *c_lruhead; /* lru - add accessed entries here */ Entry *c_lrutail; /* lru - rem lru entries from here */ - pthread_mutex_t c_mutex; + ldap_pvt_thread_mutex_t c_mutex; }; /* for the cache of open index files */ @@ -112,9 +112,9 @@ struct ldbminfo { ID li_nextid_wrote; #endif char *li_nextid_file; - pthread_mutex_t li_root_mutex; - pthread_mutex_t li_add_mutex; - pthread_mutex_t li_nextid_mutex; + ldap_pvt_thread_mutex_t li_root_mutex; + ldap_pvt_thread_mutex_t li_add_mutex; + ldap_pvt_thread_mutex_t li_nextid_mutex; int li_mode; char *li_directory; struct cache li_cache; @@ -122,8 +122,8 @@ struct ldbminfo { int li_dbcachesize; int li_dbcachewsync; struct dbcache li_dbcache[MAXDBCACHE]; - pthread_mutex_t li_dbcache_mutex; - pthread_cond_t li_dbcache_cv; + ldap_pvt_thread_mutex_t li_dbcache_mutex; + ldap_pvt_thread_cond_t li_dbcache_cv; }; #include "proto-back-ldbm.h" diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index 6b8a972a28..ac461e7668 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -34,7 +34,7 @@ crypted_value_find( int result; #ifdef SLAPD_CRYPT - pthread_mutex_lock( &crypt_mutex ); + ldap_pvt_thread_mutex_lock( &crypt_mutex ); #endif result = lutil_passwd( @@ -42,7 +42,7 @@ crypted_value_find( (char*) vals[i]->bv_val); #ifdef SLAPD_CRYPT - pthread_mutex_unlock( &crypt_mutex ); + ldap_pvt_thread_mutex_unlock( &crypt_mutex ); #endif return result; diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index a9c31cc3eb..add8693393 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -50,26 +50,26 @@ void cache_set_state( struct cache *cache, Entry *e, int state ) { /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); e->e_state = state; /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); } static void cache_return_entry( struct cache *cache, Entry *e ) { /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); if ( --e->e_refcnt == 0 && e->e_state == ENTRY_STATE_DELETED ) { entry_free( e ); } /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); } static void @@ -136,7 +136,7 @@ cache_add_entry_lock( Entry *ee; /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); if ( avl_insert( &cache->c_dntree, (caddr_t) e, cache_entrydn_cmp, avl_dup_error ) != 0 ) @@ -146,7 +146,7 @@ cache_add_entry_lock( e->e_dn, e->e_id, 0 ); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 1 ); } @@ -167,7 +167,7 @@ cache_add_entry_lock( } /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( -1 ); } @@ -202,7 +202,7 @@ cache_add_entry_lock( /* XXX check for writer lock - should also check no readers pending */ #ifdef LDAP_DEBUG - assert(!pthread_rdwr_rwchk_np(&e->e_rdwr)); + assert(!ldap_pvt_thread_rdwr_rwchk(&e->e_rdwr)); #endif /* delete from cache and lru q */ @@ -213,7 +213,7 @@ cache_add_entry_lock( } /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( 0 ); } @@ -233,7 +233,7 @@ cache_find_entry_dn2id( ID id; /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); e.e_dn = dn; e.e_ndn = dn_normalize_case( ch_strdup( dn ) ); @@ -253,7 +253,7 @@ cache_find_entry_dn2id( ep->e_state == ENTRY_STATE_CREATING ) { /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NOID ); } @@ -277,7 +277,7 @@ cache_find_entry_dn2id( /* free reader lock */ entry_rdwr_unlock(ep, 0); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NOID ); } @@ -289,7 +289,7 @@ cache_find_entry_dn2id( entry_rdwr_unlock(ep, 0); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); cache_return_entry( &li->li_cache, ep ); @@ -299,7 +299,7 @@ cache_find_entry_dn2id( free(e.e_ndn); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NOID ); } @@ -319,7 +319,7 @@ cache_find_entry_id( Entry *ep; /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); e.e_id = id; @@ -337,7 +337,7 @@ cache_find_entry_id( ep->e_state == ENTRY_STATE_CREATING ) { /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NULL ); } /* XXX is this safe without writer lock? */ @@ -361,7 +361,7 @@ cache_find_entry_id( entry_rdwr_unlock(ep, 0); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NULL ); } @@ -371,13 +371,13 @@ cache_find_entry_id( } /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( ep ); } /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( NULL ); } @@ -405,16 +405,16 @@ cache_delete_entry( /* XXX check for writer lock - should also check no readers pending */ #ifdef LDAP_DEBUG - assert(pthread_rdwr_wchk_np(&e->e_rdwr)); + assert(ldap_pvt_thread_rdwr_wchk(&e->e_rdwr)); #endif /* set cache mutex */ - pthread_mutex_lock( &cache->c_mutex ); + ldap_pvt_thread_mutex_lock( &cache->c_mutex ); rc = cache_delete_entry_internal( cache, e ); /* free cache mutex */ - pthread_mutex_unlock( &cache->c_mutex ); + ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); return( rc ); } diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index 7254c6f4c0..066a71d8ca 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -40,12 +40,12 @@ ldbm_cache_open( flags, li->li_mode ); lru = 0; - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); curtime = currenttime; - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); oldtime = curtime; - pthread_mutex_lock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex ); for ( i = 0; i < MAXDBCACHE && li->li_dbcache[i].dbc_name != NULL; i++ ) { /* already open - return it */ @@ -53,7 +53,7 @@ ldbm_cache_open( li->li_dbcache[i].dbc_refcnt++; Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (cache %d)\n", i, 0, 0 ); - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); return( &li->li_dbcache[i] ); } @@ -74,7 +74,7 @@ ldbm_cache_open( 0, 0, 0 ); lru = -1; while ( lru == -1 ) { - pthread_cond_wait( &li->li_dbcache_cv, + ldap_pvt_thread_cond_wait( &li->li_dbcache_cv, &li->li_dbcache_mutex ); for ( i = 0; i < MAXDBCACHE; i++ ) { if ( li->li_dbcache[i].dbc_refcnt @@ -97,7 +97,7 @@ ldbm_cache_open( "<= ldbm_cache_open NULL \"%s\" errno %d reason \"%s\")\n", buf, errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno] : "unknown" ); - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); return( NULL ); } li->li_dbcache[i].dbc_name = ch_strdup( buf ); @@ -118,7 +118,7 @@ ldbm_cache_open( li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids, li->li_dbcache[i].dbc_maxindirect ); Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 ); - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); return( &li->li_dbcache[i] ); } @@ -127,11 +127,11 @@ ldbm_cache_close( Backend *be, struct dbcache *db ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - pthread_mutex_lock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex ); if ( --db->dbc_refcnt == 0 ) { - pthread_cond_signal( &li->li_dbcache_cv ); + ldap_pvt_thread_cond_signal( &li->li_dbcache_cv ); } - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); } void @@ -139,14 +139,14 @@ ldbm_cache_really_close( Backend *be, struct dbcache *db ) { struct ldbminfo *li = (struct ldbminfo *) be->be_private; - pthread_mutex_lock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex ); if ( --db->dbc_refcnt == 0 ) { - pthread_cond_signal( &li->li_dbcache_cv ); + ldap_pvt_thread_cond_signal( &li->li_dbcache_cv ); ldbm_close( db->dbc_db ); free( db->dbc_name ); db->dbc_name = NULL; } - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); } void @@ -155,7 +155,7 @@ ldbm_cache_flush_all( Backend *be ) struct ldbminfo *li = (struct ldbminfo *) be->be_private; int i; - pthread_mutex_lock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_dbcache_mutex ); for ( i = 0; i < MAXDBCACHE; i++ ) { if ( li->li_dbcache[i].dbc_name != NULL ) { Debug( LDAP_DEBUG_TRACE, "ldbm flushing db (%s)\n", @@ -163,7 +163,7 @@ ldbm_cache_flush_all( Backend *be ) ldbm_sync( li->li_dbcache[i].dbc_db ); } } - pthread_mutex_unlock( &li->li_dbcache_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_dbcache_mutex ); } Datum diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 79f405a7b5..1290e747ad 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -41,7 +41,7 @@ ldbm_back_delete( Debug (LDAP_DEBUG_TRACE, "rdwr_Xchk: readers_reading: %d writer_writing: %d\n", - e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); + e->e_rdwr.lt_readers_reading, e->e_rdwr.lt_writer_writing, 0); /* check for deleted */ @@ -67,12 +67,13 @@ ldbm_back_delete( Debug (LDAP_DEBUG_TRACE, "rdwr_Xchk: readers_reading: %d writer_writing: %d\n", - e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); + e->e_rdwr.lt_readers_reading, e->e_rdwr.lt_writer_writing, 0); /* delete from parent's id2children entry */ if( (pdn = dn_parent( be, dn )) != NULL ) { if( (p = dn2entry_w( be, pdn, &matched )) == NULL) { - Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: parent does not exist\n", 0, 0, 0); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", ""); @@ -84,7 +85,8 @@ ldbm_back_delete( if ( ! access_allowed( be, conn, op, p, "children", NULL, ACL_WRITE ) ) { - Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: no access to parent\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" ); @@ -95,14 +97,15 @@ ldbm_back_delete( } else { /* no parent, must be root to delete */ if( ! be_isroot( be, op->o_ndn ) ) { - Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", + Debug( LDAP_DEBUG_TRACE, + "<=- ldbm_back_delete: no parent & not root\n", 0, 0, 0); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", ""); goto return_results; } - pthread_mutex_lock(&li->li_root_mutex); + ldap_pvt_thread_mutex_lock(&li->li_root_mutex); rootlock = 1; } @@ -145,7 +148,7 @@ return_results:; if ( rootlock ) { /* release root lock */ - pthread_mutex_unlock(&li->li_root_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } /* free entry and writer lock */ diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index e42c1f0e51..2aee65d523 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -33,7 +33,7 @@ id2entry_add( Backend *be, Entry *e ) key.dptr = (char *) &e->e_id; key.dsize = sizeof(ID); - pthread_mutex_lock( &entry2str_mutex ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); data.dptr = entry2str( e, &len, 1 ); data.dsize = len + 1; @@ -42,7 +42,7 @@ id2entry_add( Backend *be, Entry *e ) if ( li->li_dbcachewsync ) flags |= LDBM_SYNC; rc = ldbm_cache_store( db, key, data, flags ); - pthread_mutex_unlock( &entry2str_mutex ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); ldbm_cache_close( be, db ); (void) cache_add_entry_lock( &li->li_cache, e, 0 ); @@ -66,7 +66,7 @@ id2entry_delete( Backend *be, Entry *e ) /* XXX - check for writer lock - should also check no reader pending */ #ifdef LDAP_DEBUG - assert(pthread_rdwr_wchk_np(&e->e_rdwr)); + assert(ldap_pvt_thread_rdwr_wchk(&e->e_rdwr)); #endif ldbm_datum_init( key ); @@ -74,7 +74,7 @@ id2entry_delete( Backend *be, Entry *e ) /* XXX - check for writer lock - should also check no reader pending */ Debug (LDAP_DEBUG_TRACE, "rdwr_Xchk: readers_reading: %d writer_writing: %d\n", - e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); + e->e_rdwr.lt_readers_reading, e->e_rdwr.lt_writer_writing, 0); if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT )) == NULL ) { diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 6ccfbc38fd..abf4184f67 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -205,7 +205,7 @@ add_value( } idl_free( idl ); - pthread_yield(); + ldap_pvt_thread_yield(); /* Debug( LDAP_DEBUG_TRACE, "<= add_value %d\n", rc, 0, 0 ); */ return( rc ); diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index 501e451880..f0ae9fb777 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -70,12 +70,12 @@ ldbm_back_init( free( argv[ 1 ] ); /* initialize various mutex locks & condition variables */ - pthread_mutex_init( &li->li_root_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &li->li_add_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &li->li_cache.c_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &li->li_nextid_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &li->li_dbcache_mutex, pthread_mutexattr_default ); - pthread_cond_init( &li->li_dbcache_cv, pthread_condattr_default ); + ldap_pvt_thread_mutex_init( &li->li_root_mutex ); + ldap_pvt_thread_mutex_init( &li->li_add_mutex ); + ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex ); + ldap_pvt_thread_mutex_init( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_init( &li->li_dbcache_mutex ); + ldap_pvt_thread_cond_init( &li->li_dbcache_cv ); be->be_private = li; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 7fac3f8c8b..940d2c808b 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -79,12 +79,12 @@ ldbm_back_modify( } /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto error_return; } - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* modify indexes */ if ( index_add_mods( be, modlist, e->e_id ) != 0 ) { @@ -93,12 +93,12 @@ ldbm_back_modify( } /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto error_return; } - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* change the entry itself */ if ( id2entry_add( be, e ) != 0 ) { diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 33f6536bdc..cf2e9751aa 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -107,7 +107,7 @@ ldbm_back_modrdn( goto return_results; } - pthread_mutex_lock(&li->li_root_mutex); + ldap_pvt_thread_mutex_lock(&li->li_root_mutex); rootlock = 1; new_dn = ch_strdup( newrdn ); @@ -121,12 +121,12 @@ ldbm_back_modrdn( } /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); goto return_results; } - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* add new one */ if ( dn2id_add( be, new_ndn, e->e_id ) != 0 ) { @@ -180,7 +180,7 @@ return_results: if ( rootlock ) { /* release root writer lock */ - pthread_mutex_unlock(&li->li_root_mutex); + ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } /* free entry and writer lock */ diff --git a/servers/slapd/back-ldbm/nextid.c b/servers/slapd/back-ldbm/nextid.c index e29d86b6ca..25841ca86d 100644 --- a/servers/slapd/back-ldbm/nextid.c +++ b/servers/slapd/back-ldbm/nextid.c @@ -102,7 +102,7 @@ next_id( Backend *be ) struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id; - pthread_mutex_lock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); /* first time in here since startup - try to read the nexid */ if ( li->li_nextid == NOID ) { @@ -128,7 +128,7 @@ next_id( Backend *be ) (void) next_id_write( be, li->li_nextid ); #endif - pthread_mutex_unlock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); return( id ); } @@ -138,10 +138,10 @@ next_id_return( Backend *be, ID id ) #ifdef SLAPD_NEXTID_RETURN struct ldbminfo *li = (struct ldbminfo *) be->be_private; - pthread_mutex_lock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); if ( id != li->li_nextid - 1 ) { - pthread_mutex_unlock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); return; } @@ -151,7 +151,7 @@ next_id_return( Backend *be, ID id ) (void) next_id_write( be, li->li_nextid ); #endif - pthread_mutex_unlock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); #endif } @@ -161,7 +161,7 @@ next_id_get( Backend *be ) struct ldbminfo *li = (struct ldbminfo *) be->be_private; ID id; - pthread_mutex_lock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); /* first time in here since startup - try to read the nexid */ if ( li->li_nextid == NOID ) { @@ -178,7 +178,7 @@ next_id_get( Backend *be ) id = li->li_nextid; - pthread_mutex_unlock( &li->li_nextid_mutex ); + ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); return( id ); } diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 584f690c4e..5b19327104 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -140,9 +140,9 @@ ldbm_back_search( for ( id = idl_firstid( candidates ); id != NOID; id = idl_nextid( candidates, id ) ) { /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); idl_free( candidates ); free( rbuf ); if( realBase != NULL) { @@ -150,13 +150,13 @@ ldbm_back_search( } return( 0 ); } - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check time limit */ - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); time( ¤ttime ); if ( tlimit != -1 && currenttime > stoptime ) { - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); send_ldap_search_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, NULL, nrefs > 0 ? rbuf : NULL, nentries ); @@ -167,7 +167,7 @@ ldbm_back_search( } return( 0 ); } - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); /* get the entry with reader lock */ if ( (e = id2entry_r( be, id )) == NULL ) { @@ -286,7 +286,7 @@ ldbm_back_search( cache_return_entry_r( &li->li_cache, e ); } - pthread_yield(); + ldap_pvt_thread_yield(); } idl_free( candidates ); if ( nrefs > 0 ) { diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index cbfc68fb4d..8695ffa616 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -72,25 +72,25 @@ passwd_back_search( for ( pw = getpwent(); pw != NULL; pw = getpwent() ) { /* check for abandon */ - pthread_mutex_lock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_lock( &op->o_abandonmutex ); if ( op->o_abandon ) { - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); endpwent(); return( -1 ); } - pthread_mutex_unlock( &op->o_abandonmutex ); + ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check time limit */ - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); time( ¤ttime ); if ( currenttime > stoptime ) { - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED, NULL, NULL ); endpwent(); return( 0 ); } - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); e = pw2entry( be, pw ); diff --git a/servers/slapd/back-perl/add.c b/servers/slapd/back-perl/add.c index 6ff3b8d1ca..9b4e09f7df 100644 --- a/servers/slapd/back-perl/add.c +++ b/servers/slapd/back-perl/add.c @@ -34,7 +34,7 @@ perl_back_add( PerlBackend *perl_back = (PerlBackend *) be->be_private; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -58,7 +58,7 @@ perl_back_add( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); if( return_code != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); diff --git a/servers/slapd/back-perl/bind.c b/servers/slapd/back-perl/bind.c index 4304348128..b4cd6ca45c 100644 --- a/servers/slapd/back-perl/bind.c +++ b/servers/slapd/back-perl/bind.c @@ -45,7 +45,7 @@ perl_back_bind( *edn = NULL; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -70,7 +70,7 @@ perl_back_bind( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); Debug( LDAP_DEBUG_ANY, "Perl BIND\n", 0, 0, 0 ); diff --git a/servers/slapd/back-perl/close.c b/servers/slapd/back-perl/close.c index 34d5a78f15..8e320e6b59 100644 --- a/servers/slapd/back-perl/close.c +++ b/servers/slapd/back-perl/close.c @@ -32,11 +32,11 @@ perl_back_close( Backend *be ) { - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); perl_destruct(perl_interpreter); perl_free(perl_interpreter); - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); } diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c index 9ade62f55d..03656cf273 100644 --- a/servers/slapd/back-perl/compare.c +++ b/servers/slapd/back-perl/compare.c @@ -43,7 +43,7 @@ perl_back_compare( "", "not yet implemented" ); #ifdef notdef - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -67,7 +67,7 @@ perl_back_compare( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); if( return_code != 0 ) { send_ldap_result( conn, op, LDAP_COMPARE_TRUE, "", "" ); diff --git a/servers/slapd/back-perl/delete.c b/servers/slapd/back-perl/delete.c index d367559183..956cc594c7 100644 --- a/servers/slapd/back-perl/delete.c +++ b/servers/slapd/back-perl/delete.c @@ -33,7 +33,7 @@ perl_back_delete( PerlBackend *perl_back = (PerlBackend *) be->be_private; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -57,7 +57,7 @@ perl_back_delete( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); if( return_code != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c index a5e078c075..a8026909a7 100644 --- a/servers/slapd/back-perl/init.c +++ b/servers/slapd/back-perl/init.c @@ -24,7 +24,7 @@ PerlInterpreter *perl_interpreter = NULL; -pthread_mutex_t perl_interpreter_mutex; +ldap_pvt_thread_mutex_t perl_interpreter_mutex; /********************************************************** @@ -46,8 +46,8 @@ perl_back_init( perl_parse(perl_interpreter, NULL, 3, embedding, (char **)NULL); perl_run(perl_interpreter); - pthread_mutex_init( &perl_interpreter_mutex, - pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &perl_interpreter_mutex, + ldap_pvt_thread_mutexattr_default ); } be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) ); diff --git a/servers/slapd/back-perl/modify.c b/servers/slapd/back-perl/modify.c index 064701d1f6..c0f8227a01 100644 --- a/servers/slapd/back-perl/modify.c +++ b/servers/slapd/back-perl/modify.c @@ -38,7 +38,7 @@ perl_back_modify( PerlBackend *perl_back = (PerlBackend *)be->be_private; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -89,7 +89,7 @@ perl_back_modify( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); if( return_code != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); diff --git a/servers/slapd/back-perl/modrdn.c b/servers/slapd/back-perl/modrdn.c index 32d9433af6..9259e21314 100644 --- a/servers/slapd/back-perl/modrdn.c +++ b/servers/slapd/back-perl/modrdn.c @@ -36,7 +36,7 @@ perl_back_modrdn( PerlBackend *perl_back = (PerlBackend *) be->be_private; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -61,7 +61,7 @@ perl_back_modrdn( PUTBACK; FREETMPS; LEAVE ; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); if( return_code != 0 ) { send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); diff --git a/servers/slapd/back-perl/perl_back.h b/servers/slapd/back-perl/perl_back.h index 445893f805..a8adcd57a1 100644 --- a/servers/slapd/back-perl/perl_back.h +++ b/servers/slapd/back-perl/perl_back.h @@ -10,7 +10,7 @@ LDAP_BEGIN_DECL #define EVAL_BUF_SIZE 500 extern PerlInterpreter *perl_interpreter; -extern pthread_mutex_t perl_interpreter_mutex; +extern ldap_pvt_thread_mutex_t perl_interpreter_mutex; typedef struct perl_backend_instance { char *pb_module_name; diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c index e85435fe65..b53809ba63 100644 --- a/servers/slapd/back-perl/search.c +++ b/servers/slapd/back-perl/search.c @@ -50,7 +50,7 @@ perl_back_search( char *buf; int i; - pthread_mutex_lock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; @@ -95,7 +95,7 @@ perl_back_search( PUTBACK; FREETMPS; LEAVE; } - pthread_mutex_unlock( &perl_interpreter_mutex ); + ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); send_ldap_result( conn, op, err, matched, info ); } diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index fef38c9a47..dad3204984 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -26,7 +26,7 @@ shell_back_abandon( /* no abandon command defined - just kill the process handling it */ if ( si->si_abandon == NULL ) { - pthread_mutex_lock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_opsmutex ); pid = -1; for ( o = conn->c_ops; o != NULL; o = o->o_next ) { if ( o->o_msgid == msgid ) { @@ -34,7 +34,7 @@ shell_back_abandon( break; } } - pthread_mutex_unlock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex ); if ( pid != -1 ) { Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", pid, diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index 9a6663bb5b..61752d3278 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -38,9 +38,9 @@ shell_back_add( fprintf( wfp, "ADD\n" ); fprintf( wfp, "msgid: %ld\n", op->o_msgid ); print_suffixes( wfp, be ); - pthread_mutex_lock( &entry2str_mutex ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); fprintf( wfp, "%s", entry2str( e, &len, 0 ) ); - pthread_mutex_unlock( &entry2str_mutex ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); fclose( wfp ); /* read in the result and send it along */ diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 7d715fe40d..be069201f9 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -258,13 +258,13 @@ be_isroot_pw( Backend *be, char *ndn, struct berval *cred ) } #ifdef SLAPD_CRYPT - pthread_mutex_lock( &crypt_mutex ); + ldap_pvt_thread_mutex_lock( &crypt_mutex ); #endif result = lutil_passwd( cred->bv_val, be->be_root_pw ); #ifdef SLAPD_CRYPT - pthread_mutex_unlock( &crypt_mutex ); + ldap_pvt_thread_mutex_unlock( &crypt_mutex ); #endif return result == 0; diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 0a64185499..17790f739f 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -135,7 +135,7 @@ do_bind( free( cred.bv_val ); } - pthread_mutex_lock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_dnmutex ); conn->c_protocol = version; @@ -149,7 +149,7 @@ do_bind( conn->c_dn = NULL; } - pthread_mutex_unlock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_dnmutex ); send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); return; @@ -168,7 +168,7 @@ do_bind( free( cred.bv_val ); } if ( cred.bv_len == 0 ) { - pthread_mutex_lock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_dnmutex ); conn->c_protocol = version; @@ -182,7 +182,7 @@ do_bind( conn->c_dn = NULL; } - pthread_mutex_unlock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_dnmutex ); send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); @@ -203,7 +203,7 @@ do_bind( ndn = suffixAlias( ndn, op, be ); if ( (*be->be_bind)( be, conn, op, ndn, method, &cred, &edn ) == 0 ) { - pthread_mutex_lock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_dnmutex ); conn->c_protocol = version; @@ -228,7 +228,7 @@ do_bind( Debug( LDAP_DEBUG_TRACE, "do_bind: bound \"%s\" to \"%s\"\n", conn->c_cdn, conn->c_dn, method ); - pthread_mutex_unlock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_dnmutex ); /* send this here to avoid a race condition */ send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL ); diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 159f01ef0f..563d33bd50 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -27,13 +27,13 @@ connection_operation( void *arg_v ) struct co_arg *arg = arg_v; unsigned long len; - pthread_mutex_lock( &arg->co_conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex ); arg->co_conn->c_opsinitiated++; - pthread_mutex_unlock( &arg->co_conn->c_opsmutex ); + ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex ); - pthread_mutex_lock( &ops_mutex ); + ldap_pvt_thread_mutex_lock( &ops_mutex ); ops_initiated++; - pthread_mutex_unlock( &ops_mutex ); + ldap_pvt_thread_mutex_unlock( &ops_mutex ); switch ( arg->co_op->o_tag ) { case LDAP_REQ_BIND: @@ -87,23 +87,23 @@ connection_operation( void *arg_v ) break; } - pthread_mutex_lock( &arg->co_conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex ); arg->co_conn->c_opscompleted++; slap_op_delete( &arg->co_conn->c_ops, arg->co_op ); - pthread_mutex_unlock( &arg->co_conn->c_opsmutex ); + ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex ); free( (char *) arg ); - pthread_mutex_lock( &ops_mutex ); + ldap_pvt_thread_mutex_lock( &ops_mutex ); ops_completed++; - pthread_mutex_unlock( &ops_mutex ); + ldap_pvt_thread_mutex_unlock( &ops_mutex ); - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); active_threads--; if( active_threads < 1 ) { - pthread_cond_signal(&active_threads_cond); + ldap_pvt_thread_cond_signal(&active_threads_cond); } - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); return NULL; } @@ -112,9 +112,6 @@ connection_activity( Connection *conn ) { -#ifndef HAVE_PTHREAD_DETACH - pthread_attr_t attr; -#endif int status; struct co_arg *arg; unsigned long tag, len; @@ -181,68 +178,29 @@ connection_activity( arg = (struct co_arg *) ch_malloc( sizeof(struct co_arg) ); arg->co_conn = conn; - pthread_mutex_lock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_dnmutex ); if ( conn->c_dn != NULL ) { tmpdn = ch_strdup( conn->c_dn ); } else { tmpdn = NULL; } - pthread_mutex_unlock( &conn->c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_dnmutex ); - pthread_mutex_lock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_lock( &conn->c_opsmutex ); arg->co_op = slap_op_add( &conn->c_ops, ber, msgid, tag, tmpdn, conn->c_opsinitiated, conn->c_connid ); - pthread_mutex_unlock( &conn->c_opsmutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex ); if ( tmpdn != NULL ) { free( tmpdn ); } -#ifdef HAVE_PTHREAD_DETACH - if ( status = pthread_create( &arg->co_op->o_tid, NULL, - connection_operation, (void *) arg ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "pthread_create failed (%d)\n", status, 0, 0 ); - } else { - pthread_mutex_lock( &active_threads_mutex ); - active_threads++; - pthread_mutex_unlock( &active_threads_mutex ); - } - -#if !defined(HAVE_PTHREADS_D4) - pthread_detach( arg->co_op->o_tid ); -#else - pthread_detach( &arg->co_op->o_tid ); -#endif - -#else /* !pthread detach */ - - pthread_attr_init( &attr ); - pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); -#if !defined(HAVE_PTHREADS_D4) - /* POSIX_THREADS or compatible - * This is a draft 10 or standard pthreads implementation - */ - if ( status = pthread_create( &arg->co_op->o_tid, &attr, + if ( status = ldap_pvt_thread_create( &arg->co_op->o_tid, 1, connection_operation, (void *) arg ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "pthread_create failed (%d)\n", status, 0, 0 ); + Debug( LDAP_DEBUG_ANY, "ldap_pvt_thread_create failed (%d)\n", status, 0, 0 ); } else { - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); active_threads++; - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); } -#else /* pthread draft4 */ - /* - * This is a draft 4 or earlier pthreads implementation - */ - if ( status = pthread_create( &arg->co_op->o_tid, attr, - connection_operation, (void *) arg ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "pthread_create failed (%d)\n", status, 0, 0 ); - } else { - pthread_mutex_lock( &active_threads_mutex ); - active_threads++; - pthread_mutex_unlock( &active_threads_mutex ); - } -#endif /* pthread draft4 */ - pthread_attr_destroy( &attr ); -#endif } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 546598927c..4e2ac8756c 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -90,13 +90,10 @@ slapd_daemon( c[i].c_sb.sb_ber.ber_end = NULL; c[i].c_writewaiter = 0; c[i].c_connid = 0; - pthread_mutex_init( &c[i].c_dnmutex, - pthread_mutexattr_default ); - pthread_mutex_init( &c[i].c_opsmutex, - pthread_mutexattr_default ); - pthread_mutex_init( &c[i].c_pdumutex, - pthread_mutexattr_default ); - pthread_cond_init( &c[i].c_wcv, pthread_condattr_default ); + ldap_pvt_thread_mutex_init( &c[i].c_dnmutex ); + ldap_pvt_thread_mutex_init( &c[i].c_opsmutex ); + ldap_pvt_thread_mutex_init( &c[i].c_pdumutex ); + ldap_pvt_thread_cond_init( &c[i].c_wcv ); } if ( (tcps = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) { @@ -173,12 +170,12 @@ slapd_daemon( zero.tv_sec = 0; zero.tv_usec = 0; - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); Debug( LDAP_DEBUG_CONNS, "listening for connections on %d, activity on:", tcps, 0, 0 ); - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { FD_SET( c[i].c_sb.sb_sd, &readfds ); @@ -191,7 +188,7 @@ slapd_daemon( } } Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); Debug( LDAP_DEBUG_CONNS, "before select active_threads %d\n", active_threads, 0, 0 ); @@ -200,7 +197,7 @@ slapd_daemon( #else tvp = active_threads ? &zero : NULL; #endif - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); switch ( i = select( dtblsize, &readfds, &writefds, 0, tvp ) ) { case -1: /* failure - try again */ @@ -213,19 +210,19 @@ slapd_daemon( case 0: /* timeout - let threads run */ Debug( LDAP_DEBUG_CONNS, "select timeout - yielding\n", 0, 0, 0 ); - pthread_yield(); + ldap_pvt_thread_yield(); continue; default: /* something happened - deal with it */ Debug( LDAP_DEBUG_CONNS, "select activity on %d descriptors\n", i, 0, 0 ); ; /* FALL */ } - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); time( ¤ttime ); - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); /* new connection */ - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); if ( FD_ISSET( tcps, &readfds ) ) { len = sizeof(from); if ( (ns = accept( tcps, (struct sockaddr *) &from, @@ -234,7 +231,7 @@ slapd_daemon( "accept() failed errno %d (%s)", errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno] : "unknown", 0 ); - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); continue; } if ( ioctl( ns, FIONBIO, (caddr_t) &on ) == -1 ) { @@ -292,15 +289,15 @@ slapd_daemon( 0, 0 ); close(ns); - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); continue; } #endif /* HAVE_TCPD */ c[ns].c_sb.sb_sd = ns; - pthread_mutex_lock( &ops_mutex ); + ldap_pvt_thread_mutex_lock( &ops_mutex ); c[ns].c_connid = num_conns++; - pthread_mutex_unlock( &ops_mutex ); + ldap_pvt_thread_mutex_unlock( &ops_mutex ); Statslog( LDAP_DEBUG_STATS, "conn=%d fd=%d connection from %s (%s) accepted.\n", @@ -321,7 +318,7 @@ slapd_daemon( c[ns].c_domain = ch_strdup( client_name == NULL ? "" : client_name ); - pthread_mutex_lock( &c[ns].c_dnmutex ); + ldap_pvt_thread_mutex_lock( &c[ns].c_dnmutex ); if ( c[ns].c_dn != NULL ) { free( c[ns].c_dn ); c[ns].c_dn = NULL; @@ -330,12 +327,12 @@ slapd_daemon( free( c[ns].c_cdn ); c[ns].c_cdn = NULL; } - pthread_mutex_unlock( &c[ns].c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &c[ns].c_dnmutex ); c[ns].c_starttime = currenttime; c[ns].c_opsinitiated = 0; c[ns].c_opscompleted = 0; } - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); Debug( LDAP_DEBUG_CONNS, "activity on:", 0, 0, 0 ); for ( i = 0; i < dtblsize; i++ ) { @@ -360,11 +357,11 @@ slapd_daemon( Debug( LDAP_DEBUG_CONNS, "signaling write waiter on %d\n", i, 0, 0 ); - pthread_mutex_lock( &active_threads_mutex ); - pthread_cond_signal( &c[i].c_wcv ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_cond_signal( &c[i].c_wcv ); c[i].c_writewaiter = 0; active_threads++; - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); } if ( FD_ISSET( i, &readfds ) ) { @@ -375,19 +372,19 @@ slapd_daemon( } } - pthread_yield(); + ldap_pvt_thread_yield(); } close( tcps ); - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); Debug( LDAP_DEBUG_ANY, "slapd shutting down - waiting for %d threads to terminate\n", active_threads, 0, 0 ); while ( active_threads > 0 ) { - pthread_cond_wait(&active_threads_cond, &active_threads_mutex); + ldap_pvt_thread_cond_wait(&active_threads_cond, &active_threads_mutex); } - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); /* let backends do whatever cleanup they need to do */ Debug( LDAP_DEBUG_TRACE, @@ -403,7 +400,7 @@ set_shutdown( int sig ) { Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 ); slapd_shutdown = 1; - pthread_kill( listener_tid, LDAP_SIGUSR1 ); + ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 ); (void) SIGNAL( LDAP_SIGUSR2, set_shutdown ); (void) SIGNAL( SIGTERM, set_shutdown ); (void) SIGNAL( SIGINT, set_shutdown ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index fedab892fa..239b97434b 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -220,8 +220,8 @@ entry_free( Entry *e ) /* XXX check that no reader/writer locks exist */ #ifdef LDAP_DEBUG - assert( !pthread_rdwr_wchk_np(&e->e_rdwr) && - !pthread_rdwr_rchk_np(&e->e_rdwr) ); + assert( !ldap_pvt_thread_rdwr_wchk(&e->e_rdwr) && + !ldap_pvt_thread_rdwr_rchk(&e->e_rdwr) ); #endif if ( e->e_dn != NULL ) { @@ -243,9 +243,9 @@ entry_rdwr_lock(Entry *e, int rw) Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n", rw ? "w" : "r", e->e_id, 0); if (rw) - return pthread_rdwr_wlock_np(&e->e_rdwr); + return ldap_pvt_thread_rdwr_wlock(&e->e_rdwr); else - return pthread_rdwr_rlock_np(&e->e_rdwr); + return ldap_pvt_thread_rdwr_rlock(&e->e_rdwr); } int @@ -266,9 +266,9 @@ entry_rdwr_unlock(Entry *e, int rw) Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n", rw ? "w" : "r", e->e_id, 0); if (rw) - return pthread_rdwr_wunlock_np(&e->e_rdwr); + return ldap_pvt_thread_rdwr_wunlock(&e->e_rdwr); else - return pthread_rdwr_runlock_np(&e->e_rdwr); + return ldap_pvt_thread_rdwr_runlock(&e->e_rdwr); } int @@ -286,5 +286,5 @@ entry_rdwr_wunlock(Entry *e) int entry_rdwr_init(Entry *e) { - return pthread_rdwr_init_np(&e->e_rdwr, NULL); + return ldap_pvt_thread_rdwr_init( &e->e_rdwr ); } diff --git a/servers/slapd/init.c b/servers/slapd/init.c index f92d8bba73..2b6cd5a725 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -26,7 +26,7 @@ int ldap_syslog; int ldap_syslog_level = LOG_DEBUG; char *default_referral; time_t starttime; -pthread_t listener_tid; +ldap_pvt_thread_t listener_tid; int g_argc; char **g_argv; @@ -34,46 +34,48 @@ char **g_argv; * global variables that need mutex protection */ int active_threads; -pthread_mutex_t active_threads_mutex; -pthread_cond_t active_threads_cond; +ldap_pvt_thread_mutex_t active_threads_mutex; +ldap_pvt_thread_cond_t active_threads_cond; time_t currenttime; -pthread_mutex_t currenttime_mutex; +ldap_pvt_thread_mutex_t currenttime_mutex; -pthread_mutex_t new_conn_mutex; +ldap_pvt_thread_mutex_t new_conn_mutex; #ifdef SLAPD_CRYPT -pthread_mutex_t crypt_mutex; +ldap_pvt_thread_mutex_t crypt_mutex; #endif int num_conns; long ops_initiated; long ops_completed; -pthread_mutex_t ops_mutex; +ldap_pvt_thread_mutex_t ops_mutex; long num_entries_sent; long num_bytes_sent; -pthread_mutex_t num_sent_mutex; +ldap_pvt_thread_mutex_t num_sent_mutex; /* * these mutexes must be used when calling the entry2str() * routine since it returns a pointer to static data. */ -pthread_mutex_t entry2str_mutex; -pthread_mutex_t replog_mutex; +ldap_pvt_thread_mutex_t entry2str_mutex; +ldap_pvt_thread_mutex_t replog_mutex; void init( void ) { - pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default ); - pthread_cond_init( &active_threads_cond, pthread_condattr_default ); - - pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default ); - pthread_mutex_init( ¤ttime_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &entry2str_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &replog_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &ops_mutex, pthread_mutexattr_default ); - pthread_mutex_init( &num_sent_mutex, pthread_mutexattr_default ); + (void) ldap_pvt_thread_initialize(); + + ldap_pvt_thread_mutex_init( &active_threads_mutex ); + ldap_pvt_thread_cond_init( &active_threads_cond ); + + ldap_pvt_thread_mutex_init( &new_conn_mutex ); + ldap_pvt_thread_mutex_init( ¤ttime_mutex ); + ldap_pvt_thread_mutex_init( &entry2str_mutex ); + ldap_pvt_thread_mutex_init( &replog_mutex ); + ldap_pvt_thread_mutex_init( &ops_mutex ); + ldap_pvt_thread_mutex_init( &num_sent_mutex ); #ifdef SLAPD_CRYPT - pthread_mutex_init( &crypt_mutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &crypt_mutex ); #endif } diff --git a/servers/slapd/main.c b/servers/slapd/main.c index f529cb5eca..caa19f866f 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -195,19 +195,15 @@ main( int argc, char **argv ) time( &starttime ); - if ( status = pthread_create( &listener_tid, NULL, + if ( status = ldap_pvt_thread_create( &listener_tid, 0, slapd_daemon, (void *) port ) != 0 ) { Debug( LDAP_DEBUG_ANY, - "listener pthread_create failed (%d)\n", status, 0, 0 ); + "listener ldap_pvt_thread_create failed (%d)\n", status, 0, 0 ); exit( 1 ); } -#ifdef HAVE_PTHREADS_FINAL - pthread_join( listener_tid, (void *) NULL ); -#else - pthread_join( listener_tid, (void *) &status ); -#endif + ldap_pvt_thread_join( listener_tid, (void *) NULL ); return 0; @@ -230,9 +226,9 @@ main( int argc, char **argv ) c.c_sb.sb_ber.ber_buf = NULL; c.c_sb.sb_ber.ber_ptr = NULL; c.c_sb.sb_ber.ber_end = NULL; - pthread_mutex_init( &c.c_dnmutex, pthread_mutexattr_default ); - pthread_mutex_init( &c.c_opsmutex, pthread_mutexattr_default ); - pthread_mutex_init( &c.c_pdumutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &c.c_dnmutex ); + ldap_pvt_thread_mutex_init( &c.c_opsmutex ); + ldap_pvt_thread_mutex_init( &c.c_pdumutex ); #ifdef notdefcldap c.c_sb.sb_addrs = (void **) saddrlist; c.c_sb.sb_fromaddr = &faddr; @@ -262,9 +258,9 @@ main( int argc, char **argv ) while ( (tag = ber_get_next( &c.c_sb, &len, &ber )) == LDAP_TAG_MESSAGE ) { - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); time( ¤ttime ); - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); if ( (tag = ber_get_int( &ber, &msgid )) != LDAP_TAG_MSGID ) { diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index fcc040a18e..7d07f9cb31 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -250,7 +250,7 @@ add_lastmods( Operation *op, LDAPModList **modlist ) tmp->ml_next = *modlist; *modlist = tmp; - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME ltm = gmtime( ¤ttime ); strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); @@ -258,7 +258,7 @@ add_lastmods( Operation *op, LDAPModList **modlist ) ltm = localtime( ¤ttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); #endif - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); tmp = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) ); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index f9514fd519..df9c788fbb 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -68,7 +68,7 @@ monitor_info( Connection *conn, Operation *op ) nwritewaiters = 0; nreadwaiters = 0; - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { nconns++; @@ -78,7 +78,7 @@ monitor_info( Connection *conn, Operation *op ) if ( c[i].c_gettingber ) { nreadwaiters++; } - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME ltm = gmtime( &c[i].c_starttime ); strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); @@ -86,21 +86,21 @@ monitor_info( Connection *conn, Operation *op ) ltm = localtime( &c[i].c_starttime ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); #endif - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); - pthread_mutex_lock( &c[i].c_dnmutex ); + ldap_pvt_thread_mutex_lock( &c[i].c_dnmutex ); sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i, buf2, c[i].c_opsinitiated, c[i].c_opscompleted, c[i].c_cdn ? c[i].c_cdn : "NULLDN", c[i].c_gettingber ? "r" : "", c[i].c_writewaiter ? "w" : "" ); - pthread_mutex_unlock( &c[i].c_dnmutex ); + ldap_pvt_thread_mutex_unlock( &c[i].c_dnmutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "connection", vals ); } } - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); sprintf( buf, "%d", nconns ); val.bv_val = buf; @@ -147,7 +147,7 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "bytessent", vals ); - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME ltm = gmtime( ¤ttime ); strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); @@ -155,12 +155,12 @@ monitor_info( Connection *conn, Operation *op ) ltm = localtime( ¤ttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); #endif - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "currenttime", vals ); - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); #ifndef LDAP_LOCALTIME ltm = gmtime( &starttime ); strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); @@ -168,7 +168,7 @@ monitor_info( Connection *conn, Operation *op ) ltm = localtime( &starttime ); strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); #endif - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "starttime", vals ); @@ -178,8 +178,8 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "nbackends", vals ); -#ifdef HAVE_THR - sprintf( buf, "%d", thr_getconcurrency() ); +#ifdef HAVE_THREAD_CONCURRENCY + sprintf( buf, "%d", ldap_pvt_thread_getconcurrency() ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "concurrency", vals ); diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index 56085eeb73..bf9590de98 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -21,7 +21,7 @@ slap_op_free( Operation *op ) if ( op->o_ndn != NULL ) { free( op->o_ndn ); } - /* pthread_mutex_destroy( &op->o_abandonmutex ); */ + /* ldap_pvt_thread_mutex_destroy( &op->o_abandonmutex ); */ free( (char *) op ); } @@ -42,8 +42,7 @@ slap_op_add( ; /* NULL */ *tmp = (Operation *) calloc( 1, sizeof(Operation) ); - pthread_mutex_init( &(*tmp)->o_abandonmutex, - pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &(*tmp)->o_abandonmutex ); (*tmp)->o_ber = ber; (*tmp)->o_msgid = msgid; (*tmp)->o_tag = tag; @@ -52,9 +51,9 @@ slap_op_add( (*tmp)->o_dn = ch_strdup( dn != NULL ? dn : "" ); (*tmp)->o_ndn = dn_normalize_case( ch_strdup( (*tmp)->o_dn ) ); - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); (*tmp)->o_time = currenttime; - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); (*tmp)->o_opid = id; (*tmp)->o_connid = connid; (*tmp)->o_next = NULL; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index b519ffb967..9484978778 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -247,19 +247,19 @@ extern long num_entries_sent; extern long ops_completed; extern long ops_initiated; -extern pthread_mutex_t active_threads_mutex; -extern pthread_cond_t active_threads_cond; - -extern pthread_mutex_t currenttime_mutex; -extern pthread_mutex_t entry2str_mutex; -extern pthread_mutex_t new_conn_mutex; -extern pthread_mutex_t num_sent_mutex; -extern pthread_mutex_t ops_mutex; -extern pthread_mutex_t replog_mutex; +extern ldap_pvt_thread_mutex_t active_threads_mutex; +extern ldap_pvt_thread_cond_t active_threads_cond; + +extern ldap_pvt_thread_mutex_t currenttime_mutex; +extern ldap_pvt_thread_mutex_t entry2str_mutex; +extern ldap_pvt_thread_mutex_t new_conn_mutex; +extern ldap_pvt_thread_mutex_t num_sent_mutex; +extern ldap_pvt_thread_mutex_t ops_mutex; +extern ldap_pvt_thread_mutex_t replog_mutex; #ifdef SLAPD_CRYPT -extern pthread_mutex_t crypt_mutex; +extern ldap_pvt_thread_mutex_t crypt_mutex; #endif -extern pthread_t listener_tid; +extern ldap_pvt_thread_t listener_tid; extern struct acl *global_acl; extern struct objclass *global_oc; extern time_t currenttime; diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index f0f8818a3c..c1bcff91d5 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -33,10 +33,10 @@ replog( return; } - pthread_mutex_lock( &replog_mutex ); + ldap_pvt_thread_mutex_lock( &replog_mutex ); if ( (fp = lock_fopen( be->be_replogfile ? be->be_replogfile : replogfile, "a", &lfp )) == NULL ) { - pthread_mutex_unlock( &replog_mutex ); + ldap_pvt_thread_mutex_unlock( &replog_mutex ); return; } @@ -92,7 +92,7 @@ replog( case LDAP_REQ_ADD: e = change; fprintf( fp, "changetype: add\n" ); - pthread_mutex_lock( &entry2str_mutex ); + ldap_pvt_thread_mutex_lock( &entry2str_mutex ); tmp = entry2str( e, &len, 0 ); while ( (tmp = strchr( tmp, '\n' )) != NULL ) { tmp++; @@ -100,7 +100,7 @@ replog( break; } fprintf( fp, "%s", tmp ); - pthread_mutex_unlock( &entry2str_mutex ); + ldap_pvt_thread_mutex_unlock( &entry2str_mutex ); break; case LDAP_REQ_DELETE: @@ -116,5 +116,5 @@ replog( fprintf( fp, "\n" ); lock_fclose( fp, lfp ); - pthread_mutex_unlock( &replog_mutex ); + ldap_pvt_thread_mutex_unlock( &replog_mutex ); } diff --git a/servers/slapd/result.c b/servers/slapd/result.c index af4498bc9f..1e9384f51f 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -83,14 +83,14 @@ send_ldap_result2( } /* write only one pdu at a time - wait til it's our turn */ - pthread_mutex_lock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_lock( &conn->c_pdumutex ); /* write the pdu */ bytes = ber->ber_ptr - ber->ber_buf; - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); while ( conn->c_connid == op->o_connid && ber_flush( &conn->c_sb, ber, 1 ) != 0 ) { - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); /* * we got an error. if it's ewouldblock, we need to * wait on the socket being writable. otherwise, figure @@ -104,33 +104,33 @@ send_ldap_result2( if ( errno != EWOULDBLOCK && errno != EAGAIN ) { close_connection( conn, op->o_connid, op->o_opid ); - pthread_mutex_unlock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_pdumutex ); return; } /* wait for socket to be write-ready */ - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); active_threads--; conn->c_writewaiter = 1; - pthread_kill( listener_tid, LDAP_SIGUSR1 ); + ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 ); - pthread_cond_wait( &conn->c_wcv, &active_threads_mutex ); + ldap_pvt_thread_cond_wait( &conn->c_wcv, &active_threads_mutex ); if( active_threads < 1 ) { - pthread_cond_signal(&active_threads_cond); + ldap_pvt_thread_cond_signal(&active_threads_cond); } - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); - pthread_yield(); - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_yield(); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); } - pthread_mutex_unlock( &new_conn_mutex ); - pthread_mutex_unlock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_pdumutex ); - pthread_mutex_lock( &num_sent_mutex ); + ldap_pvt_thread_mutex_lock( &num_sent_mutex ); num_bytes_sent += bytes; - pthread_mutex_unlock( &num_sent_mutex ); + ldap_pvt_thread_mutex_unlock( &num_sent_mutex ); Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d RESULT err=%d tag=%d nentries=%d\n", conn->c_connid, @@ -319,13 +319,13 @@ send_search_entry( } /* write only one pdu at a time - wait til it's our turn */ - pthread_mutex_lock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_lock( &conn->c_pdumutex ); bytes = ber->ber_ptr - ber->ber_buf; - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); while ( conn->c_connid == op->o_connid && ber_flush( &conn->c_sb, ber, 1 ) != 0 ) { - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); /* * we got an error. if it's ewouldblock, we need to * wait on the socket being writable. otherwise, figure @@ -339,34 +339,34 @@ send_search_entry( if ( errno != EWOULDBLOCK && errno != EAGAIN ) { close_connection( conn, op->o_connid, op->o_opid ); - pthread_mutex_unlock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_pdumutex ); return( -1 ); } /* wait for socket to be write-ready */ - pthread_mutex_lock( &active_threads_mutex ); + ldap_pvt_thread_mutex_lock( &active_threads_mutex ); active_threads--; conn->c_writewaiter = 1; - pthread_kill( listener_tid, LDAP_SIGUSR1 ); - pthread_cond_wait( &conn->c_wcv, &active_threads_mutex ); + ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 ); + ldap_pvt_thread_cond_wait( &conn->c_wcv, &active_threads_mutex ); if( active_threads < 1 ) { - pthread_cond_signal(&active_threads_cond); + ldap_pvt_thread_cond_signal(&active_threads_cond); } - pthread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); - pthread_yield(); - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_yield(); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); } - pthread_mutex_unlock( &new_conn_mutex ); - pthread_mutex_unlock( &conn->c_pdumutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &conn->c_pdumutex ); - pthread_mutex_lock( &num_sent_mutex ); + ldap_pvt_thread_mutex_lock( &num_sent_mutex ); num_bytes_sent += bytes; num_entries_sent++; - pthread_mutex_unlock( &num_sent_mutex ); + ldap_pvt_thread_mutex_unlock( &num_sent_mutex ); - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); if ( conn->c_connid == op->o_connid ) { rc = 0; Statslog( LDAP_DEBUG_STATS2, "conn=%d op=%d ENTRY dn=\"%s\"\n", @@ -374,7 +374,7 @@ send_search_entry( } else { rc = -1; } - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 ); @@ -447,7 +447,7 @@ str2result( void close_connection( Connection *conn, int opconnid, int opid ) { - pthread_mutex_lock( &new_conn_mutex ); + ldap_pvt_thread_mutex_lock( &new_conn_mutex ); if ( conn->c_sb.sb_sd != -1 && conn->c_connid == opconnid ) { Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d fd=%d closed errno=%d\n", conn->c_connid, @@ -457,5 +457,5 @@ close_connection( Connection *conn, int opconnid, int opid ) conn->c_version = 0; conn->c_protocol = 0; } - pthread_mutex_unlock( &new_conn_mutex ); + ldap_pvt_thread_mutex_unlock( &new_conn_mutex ); } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 00a921b856..c3771d5669 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -27,8 +27,7 @@ #include "../../libraries/liblber/lber-int.h" #include "ldap.h" -#include "lthread.h" -#include "lthread_rdwr.h" +#include "ldap_pvt_thread.h" #include "ldif.h" #ifdef f_next #undef f_next /* name conflict between sys/file.h on SCO and struct filter */ @@ -142,7 +141,7 @@ typedef struct entry { /* really be private to back-ldbm */ char e_state; /* for the cache */ - pthread_rdwr_t e_rdwr; /* reader/writer lock */ + ldap_pvt_thread_rdwr_t e_rdwr; /* reader/writer lock */ #define ENTRY_STATE_DELETED 1 #define ENTRY_STATE_CREATING 2 @@ -303,9 +302,9 @@ typedef struct slap_op { char o_searchbase; /* search base if via CLDAP */ #endif struct slap_op *o_next; /* next operation pending */ - pthread_t o_tid; /* thread handling this op */ + ldap_pvt_thread_t o_tid; /* thread handling this op */ int o_abandon; /* signals op has been abandoned */ - pthread_mutex_t o_abandonmutex; /* signals op has been abandoned */ + ldap_pvt_thread_mutex_t o_abandonmutex; /* signals op has been abandoned */ void *o_private; /* anything the backend needs */ } Operation; @@ -318,7 +317,7 @@ typedef struct slap_conn { Sockbuf c_sb; /* ber connection stuff */ char *c_cdn; /* DN provided by the client */ char *c_dn; /* DN bound to this conn */ - pthread_mutex_t c_dnmutex; /* mutex for c_dn field */ + ldap_pvt_thread_mutex_t c_dnmutex; /* mutex for c_dn field */ int c_protocol; /* version of the LDAP protocol used by client */ int c_authtype; /* auth method used to bind c_dn */ #ifdef LDAP_COMPAT @@ -327,9 +326,9 @@ typedef struct slap_conn { char *c_addr; /* address of client on this conn */ char *c_domain; /* domain of client on this conn */ Operation *c_ops; /* list of pending operations */ - pthread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */ - pthread_mutex_t c_pdumutex; /* only one pdu written at a time */ - pthread_cond_t c_wcv; /* used to wait for sd write-ready*/ + ldap_pvt_thread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */ + ldap_pvt_thread_mutex_t c_pdumutex; /* only one pdu written at a time */ + ldap_pvt_thread_cond_t c_wcv; /* used to wait for sd write-ready*/ int c_gettingber; /* in the middle of ber_get_next */ BerElement *c_currentber; /* ber we're getting */ int c_writewaiter; /* signals write-ready sd waiter */ diff --git a/servers/slapd/tools/Makefile.in b/servers/slapd/tools/Makefile.in index f218a65313..94cdf1969c 100644 --- a/servers/slapd/tools/Makefile.in +++ b/servers/slapd/tools/Makefile.in @@ -18,7 +18,7 @@ BUILD_LDBM = @BUILD_LDBM@ LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries -XLIBS = -lavl -lldif -lldap -llber -lldbm -llthread -llutil +XLIBS = -lavl -lldif -lldbm -lldap_r -llber -llutil XXLIBS = $(LDAPD_LIBS) $(SLAPD_LIBS) \ $(PERL_LDFLAGS) $(LDBM_LIBS) $(KRB_LIBS) $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) diff --git a/servers/slurpd/Makefile.in b/servers/slurpd/Makefile.in index 335ff224d6..9ca6c0044f 100644 --- a/servers/slurpd/Makefile.in +++ b/servers/slurpd/Makefile.in @@ -9,12 +9,10 @@ XSRCS = version.c SRCS = admin.c args.c ch_malloc.c config.c \ fm.c globals.c ldap_op.c lock.c main.c re.c \ - reject.c replica.c replog.c ri.c rq.c sanity.c st.c \ - tsleep.c + reject.c replica.c replog.c ri.c rq.c sanity.c st.c OBJS = admin.o args.o ch_malloc.o config.o \ fm.o globals.o ldap_op.o lock.o main.o re.o \ - reject.o replica.o replog.o ri.o rq.o sanity.o st.o \ - tsleep.o + reject.o replica.o replog.o ri.o rq.o sanity.o st.o LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries @@ -25,7 +23,7 @@ BUILD_SRV = @BUILD_SLURPD@ all-local-srv: slurpd # $(LTHREAD_LIBS) must be last! -XLIBS = -lldif -lldap -llber -llthread -llutil +XLIBS = -lldif -lldap_r -llber -llutil XXLIBS = $(SLURPD_LIBS) $(KRB_LIBS) $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index 5063927180..e63002f826 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -99,7 +99,7 @@ fm( } } } else { - tsleep( sglob->no_work_interval ); + ldap_pvt_thread_sleep( sglob->no_work_interval ); } /* Garbage-collect queue */ @@ -135,9 +135,9 @@ set_shutdown(int x) int i; sglob->slurpd_shutdown = 1; /* set flag */ - pthread_kill( sglob->fm_tid, LDAP_SIGUSR1 ); /* wake up file mgr */ + ldap_pvt_thread_kill( sglob->fm_tid, LDAP_SIGUSR1 ); /* wake up file mgr */ sglob->rq->rq_lock( sglob->rq ); /* lock queue */ - pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */ + ldap_pvt_thread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */ for ( i = 0; i < sglob->num_replicas; i++ ) { (sglob->replicas[ i ])->ri_wake( sglob->replicas[ i ]); } @@ -203,7 +203,7 @@ populate_queue( p, 0, 0 ); } free( p ); - pthread_yield(); + ldap_pvt_thread_yield(); } sglob->srpos = ftell( fp ); } diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c index 91b7e3086f..fed3bbf31d 100644 --- a/servers/slurpd/globals.c +++ b/servers/slurpd/globals.c @@ -60,7 +60,7 @@ init_globals( void ) fprintf( stderr, "Cannot initialize status data\n" ); exit( 1 ); } - pthread_mutex_init( &(g->rej_mutex), pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &(g->rej_mutex) ); if ( Rq_init( &(g->rq)) < 0 ) { fprintf( stderr, "Cannot initialize queue\n" ); exit( 1 ); diff --git a/servers/slurpd/globals.h b/servers/slurpd/globals.h index 365c32ed6c..46c854e663 100644 --- a/servers/slurpd/globals.h +++ b/servers/slurpd/globals.h @@ -23,7 +23,7 @@ LDAP_BEGIN_DECL typedef struct globals { /* Thread ID for file manager thread */ - pthread_t fm_tid; + ldap_pvt_thread_t fm_tid; /* The name of the slapd config file (which is also our config file) */ char *slapd_configfile; /* How long the master slurpd sleeps when there's no work to do */ @@ -49,7 +49,7 @@ typedef struct globals { /* Current offset into slurpd replica logfile */ off_t srpos; /* mutex to serialize access to reject file */ - pthread_mutex_t rej_mutex; + ldap_pvt_thread_mutex_t rej_mutex; /* pointer to status struct */ St *st; /* Pointer to replication queue */ diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c index 5469454cc7..cc094ba446 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -36,7 +36,6 @@ main( return( 1 ); #else - pthread_attr_t attr; int status; int i; @@ -94,13 +93,8 @@ main( #endif /* LDAP_DEBUG */ lutil_detach( 0, 0 ); -#if defined( HAVE_LWP ) - /* - * Need to start a scheduler thread under SunOS 4 - */ - start_lwp_scheduler(); -#endif /* HAVE_LWP */ - + /* initialize thread package */ + ldap_pvt_thread_initialize(); /* * Start threads - one thread for each replica @@ -112,9 +106,10 @@ main( /* * Start the main file manager thread (in fm.c). */ - if ( pthread_create( &(sglob->fm_tid), NULL, fm, (void *) NULL ) - != 0 ) { - Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n", + if ( ldap_pvt_thread_create( &(sglob->fm_tid), + 0, fm, (void *) NULL ) != 0 ) + { + Debug( LDAP_DEBUG_ANY, "file manager ldap_pvt_thread_create failed\n", 0, 0, 0 ); exit( 1 ); @@ -123,20 +118,13 @@ main( /* * Wait for the fm thread to finish. */ -#ifdef HAVE_PTHREADS_FINAL - pthread_join( sglob->fm_tid, (void *) NULL ); -#else - pthread_join( sglob->fm_tid, (void *) &status ); -#endif + ldap_pvt_thread_join( sglob->fm_tid, (void *) NULL ); + /* * Wait for the replica threads to finish. */ for ( i = 0; sglob->replicas[ i ] != NULL; i++ ) { -#ifdef HAVE_PTHREADS_FINAL - pthread_join( sglob->replicas[ i ]->ri_tid, (void *) NULL ); -#else - pthread_join( sglob->replicas[ i ]->ri_tid, (void *) &status ); -#endif + ldap_pvt_thread_join( sglob->replicas[ i ]->ri_tid, (void *) NULL ); } Debug( LDAP_DEBUG_ANY, "slurpd: terminating normally\n", 0, 0, 0 ); sglob->slurpd_shutdown = 1; diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index f44601c1ac..773825c5e1 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -82,7 +82,7 @@ Re_free( } #if !defined( HAVE_LWP ) /* This seems to have problems under SunOS lwp */ - pthread_mutex_destroy( &re->re_mutex ); + ldap_pvt_thread_mutex_destroy( &re->re_mutex ); #endif /* HAVE_LWP */ ch_free( re->re_timestamp ); if (( rh = re->re_replicas ) != NULL ) { @@ -642,7 +642,7 @@ Re_lock( Re *re ) { - return( pthread_mutex_lock( &re->re_mutex )); + return( ldap_pvt_thread_mutex_lock( &re->re_mutex )); } @@ -656,7 +656,7 @@ Re_unlock( Re *re ) { - return( pthread_mutex_unlock( &re->re_mutex )); + return( ldap_pvt_thread_mutex_unlock( &re->re_mutex )); } @@ -697,7 +697,7 @@ Re_init( (*re)->re_mods = NULL; (*re)->re_next = NULL; - pthread_mutex_init( &((*re)->re_mutex), pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &((*re)->re_mutex) ); return 0; } diff --git a/servers/slurpd/reject.c b/servers/slurpd/reject.c index aa7266740b..0d0e606a42 100644 --- a/servers/slurpd/reject.c +++ b/servers/slurpd/reject.c @@ -51,7 +51,7 @@ write_reject( FILE *rfp, *lfp; int rc; - pthread_mutex_lock( &sglob->rej_mutex ); + ldap_pvt_thread_mutex_lock( &sglob->rej_mutex ); sprintf( rejfile, "%s/%s:%d.rej", sglob->slurpd_rdir, ri->ri_hostname, ri->ri_port ); @@ -63,7 +63,7 @@ write_reject( Debug( LDAP_DEBUG_ANY, "Error: write_reject: Cannot create \"%s\": %s\n", rejfile, sys_errlist[ errno ], 0 ); - pthread_mutex_unlock( &sglob->rej_mutex ); + ldap_pvt_thread_mutex_unlock( &sglob->rej_mutex ); return; } else { close( rjfd ); @@ -89,7 +89,7 @@ write_reject( "Error: ldap operation failed, data written to \"%s\"\n", rejfile, 0, 0 ); } - pthread_mutex_unlock( &sglob->rej_mutex ); + ldap_pvt_thread_mutex_unlock( &sglob->rej_mutex ); return; } diff --git a/servers/slurpd/replica.c b/servers/slurpd/replica.c index 7ccd356a15..8e919b274a 100644 --- a/servers/slurpd/replica.c +++ b/servers/slurpd/replica.c @@ -55,9 +55,9 @@ start_replica_thread( ) { /* POSIX_THREADS or compatible */ - if ( pthread_create( &(ri->ri_tid), NULL, replicate, + if ( ldap_pvt_thread_create( &(ri->ri_tid), NULL, replicate, (void *) ri ) != 0 ) { - Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n", + Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" ldap_pvt_thread_create failed\n", ri->ri_hostname, ri->ri_port, 0 ); return -1; } diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index e28e4468f6..2a6166ea9b 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -60,7 +60,7 @@ Ri_process( while ( !sglob->slurpd_shutdown && (( re = rq->rq_gethead( rq )) == NULL )) { /* No work - wait on condition variable */ - pthread_cond_wait( &rq->rq_more, &rq->rq_mutex ); + ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex ); } /* @@ -84,7 +84,7 @@ Ri_process( rc = do_ldap( ri, re, &errmsg ); switch ( rc ) { case DO_LDAP_ERR_RETRYABLE: - tsleep( RETRY_SLEEP_TIME ); + ldap_pvt_thread_sleep( RETRY_SLEEP_TIME ); Debug( LDAP_DEBUG_ANY, "Retrying operation for DN %s on replica %s:%d\n", re->re_dn, ri->ri_hostname, ri->ri_port ); @@ -120,7 +120,7 @@ Ri_process( return 0; } /* No work - wait on condition variable */ - pthread_cond_wait( &rq->rq_more, &rq->rq_mutex ); + ldap_pvt_thread_cond_wait( &rq->rq_more, &rq->rq_mutex ); } re->re_decrefcnt( re ); re = new_re; @@ -145,7 +145,7 @@ Ri_wake( if ( ri == NULL ) { return; } - pthread_kill( ri->ri_tid, LDAP_SIGUSR1 ); + ldap_pvt_thread_kill( ri->ri_tid, LDAP_SIGUSR1 ); (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); } diff --git a/servers/slurpd/rq.c b/servers/slurpd/rq.c index 3fe7285275..46667210b6 100644 --- a/servers/slurpd/rq.c +++ b/servers/slurpd/rq.c @@ -49,7 +49,7 @@ Rq_lock( Rq *rq ) { - return( pthread_mutex_lock( &rq->rq_mutex )); + return( ldap_pvt_thread_mutex_lock( &rq->rq_mutex )); } @@ -61,7 +61,7 @@ Rq_unlock( Rq *rq ) { - return( pthread_mutex_unlock( &rq->rq_mutex )); + return( ldap_pvt_thread_mutex_unlock( &rq->rq_mutex )); } @@ -184,7 +184,7 @@ Rq_add( /* Increment count of items in queue */ rq->rq_nre++; /* wake up any threads waiting for more work */ - pthread_cond_broadcast( &rq->rq_more ); + ldap_pvt_thread_cond_broadcast( &rq->rq_more ); /* ... and unlock the queue */ rq->rq_unlock( rq ); @@ -397,8 +397,8 @@ Rq_init( (*rq)->rq_getcount = Rq_getcount; /* Initialize private data */ - pthread_mutex_init( &((*rq)->rq_mutex), pthread_mutexattr_default ); - pthread_cond_init( &((*rq)->rq_more), pthread_condattr_default ); + ldap_pvt_thread_mutex_init( &((*rq)->rq_mutex) ); + ldap_pvt_thread_cond_init( &((*rq)->rq_more) ); (*rq)->rq_head = NULL; (*rq)->rq_tail = NULL; (*rq)->rq_nre = 0; diff --git a/servers/slurpd/slurp.h b/servers/slurpd/slurp.h index f107793230..ace1eb79ba 100644 --- a/servers/slurpd/slurp.h +++ b/servers/slurpd/slurp.h @@ -31,7 +31,7 @@ #define ldap_debug slurp_debug #include "ldap_log.h" -#include "lthread.h" +#include "ldap_pvt_thread.h" #include "ldapconfig.h" #include "ldif.h" @@ -184,7 +184,7 @@ struct ri { struct stel *ri_stel; /* pointer to Stel for this replica */ unsigned long ri_seq; /* seq number of last repl */ - pthread_t ri_tid; /* ID of thread for this replica */ + ldap_pvt_thread_t ri_tid; /* ID of thread for this replica */ /* Member functions */ int (*ri_process) LDAP_P(( Ri * )); /* process the next repl entry */ @@ -218,7 +218,7 @@ typedef struct re Re; struct re { /* Private data */ - pthread_mutex_t + ldap_pvt_thread_mutex_t re_mutex; /* mutex for this Re */ int re_refcnt; /* ref count, 0 = done */ char *re_timestamp; /* timestamp of this re */ @@ -263,9 +263,9 @@ struct rq { time_t rq_lasttrim; /* Last time we trimmed file */ /* Public data */ - pthread_mutex_t + ldap_pvt_thread_mutex_t rq_mutex; /* mutex for whole queue */ - pthread_cond_t + ldap_pvt_thread_cond_t rq_more; /* condition var - more work added */ /* Member functions */ @@ -309,7 +309,7 @@ typedef struct stel { typedef struct st St; struct st { /* Private data */ - pthread_mutex_t + ldap_pvt_thread_mutex_t st_mutex; /* mutex to serialize access */ Stel **st_data; /* array of pointers to Stel structs */ int st_nreplicas; /* number of repl hosts */ diff --git a/servers/slurpd/st.c b/servers/slurpd/st.c index 3d50e80ce4..fed678b88d 100644 --- a/servers/slurpd/st.c +++ b/servers/slurpd/st.c @@ -43,19 +43,19 @@ St_add( } /* Serialize access to the St struct */ - pthread_mutex_lock( &(st->st_mutex )); + ldap_pvt_thread_mutex_lock( &(st->st_mutex )); st->st_nreplicas++; ind = st->st_nreplicas - 1; st->st_data = ( Stel ** ) ch_realloc( st->st_data, ( st->st_nreplicas * sizeof( Stel * ))); if ( st->st_data == NULL ) { - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return NULL; } st->st_data[ ind ] = ( Stel * ) ch_malloc( sizeof( Stel ) ); if ( st->st_data[ ind ] == NULL ) { - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return NULL; } @@ -64,7 +64,7 @@ St_add( memset( st->st_data[ ind ]->last, 0, sizeof( st->st_data[ ind ]->last )); st->st_data[ ind ]->seq = 0; - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return st->st_data[ ind ]; } @@ -85,7 +85,7 @@ St_write ( if ( st == NULL ) { return -1; } - pthread_mutex_lock( &(st->st_mutex )); + ldap_pvt_thread_mutex_lock( &(st->st_mutex )); if ( st->st_fp == NULL ) { /* Open file */ if (( rc = acquire_lock( sglob->slurpd_status_file, &(st->st_fp), @@ -95,7 +95,7 @@ St_write ( "Error: cannot open status file \"%s\": %s\n", sglob->slurpd_status_file, sys_errlist[ errno ], 0 ); st->st_err_logged = 1; - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return -1; } } else { @@ -113,7 +113,7 @@ St_write ( } fflush( st->st_fp ); - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return 0; } @@ -135,10 +135,10 @@ St_update( return -1; } - pthread_mutex_lock( &(st->st_mutex )); + ldap_pvt_thread_mutex_lock( &(st->st_mutex )); strcpy( stel->last, re->re_timestamp ); stel->seq = re->re_seq; - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return 0; } @@ -164,7 +164,7 @@ St_read( if ( st == NULL ) { return -1; } - pthread_mutex_lock( &(st->st_mutex )); + ldap_pvt_thread_mutex_lock( &(st->st_mutex )); if ( access( sglob->slurpd_status_file, F_OK ) < 0 ) { /* * File doesn't exist, so create it and return. @@ -172,17 +172,17 @@ St_read( if (( fp = fopen( sglob->slurpd_status_file, "w" )) == NULL ) { Debug( LDAP_DEBUG_ANY, "Error: cannot create status file \"%s\"\n", sglob->slurpd_status_file, 0, 0 ); - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return -1; } (void) fclose( fp ); - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); Debug( LDAP_DEBUG_ARGS, "No status file found, defaulting values\n", 0, 0, 0 ); return 0; } if (( rc = acquire_lock( sglob->slurpd_status_file, &fp, &lfp)) < 0 ) { - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return 0; } while ( fgets( buf, sizeof( buf ), fp ) != NULL ) { @@ -232,12 +232,12 @@ St_read( } } (void) relinquish_lock( sglob->slurpd_status_file, fp, lfp); - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return 0; bad: (void) relinquish_lock( sglob->slurpd_status_file, fp, lfp); - pthread_mutex_unlock( &(st->st_mutex )); + ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return -1; } @@ -252,7 +252,7 @@ St_lock( St *st ) { - return( pthread_mutex_lock( &st->st_mutex )); + return( ldap_pvt_thread_mutex_lock( &st->st_mutex )); } @@ -266,7 +266,7 @@ St_unlock( St *st ) { - return( pthread_mutex_unlock( &st->st_mutex )); + return( ldap_pvt_thread_mutex_unlock( &st->st_mutex )); } @@ -289,7 +289,7 @@ St_init( return -1; } - pthread_mutex_init( &((*st)->st_mutex), pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &((*st)->st_mutex) ); (*st)->st_data = NULL; (*st)->st_fp = NULL; (*st)->st_lfp = NULL; diff --git a/servers/slurpd/tsleep.c b/servers/slurpd/tsleep.c deleted file mode 100644 index c21cf7def4..0000000000 --- a/servers/slurpd/tsleep.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 1996 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - */ - -/* - * tsleep.c - allow a thread to sleep without putting the whole process - * (e.g. pod under lwp) to sleep. Contains platform-specific code to - * allow this: - * - * Under non-preemptive threads packages like SunOS lwp, tsleep() adds - * the thread to a list of sleepers. The lwp_scheduler process takes - * care of resuming suspended threads. - * - * Under a fully-preemptive threads package, like Solaris threads, - * tsleep just calls sleep(), and there is no scheduler thread. Life - * is so much simpler... - */ - -#include "portable.h" - -#include -#include -#include /* get sleep() */ - -#include "slurp.h" -#include "globals.h" - - -#if defined( HAVE_LWP ) - -int -tsleep( - time_t interval -) -{ - thread_t mylwp; - tl_t *t, *nt; - time_t now; - - - if ( lwp_self( &mylwp ) < 0 ) { - return -1; - } - time( &now ); - - mon_enter( &sglob->tsl_mon ); - if ( sglob->tsl_list != NULL ) { - for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { - if ( SAMETHREAD( t->tl_tid, mylwp )) { - /* We're already sleeping? */ - t->tl_wake = now + interval; - mon_exit( &sglob->tsl_mon ); - lwp_suspend( mylwp ); - return 0; - } - } - } - nt = (tl_t *) malloc( sizeof( tl_t )); - - nt->tl_next = sglob->tsl_list; - nt->tl_wake = now + interval; - nt->tl_tid = mylwp; - sglob->tsl_list = nt; - mon_exit( &sglob->tsl_mon ); - lwp_suspend( mylwp ); - return 0; -} - -/* - * The lwp_scheduler thread periodically checks to see if any threads - * are due to be resumed. If there are, it resumes them. Otherwise, - * it computes the lesser of ( 1 second ) or ( the minimum time until - * a thread need to be resumed ) and puts itself to sleep for that amount - * of time. - */ -void -lwp_scheduler( - int stackno -) -{ - time_t now, min; - struct timeval interval; - tl_t *t; - - while ( !sglob->slurpd_shutdown ) { - mon_enter( &sglob->tsl_mon ); - time( &now ); - min = 0L; - if ( sglob->tsl_list != NULL ) { - for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { - if (( t->tl_wake > 0L ) && ( t->tl_wake < now )) { - lwp_resume( t->tl_tid ); - t->tl_wake = 0L; - } - if (( t->tl_wake > now ) && ( t->tl_wake < min )) { - min = t->tl_wake; - } - } - } - mon_exit( &sglob->tsl_mon ); - interval.tv_usec = 0L; - if ( min == 0L ) { - interval.tv_sec = 1L; - } else { - interval.tv_sec = min; - } - lwp_sleep( &interval ); - } - mon_enter( &sglob->tsl_mon ); - for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) { - lwp_resume( t->tl_tid ); - } - mon_exit( &sglob->tsl_mon ); - free_stack( stackno ); -} - - -/* - * Create the lwp_scheduler thread. - */ -void -start_lwp_scheduler( void ) -{ - thread_t tid; - stkalign_t *stack; - int stackno; - - if (( stack = get_stack( &stackno )) == NULL ) { - return; - } - lwp_create( &tid, lwp_scheduler, MINPRIO, 0, stack, 1, stackno ); - return; -} - - -#else /* !HAVE_LWP */ - -/* - * Here we assume we have fully preemptive threads, and that sleep() - * does the right thing. - */ -int -tsleep( - time_t interval -) -{ - sleep( interval ); - return 0; -} -#endif /* !HAVE_LWP */