From: Jong Hyuk Choi Date: Thu, 25 Sep 2003 07:49:50 +0000 (+0000) Subject: do not cache internal search results for present entry priming X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~653 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eee84463c0afa0829535ac3b2e52401ab436e245;p=openldap do not cache internal search results for present entry priming --- diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 02db20c8c5..e5875e0c37 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -1078,3 +1078,24 @@ bdb_locker_id( Operation *op, DB_ENV *env, int *locker ) return 0; } #endif + +void +bdb_cache_delete_entry( + struct bdb_info *bdb, + EntryInfo *ei, + u_int32_t locker, + DB_LOCK *lock ) +{ + ldap_pvt_thread_rdwr_wlock( &bdb->bi_cache.c_rwlock ); + if ( bdb_cache_entry_db_lock( bdb->bi_dbenv, locker, ei, 1, 1, &lock ) == 0 ) { + if ( ei->bei_e && !(ei->bei_state & CACHE_ENTRY_NOT_LINKED )) { + LRU_DELETE( &bdb->bi_cache, ei ); + ei->bei_e->e_private = NULL; + bdb_entry_return( ei->bei_e ); + ei->bei_e = NULL; + --bdb->bi_cache.c_cursize; + } + bdb_cache_entry_db_unlock( bdb->bi_dbenv, &lock ); + } + ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); +} diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 16519b411d..9ad2193503 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -423,6 +423,7 @@ void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw ); #define bdb_cache_modify BDB_SYMBOL(cache_modify) #define bdb_cache_modrdn BDB_SYMBOL(cache_modrdn) #define bdb_cache_release_all BDB_SYMBOL(cache_release_all) +#define bdb_cache_delete_entry BDB_SYMBOL(cache_delete_entry) int bdb_cache_children( Operation *op, @@ -478,6 +479,12 @@ void bdb_cache_delete_cleanup( Entry *e ); void bdb_cache_release_all( Cache *cache ); +void bdb_cache_delete_entry( + struct bdb_info *bdb, + EntryInfo *ei, + u_int32_t locker, + DB_LOCK *lock +); #ifdef BDB_HIER int hdb_cache_load( diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 93a8714d33..2d3f245c50 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -1218,7 +1218,10 @@ loop_continue: /* free reader lock */ if (!IS_PSEARCH) { bdb_cache_return_entry_r( bdb->bi_dbenv, - &bdb->bi_cache, e , &lock); + &bdb->bi_cache, e , &lock ); + if ( sop->o_nocaching ) { + bdb_cache_delete_entry( bdb, ei, locker, &lock ); + } } e = NULL; rs->sr_entry = NULL;