ldap_pvt_thread_rmutex_destroy LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
LDAP_F( int )
-ldap_pvt_thread_rmutex_lock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
+ldap_pvt_thread_rmutex_lock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner));
LDAP_F( int )
-ldap_pvt_thread_rmutex_trylock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
+ldap_pvt_thread_rmutex_trylock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner));
LDAP_F( int )
-ldap_pvt_thread_rmutex_unlock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex ));
+ldap_pvt_thread_rmutex_unlock LDAP_P(( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner));
LDAP_F( ldap_pvt_thread_t )
ldap_pvt_thread_self LDAP_P(( void ));
return 0;
}
-int ldap_pvt_thread_rmutex_lock( ldap_pvt_thread_rmutex_t *rmutex )
+int ldap_pvt_thread_rmutex_lock( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner )
{
struct ldap_int_thread_rmutex_s *rm;
- ldap_pvt_thread_t tid;
assert( rmutex != NULL );
rm = *rmutex;
assert( rm->ltrm_depth >= 0 );
assert( rm->ltrm_waits >= 0 );
- tid = ldap_pvt_thread_self();
-
if( rm->ltrm_depth > 0 ) {
/* already locked */
- if ( !ldap_pvt_thread_equal( rm->ltrm_owner, tid )) {
+ if ( !ldap_pvt_thread_equal( rm->ltrm_owner, owner )) {
rm->ltrm_waits++;
do {
ldap_pvt_thread_cond_wait( &rm->ltrm_cond,
rm->ltrm_waits--;
assert( rm->ltrm_waits >= 0 );
- rm->ltrm_owner = tid;
+ rm->ltrm_owner = owner;
}
} else {
- rm->ltrm_owner = tid;
+ rm->ltrm_owner = owner;
}
rm->ltrm_depth++;
return 0;
}
-int ldap_pvt_thread_rmutex_trylock( ldap_pvt_thread_rmutex_t *rmutex )
+int ldap_pvt_thread_rmutex_trylock( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner )
{
struct ldap_int_thread_rmutex_s *rm;
- ldap_pvt_thread_t tid;
assert( rmutex != NULL );
rm = *rmutex;
assert( rm->ltrm_depth >= 0 );
assert( rm->ltrm_waits >= 0 );
- tid = ldap_pvt_thread_self();
-
if( rm->ltrm_depth > 0 ) {
- if ( !ldap_pvt_thread_equal( tid, rm->ltrm_owner )) {
+ if ( !ldap_pvt_thread_equal( owner, rm->ltrm_owner )) {
ldap_pvt_thread_mutex_unlock( &rm->ltrm_mutex );
return LDAP_PVT_THREAD_EBUSY;
}
} else {
- rm->ltrm_owner = tid;
+ rm->ltrm_owner = owner;
}
rm->ltrm_depth++;
return 0;
}
-int ldap_pvt_thread_rmutex_unlock( ldap_pvt_thread_rmutex_t *rmutex )
+int ldap_pvt_thread_rmutex_unlock( ldap_pvt_thread_rmutex_t *rmutex,
+ ldap_pvt_thread_t owner )
{
struct ldap_int_thread_rmutex_s *rm;
- ldap_pvt_thread_t tid;
assert( rmutex != NULL );
rm = *rmutex;
ldap_pvt_thread_mutex_lock( &rm->ltrm_mutex );
- tid = ldap_pvt_thread_self();
-
- if( !ldap_pvt_thread_equal( tid, rm->ltrm_owner )) {
+ if( !ldap_pvt_thread_equal( owner, rm->ltrm_owner )) {
ldap_pvt_thread_mutex_unlock( &rm->ltrm_mutex );
return LDAP_PVT_THREAD_EINVAL;
}
int rc;
static int init = 0;
ldap_pvt_thread_rmutex_t rm;
+ ldap_pvt_thread_t tid;
/* we only get one shot at this */
if( init++ ) return -1;
/* kludge to pull symbol definitions in */
ldap_pvt_thread_rmutex_init( &rm );
- ldap_pvt_thread_rmutex_lock( &rm );
- ldap_pvt_thread_rmutex_trylock( &rm );
- ldap_pvt_thread_rmutex_unlock( &rm );
- ldap_pvt_thread_rmutex_unlock( &rm );
+ tid = ldap_pvt_thread_self();
+ ldap_pvt_thread_rmutex_lock( &rm, tid );
+ ldap_pvt_thread_rmutex_trylock( &rm, tid );
+ ldap_pvt_thread_rmutex_unlock( &rm, tid );
+ ldap_pvt_thread_rmutex_unlock( &rm, tid );
ldap_pvt_thread_rmutex_destroy( &rm );
return 0;
ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
old = li->li_old;
li->li_old = NULL;
- ldap_pvt_thread_rmutex_unlock( &li->li_op_rmutex );
+ ldap_pvt_thread_rmutex_unlock( &li->li_op_rmutex, op->o_tid );
}
if ( li->li_success && rs->sr_err != LDAP_SUCCESS )
log_info *li = on->on_bi.bi_private;
if ( li->li_ops & LOG_OP_WRITES ) {
- ldap_pvt_thread_rmutex_lock( &li->li_op_rmutex );
+ ldap_pvt_thread_rmutex_lock( &li->li_op_rmutex, op->o_tid );
if ( li->li_oldf && ( op->o_tag == LDAP_REQ_DELETE ||
op->o_tag == LDAP_REQ_MODIFY )) {
int rc;