]> git.sur5r.net Git - openldap/commitdiff
Fix: LRU corruption, HDB rename detection, Ctxcsn assert failure
authorHoward Chu <hyc@openldap.org>
Sat, 3 Jul 2004 15:47:44 +0000 (15:47 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 3 Jul 2004 15:47:44 +0000 (15:47 +0000)
servers/slapd/back-bdb/cache.c

index 85d4d052d4e1654100987793919095b3e0fe6bd7..f68f89e4f01d4759183ca5646ac47ed7049ccb9a 100644 (file)
@@ -593,7 +593,6 @@ bdb_cache_find_id(
        Entry   *ep = NULL;
        int     rc = 0;
        EntryInfo ei;
-       int lru_del = 0;
 
        ei.bei_id = id;
 
@@ -673,6 +672,11 @@ again:     ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
                                                if ( (*eip)->bei_e ) {
                                                        bdb_entry_return( ep );
                                                        ep = NULL;
+#ifdef BDB_HIER
+                                                       /* Check for subtree renames */
+                                                       rc = bdb_fix_dn( (*eip)->bei_e, 1 );
+                                                       if ( rc ) rc = bdb_fix_dn( (*eip)->bei_e, 2 );
+#endif
                                                } else {
                                                        ep->e_private = *eip;
 #ifdef BDB_HIER
@@ -683,12 +687,10 @@ again:    ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
                                                bdb_cache_entry_db_relock( bdb->bi_dbenv, locker,
                                                        *eip, 0, 0, lock );
                                        }
+#ifdef BDB_HIER
                                } else {
-                                       /* If we had the entry already, this item
-                                        * is on the LRU list.
+                                       /* Check for subtree renames
                                         */
-                                       lru_del = 1;
-#ifdef BDB_HIER
                                        rc = bdb_fix_dn( (*eip)->bei_e, 1 );
                                        if ( rc ) {
                                                bdb_cache_entry_db_relock( bdb->bi_dbenv,
@@ -708,8 +710,8 @@ again:      ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
        if ( rc == 0 ) {
                /* set lru mutex */
                ldap_pvt_thread_mutex_lock( &bdb->bi_cache.lru_mutex );
-               /* if entry is old, remove from old spot on LRU list */
-               if ( lru_del ) {
+               /* if entry is on LRU list, remove from old spot */
+               if ( (*eip)->bei_lrunext || (*eip)->bei_lruprev ) {
                        LRU_DELETE( &bdb->bi_cache, *eip );
                } else {
                /* if entry is new, bump cache size */
@@ -785,7 +787,10 @@ bdb_cache_add(
 
        rc = bdb_entryinfo_add_internal( bdb, &ei, &new );
        /* bdb_csn_commit can cause this when adding the database root entry */
-       if ( new->bei_e ) bdb_entry_return( new->bei_e );
+       if ( new->bei_e ) {
+               new->bei_e->e_private = NULL;
+               bdb_entry_return( new->bei_e );
+       }
        new->bei_e = e;
        e->e_private = new;
        new->bei_state = CACHE_ENTRY_NO_KIDS | CACHE_ENTRY_NO_GRANDKIDS;