]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/cache.c
Fix prev commit, cleanup fakeroot entry before freeing
[openldap] / servers / slapd / back-bdb / cache.c
index 71e7c79d4db0ff676cabbfb8c95e5963854038ad..7f93b3bad1096373bf04c069f3da0cf9fd66a3a5 100644 (file)
@@ -65,6 +65,7 @@ bdb_cache_entryinfo_new( Cache *cache )
                        cache->c_eifree = ei->bei_lrunext;
                }
                ldap_pvt_thread_mutex_unlock( &cache->c_eifree_mutex );
+               ei->bei_finders = 0;
        }
        if ( !ei ) {
                ei = ch_calloc(1, sizeof(EntryInfo));
@@ -72,7 +73,6 @@ bdb_cache_entryinfo_new( Cache *cache )
        }
 
        ei->bei_state = CACHE_ENTRY_REFERENCED;
-       ei->bei_finders = 0;
 
        return ei;
 }
@@ -280,7 +280,7 @@ static int
 bdb_id_dup_err( void *v1, void *v2 )
 {
        EntryInfo *e2 = v2;
-       e2->bei_e = v1;
+       e2->bei_lrunext = v1;
        return -1;
 }
 
@@ -313,8 +313,7 @@ bdb_entryinfo_add_internal(
        /* Add to cache ID tree */
        if (avl_insert( &bdb->bi_cache.c_idtree, ei2, bdb_id_cmp,
                bdb_id_dup_err )) {
-               EntryInfo *eix = (EntryInfo *)ei2->bei_e;
-               eix = avl_find( bdb->bi_cache.c_idtree, ei2, bdb_id_cmp );
+               EntryInfo *eix = ei2->bei_lrunext;
                bdb_cache_entryinfo_free( &bdb->bi_cache, ei2 );
                ei2 = eix;
 #ifdef BDB_HIER
@@ -496,7 +495,7 @@ hdb_cache_find_parent(
                ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock );
                if ( avl_insert( &bdb->bi_cache.c_idtree, (caddr_t)ein,
                        bdb_id_cmp, bdb_id_dup_err ) ) {
-                       EntryInfo *eix = (EntryInfo *)ein->bei_e;
+                       EntryInfo *eix = ein->bei_lrunext;
 
                        /* Someone else created this node just before us.
                         * Free our new copy and use the existing one.
@@ -819,6 +818,7 @@ again:      ldap_pvt_thread_rdwr_rlock( &bdb->bi_cache.c_rwlock );
                        rc = DB_NOTFOUND;
                } else {
                        (*eip)->bei_finders++;
+                       (*eip)->bei_state |= CACHE_ENTRY_REFERENCED;
                        /* Make sure only one thread tries to load the entry */
 load1:
 #ifdef SLAP_ZONE_ALLOC
@@ -1371,6 +1371,19 @@ bdb_locker_id_free( void *key, void *data )
        }
 }
 
+/* free up any keys used by the main thread */
+void
+bdb_locker_flush( DB_ENV *env )
+{
+       void *data;
+       void *ctx = ldap_pvt_thread_pool_context();
+
+       if ( !ldap_pvt_thread_pool_getkey( ctx, env, &data, NULL ) ) {
+               ldap_pvt_thread_pool_setkey( ctx, env, NULL, NULL );
+               bdb_locker_id_free( env, data );
+       }
+}
+
 int
 bdb_locker_id( Operation *op, DB_ENV *env, u_int32_t *locker )
 {