From 3e062a3f3517ec608566e2fe6aa0bfcdd019dd08 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 8 Dec 2005 23:45:47 +0000 Subject: [PATCH] ITS#4254 fix lock ordering --- servers/slapd/back-bdb/cache.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 8e39d952df..92711b243b 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -438,12 +438,6 @@ hdb_cache_find_parent( addlru = 0; } - if ( addlru ) { - ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); - LRU_ADD( &bdb->bi_cache, ein ); - ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex ); - } - addlru = 1; /* If this is the first time, save this node * to be returned later. @@ -465,6 +459,13 @@ hdb_cache_find_parent( bdb->bi_cache.c_leaves++; ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); + if ( addlru ) { + ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex ); + LRU_ADD( &bdb->bi_cache, ein ); + ldap_pvt_thread_mutex_unlock( &bdb->bi_cache.lru_mutex ); + } + addlru = 1; + /* Got the parent, link in and we're done. */ if ( ei2 ) { bdb_cache_entryinfo_lock( ei2 ); -- 2.39.5