mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Use pthread rwlocks, if available
This commit is contained in:
parent
93a3f4e7b1
commit
f192014c1a
6 changed files with 65 additions and 1 deletions
|
|
@ -49,6 +49,11 @@ typedef pthread_cond_t ldap_int_thread_cond_t;
|
||||||
#define HAVE_SETCONCURRENCY 1
|
#define HAVE_SETCONCURRENCY 1
|
||||||
#endif
|
#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
|
LDAP_END_DECL
|
||||||
|
|
||||||
#elif defined ( HAVE_MACH_CTHREADS )
|
#elif defined ( HAVE_MACH_CTHREADS )
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
|
||||||
LIBLDAP_F( int )
|
LIBLDAP_F( int )
|
||||||
ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
|
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 {
|
typedef struct ldap_pvt_thread_rdwr_var {
|
||||||
ldap_pvt_thread_mutex_t ltrw_mutex;
|
ldap_pvt_thread_mutex_t ltrw_mutex;
|
||||||
ldap_pvt_thread_cond_t ltrw_read; /* wait for read */
|
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_r_wait;
|
||||||
int ltrw_w_wait;
|
int ltrw_w_wait;
|
||||||
} ldap_pvt_thread_rdwr_t;
|
} ldap_pvt_thread_rdwr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
LIBLDAP_F( int )
|
LIBLDAP_F( int )
|
||||||
ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
|
ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,12 @@
|
||||||
|
|
||||||
/* end of preamble */
|
/* 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.
|
/* Define if on AIX 3.
|
||||||
System headers sometimes define this.
|
System headers sometimes define this.
|
||||||
We just want to avoid a redefinition error message. */
|
We just want to avoid a redefinition error message. */
|
||||||
|
|
@ -203,6 +209,9 @@
|
||||||
/* Define if you have the pthread_kill function. */
|
/* Define if you have the pthread_kill function. */
|
||||||
#undef HAVE_PTHREAD_KILL
|
#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. */
|
/* Define if you have the pthread_setconcurrency function. */
|
||||||
#undef HAVE_PTHREAD_SETCONCURRENCY
|
#undef HAVE_PTHREAD_SETCONCURRENCY
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,10 @@ SOURCE=.\thr_stub.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\threads.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\libldap\tls.c
|
SOURCE=..\libldap\tls.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ int ldap_pvt_thread_rdwr_wunlock( ldap_pvt_thread_rdwr_t *rw )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LDAP_DEBUG
|
#ifdef LDAP_RDWR_DEBUG
|
||||||
|
|
||||||
/* just for testing,
|
/* just for testing,
|
||||||
* return 0 if false, suitable for assert(ldap_pvt_thread_rdwr_Xchk(rdwr))
|
* return 0 if false, suitable for assert(ldap_pvt_thread_rdwr_Xchk(rdwr))
|
||||||
|
|
|
||||||
|
|
@ -218,5 +218,49 @@ ldap_int_thread_mutex_unlock( ldap_int_thread_mutex_t *mutex )
|
||||||
return pthread_mutex_unlock( 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 */
|
#endif /* HAVE_PTHREADS */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue