From f192014c1a738f51bcc1b0fd91909ad234eea91f Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 7 Jun 2000 00:28:35 +0000 Subject: [PATCH] Use pthread rwlocks, if available --- include/ldap_int_thread.h | 5 ++++ include/ldap_pvt_thread.h | 2 ++ include/portable.h.in | 9 +++++++ libraries/libldap_r/libldap_r.dsp | 4 +++ libraries/libldap_r/rdwr.c | 2 +- libraries/libldap_r/thr_posix.c | 44 +++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/include/ldap_int_thread.h b/include/ldap_int_thread.h index 7f0257cdfa..5da7f13c17 100644 --- a/include/ldap_int_thread.h +++ b/include/ldap_int_thread.h @@ -49,6 +49,11 @@ typedef pthread_cond_t ldap_int_thread_cond_t; #define HAVE_SETCONCURRENCY 1 #endif +#if defined( HAVE_PTHREAD_RWLOCK_DESTROY ) +#define LDAP_THREAD_HAVE_RDWR 1 +typedef pthread_rwlock_t ldap_pvt_thread_rdwr_t; +#endif + LDAP_END_DECL #elif defined ( HAVE_MACH_CTHREADS ) diff --git a/include/ldap_pvt_thread.h b/include/ldap_pvt_thread.h index f336feafa9..668f58a1eb 100644 --- a/include/ldap_pvt_thread.h +++ b/include/ldap_pvt_thread.h @@ -96,6 +96,7 @@ ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); LIBLDAP_F( int ) ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex )); +#ifndef LDAP_THREAD_HAVE_RDWR typedef struct ldap_pvt_thread_rdwr_var { ldap_pvt_thread_mutex_t ltrw_mutex; ldap_pvt_thread_cond_t ltrw_read; /* wait for read */ @@ -107,6 +108,7 @@ typedef struct ldap_pvt_thread_rdwr_var { int ltrw_r_wait; int ltrw_w_wait; } ldap_pvt_thread_rdwr_t; +#endif LIBLDAP_F( int ) ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp)); diff --git a/include/portable.h.in b/include/portable.h.in index 6da42a598e..03d346c282 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -14,6 +14,12 @@ /* end of preamble */ +#if !defined(SLAPD_SCHEMA_COMPAT) && !defined(SLAPD_SCHEMA_NOT_COMPAT) + /* define SLAPD_SCHEMA_COMPAT if you want old schema codes */ +#define SLAPD_SCHEMA_NOT_COMPAT 1 +#endif + + /* Define if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ @@ -203,6 +209,9 @@ /* Define if you have the pthread_kill function. */ #undef HAVE_PTHREAD_KILL +/* Define if you have the pthread_rwlock_destroy function. */ +#undef HAVE_PTHREAD_RWLOCK_DESTROY + /* Define if you have the pthread_setconcurrency function. */ #undef HAVE_PTHREAD_SETCONCURRENCY diff --git a/libraries/libldap_r/libldap_r.dsp b/libraries/libldap_r/libldap_r.dsp index fe699a88ac..29e1d8d776 100644 --- a/libraries/libldap_r/libldap_r.dsp +++ b/libraries/libldap_r/libldap_r.dsp @@ -336,6 +336,10 @@ SOURCE=.\thr_stub.c # End Source File # Begin Source File +SOURCE=.\threads.c +# End Source File +# Begin Source File + SOURCE=..\libldap\tls.c # End Source File # Begin Source File diff --git a/libraries/libldap_r/rdwr.c b/libraries/libldap_r/rdwr.c index 75757adb7d..e97fe7143c 100644 --- a/libraries/libldap_r/rdwr.c +++ b/libraries/libldap_r/rdwr.c @@ -226,7 +226,7 @@ int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw ) return 0; } -#ifdef LDAP_DEBUG +#ifdef LDAP_RDWR_DEBUG /* just for testing, * return 0 if false, suitable for assert(ldap_pvt_thread_rdwr_Xchk(rdwr)) diff --git a/libraries/libldap_r/thr_posix.c b/libraries/libldap_r/thr_posix.c index b66cf7861c..f6a16c5d2a 100644 --- a/libraries/libldap_r/thr_posix.c +++ b/libraries/libldap_r/thr_posix.c @@ -218,5 +218,49 @@ ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex ) return pthread_mutex_unlock( mutex ); } +#ifdef HAVE_PTHREAD_RWLOCK_DESTROY +int +ldap_pvt_thread_rdwr_init( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_init( rw, NULL ); +} + +int +ldap_pvt_thread_rdwr_destroy( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_destroy( rw ); +} + +int ldap_pvt_thread_rdwr_rlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_rdlock( rw ); +} + +int ldap_pvt_thread_rdwr_rtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_tryrdlock( rw ); +} + +int ldap_pvt_thread_rdwr_runlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_unlock( rw ); +} + +int ldap_pvt_thread_rdwr_wlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_wrlock( rw ); +} + +int ldap_pvt_thread_rdwr_wtrylock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_trywrlock( rw ); +} + +int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw ) +{ + return pthread_rwlock_unlock( rw ); +} + +#endif /* LDAP_THREAD_HAVE_RDWR */ #endif /* HAVE_PTHREADS */ -- 2.39.5