int refcnt, freeit = 1;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
assert( e->e_private );
* for instance)
*/
if ( BEI(e)->bei_state == CACHE_ENTRY_CREATING ) {
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
bdb_cache_delete_entry_internal( cache, e );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
freeit = 0;
/* now the entry is in DELETED state */
}
BEI(e)->bei_state = CACHE_ENTRY_READY;
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
} else if ( BEI(e)->bei_state == CACHE_ENTRY_DELETED ) {
if( refcnt > 0 ) {
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
} else {
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
e->e_dn, rw ? "w" : "r" ));
#endif
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
assert( e->e_private == NULL );
if( bdb_cache_entry_private_init(e) != 0 ) {
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_ERR,
(AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 )
{
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
bdb_cache_entry_private_destroy(e);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( -1 );
}
BEI(e)->bei_state = CACHE_ENTRY_CREATING;
BEI(e)->bei_refcnt = 1;
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
/* lru */
LRU_ADD( cache, e );
if ( ++cache->c_cursize > cache->c_maxsize ) {
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( 0 );
}
Entry *ee;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
assert( e->e_private );
#endif
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( 1 );
}
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( -1 );
}
/* will be marked after when entry is returned */
BEI(e)->bei_state = CACHE_ENTRY_CREATING;
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
/* lru */
LRU_ADD( cache, e );
if ( ++cache->c_cursize > cache->c_maxsize ) {
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( 0 );
}
try_again:
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
(AVL_CMP) entry_dn_cmp )) != NULL )
assert(state != CACHE_ENTRY_UNDEFINED);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
goto try_again;
}
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
+
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
+
/* lru */
LRU_DELETE( cache, ep );
LRU_ADD( cache, ep );
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
} else {
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
id = NOID;
}
try_again:
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
(AVL_CMP) entry_id_cmp )) != NULL )
assert(state != CACHE_ENTRY_UNDEFINED);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
*/
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_INFO,
goto try_again;
}
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
/* lru */
LRU_DELETE( cache, ep );
LRU_ADD( cache, ep );
BEI(ep)->bei_refcnt++;
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_DETAIL1,
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_runlock( &cache->c_rwlock );
return( NULL );
}
int rc;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
assert( e->e_private );
e->e_id, 0, 0 );
#endif
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
rc = bdb_cache_delete_entry_internal( cache, e );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
return( rc );
}
int rc;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ ldap_pvt_thread_rdwr_wlock( &cache->c_rwlock );
+ ldap_pvt_thread_mutex_lock( &cache->lru_mutex );
#ifdef NEW_LOGGING
LDAP_LOG(( "cache", LDAP_LEVEL_ENTRY,
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->lru_mutex );
+ ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
}
#ifdef LDAP_DEBUG