]> git.sur5r.net Git - openldap/commitdiff
Assist in cache debugging
authorHoward Chu <hyc@openldap.org>
Mon, 8 Nov 2004 04:23:37 +0000 (04:23 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 8 Nov 2004 04:23:37 +0000 (04:23 +0000)
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/proto-bdb.h

index 40227ccd9e9a4b0c8b93b873d4e02c4a4538aac1..115b9e532b3b02e11683cef1b9635c99698fb51a 100644 (file)
@@ -124,6 +124,13 @@ typedef struct bdb_entry_info {
 typedef struct bdb_cache {
        int             c_maxsize;
        int             c_cursize;
+       int             c_eiused;
+/* c_eiused shows how many EntryInfos are in use. It should
+ * also equal the length of the LRU list, i.e., everything now lives
+ * on the LRU list. c_cursize shows how many Entries are attached.
+ * c_cursize will be <= c_eiused because internal nodes of the DIT
+ * will be retained in memory as long as their children are in use.
+ */
        EntryInfo       c_dntree;
        EntryInfo       *c_eifree;      /* free list */
        Avlnode         *c_idtree;
index 48758333e8d4bb77ca8aa5ddd6b05c41be472ad1..a0e436d87ed6170d8156a2e9cebe1e4dfbf07cc9 100644 (file)
@@ -244,6 +244,7 @@ bdb_entryinfo_add_internal(
                ei->bei_rdn.bv_val = NULL;
 #endif
        } else {
+               bdb->bi_cache.c_eiused++;
                ber_dupbv( &ei2->bei_nrdn, &ei->bei_nrdn );
                avl_insert( &ei->bei_parent->bei_kids, ei2, bdb_rdn_cmp,
                        avl_dup_error );
@@ -438,6 +439,7 @@ hdb_cache_find_parent(
                } else {
                        ei2 = &bdb->bi_cache.c_dntree;
                }
+               bdb->bi_cache.c_eiused++;
                ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock );
 
                /* Got the parent, link in and we're done. */
@@ -567,7 +569,7 @@ bdb_cache_lru_add(
                                 */
                                } else {
                                        bdb_cache_delete_internal( &bdb->bi_cache, elru, 0 );
-                                       bdb_cache_delete_cleanup( &bdb->bi_cache, elru->bei_e );
+                                       bdb_cache_delete_cleanup( &bdb->bi_cache, elru );
 
                                        /* break the loop, unsafe to muck with more than one */
                                        elprev = NULL;
@@ -1044,13 +1046,13 @@ bdb_cache_delete(
 void
 bdb_cache_delete_cleanup(
        Cache *cache,
-       Entry *e )
+       EntryInfo *ei )
 {
-       EntryInfo *ei = BEI(e);
-
-       ei->bei_e = NULL;
-       e->e_private = NULL;
-       bdb_entry_return( e );
+       if ( ei->bei_e ) {
+               ei->bei_e->e_private = NULL;
+               bdb_entry_return( ei->bei_e );
+               ei->bei_e = NULL;
+       }
 
        free( ei->bei_nrdn.bv_val );
        ei->bei_nrdn.bv_val = NULL;
@@ -1106,9 +1108,11 @@ bdb_cache_delete_internal(
                return rc;
        }
 
+       cache->c_eiused--;
+
        /* lru */
        LRU_DELETE( cache, e );
-       cache->c_cursize--;
+       if ( e->bei_e ) cache->c_cursize--;
 
        /* free cache write lock */
        ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
index 33924d40706abb80d92e4e66c88cd7fed1e33cc1..234c5feb3fca92c54e079d8667a46b4934e19dd1 100644 (file)
@@ -574,7 +574,7 @@ done:
        if( e != NULL ) {
                if ( rs->sr_err == LDAP_SUCCESS ) {
                        /* Free the EntryInfo and the Entry */
-                       bdb_cache_delete_cleanup( &bdb->bi_cache, e );
+                       bdb_cache_delete_cleanup( &bdb->bi_cache, BEI(e) );
                } else {
                        bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
                }
index 13bc550a54df7e6cafd20188515c1d2354924559..8f7273f6ec82d52e510deabf1e36a3ebc76d95ba 100644 (file)
@@ -490,7 +490,7 @@ int bdb_cache_delete(
 );
 void bdb_cache_delete_cleanup(
        Cache   *cache,
-       Entry   *e
+       EntryInfo *ei
 );
 void bdb_cache_release_all( Cache *cache );
 void bdb_cache_delete_entry(