]> git.sur5r.net Git - openldap/commitdiff
ITS#3527 fix race in bdb_idl_cache_get
authorHoward Chu <hyc@openldap.org>
Tue, 1 Feb 2005 05:37:09 +0000 (05:37 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 1 Feb 2005 05:37:09 +0000 (05:37 +0000)
servers/slapd/back-bdb/idl.c

index 29a337218d3baa4facd6bbdd1bba9186caafe58c..038de21ef2507f619824241d24f9b30470344533 100644 (file)
@@ -292,6 +292,7 @@ bdb_idl_cache_get(
 {
        bdb_idl_cache_entry_t idl_tmp;
        bdb_idl_cache_entry_t *matched_idl_entry;
+       int rc = LDAP_NO_SUCH_OBJECT;
 
        DBT2bv( key, &idl_tmp.kstr );
        idl_tmp.db = db;
@@ -301,19 +302,18 @@ bdb_idl_cache_get(
        if ( matched_idl_entry != NULL ) {
                if ( matched_idl_entry->idl && ids )
                        BDB_IDL_CPY( ids, matched_idl_entry->idl );
-               ldap_pvt_thread_rdwr_runlock( &bdb->bi_idl_tree_rwlock );
                ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_lrulock );
                IDL_LRU_DELETE( bdb, matched_idl_entry );
                IDL_LRU_ADD( bdb, matched_idl_entry );
                ldap_pvt_thread_mutex_unlock( &bdb->bi_idl_tree_lrulock );
                if ( matched_idl_entry->idl )
-                       return LDAP_SUCCESS;
+                       rc = LDAP_SUCCESS;
                else
-                       return DB_NOTFOUND;
+                       rc = DB_NOTFOUND;
        }
        ldap_pvt_thread_rdwr_runlock( &bdb->bi_idl_tree_rwlock );
 
-       return LDAP_NO_SUCH_OBJECT;
+       return rc;
 }
 
 void