]> git.sur5r.net Git - openldap/commitdiff
ITS#2593 keep entryinfo locked during delete
authorHoward Chu <hyc@openldap.org>
Thu, 12 Jun 2003 22:47:13 +0000 (22:47 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 12 Jun 2003 22:47:13 +0000 (22:47 +0000)
servers/slapd/back-bdb/cache.c

index f05980beb31f861a54a0a70f150ba512a579ddd1..d0c22b1ae52fb953508b95669c1ab54e44ad498a 100644 (file)
@@ -535,6 +535,9 @@ again:              ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
                        if ( ldap_pvt_thread_mutex_trylock(
                                        &(*eip)->bei_kids_mutex )) {
                                ldap_pvt_thread_rdwr_runlock( &bdb->bi_cache.c_rwlock );
+                               if ( (*eip)->bei_state & CACHE_ENTRY_DELETED ) {
+                                       return DB_NOTFOUND;
+                               }
                                ldap_pvt_thread_yield();
                                goto again;
                        }
@@ -571,7 +574,6 @@ again:              ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
                } else {
                        bdb_cache_entry_db_lock( bdb->bi_dbenv, locker,
                                        *eip, 0, 0, lock );
-
                        if ( !(*eip)->bei_e ) {
                                if (!ep) {
                                        rc = bdb_id2entry( op->o_bd, tid, id, &ep );
@@ -803,6 +805,9 @@ bdb_cache_delete(
        /* Set this early, warn off any queriers */
        ei->bei_state |= CACHE_ENTRY_DELETED;
 
+       /* Lock the entry's info */
+       bdb_cache_entryinfo_lock( ei );
+
        /* Get write lock on the data */
        bdb_cache_entry_db_relock( env, locker, ei, 1, 0, lock );
 
@@ -829,6 +834,9 @@ bdb_cache_delete(
        /* free cache write lock */
        ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
        bdb_cache_entryinfo_unlock( ei->bei_parent );
+
+       /* Leave entry info locked */
+
        return( rc );
 }
 
@@ -837,6 +845,7 @@ bdb_cache_delete_cleanup(
        Entry *e
 )
 {
+       bdb_cache_entryinfo_unlock( BEI(e) );
        bdb_cache_entryinfo_destroy( e->e_private );
        e->e_private = NULL;
        bdb_entry_return( e );