From: Howard Chu Date: Mon, 8 Nov 2004 04:23:37 +0000 (+0000) Subject: Assist in cache debugging X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~362 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=504d7ea261ebb5ca0d7542628d2ed6642ad31f53;p=openldap Assist in cache debugging --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 40227ccd9e..115b9e532b 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -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; diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 48758333e8..a0e436d87e 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -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 ); diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 33924d4070..234c5feb3f 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -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); } diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 13bc550a54..8f7273f6ec 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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(