From 896beebadcefcaa33b2e130c16338f66fe9a8c18 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 5 Mar 2004 13:43:18 +0000 Subject: [PATCH] unifdef SLAP_IDL_CACHE --- servers/slapd/back-bdb/back-bdb.h | 7 ------- servers/slapd/back-bdb/config.c | 2 -- servers/slapd/back-bdb/dn2id.c | 18 ++++++------------ servers/slapd/back-bdb/idl.c | 20 +------------------- servers/slapd/back-bdb/init.c | 9 +-------- servers/slapd/back-bdb/proto-bdb.h | 2 -- 6 files changed, 8 insertions(+), 50 deletions(-) diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 3420b0d9a1..aff155e13f 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -73,10 +73,6 @@ LDAP_BEGIN_DECL /* The minimum we can function with */ #define MINIMUM_SEARCH_STACK_DEPTH 8 -/* for the IDL cache */ -#define SLAP_IDL_CACHE 1 - -#ifdef SLAP_IDL_CACHE typedef struct bdb_idl_cache_entry_s { struct berval kstr; ldap_pvt_thread_rdwr_t idl_entry_rwlock; @@ -85,7 +81,6 @@ typedef struct bdb_idl_cache_entry_s { struct bdb_idl_cache_entry_s* idl_lru_prev; struct bdb_idl_cache_entry_s* idl_lru_next; } bdb_idl_cache_entry_t; -#endif /* BDB backend specific entry info */ typedef struct bdb_entry_info { @@ -173,7 +168,6 @@ struct bdb_info { LDAP_LIST_HEAD(pl, slap_op) bi_psearch_list; ldap_pvt_thread_rdwr_t bi_pslist_rwlock; LDAP_LIST_HEAD(se, slap_session_entry) bi_session_list; -#ifdef SLAP_IDL_CACHE int bi_idl_cache_max_size; int bi_idl_cache_size; Avlnode *bi_idl_tree; @@ -181,7 +175,6 @@ struct bdb_info { bdb_idl_cache_entry_t *bi_idl_lru_tail; ldap_pvt_thread_rdwr_t bi_idl_tree_rwlock; ldap_pvt_thread_mutex_t bi_idl_tree_lrulock; -#endif }; #define bi_id2entry bi_databases[BDB_ID2ENTRY] diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index 032472962c..37d4fd918d 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -172,7 +172,6 @@ bdb_db_config( bdb->bi_search_stack_depth = MINIMUM_SEARCH_STACK_DEPTH; } -#ifdef SLAP_IDL_CACHE /* size of the IDL cache in entries */ } else if ( strcasecmp( argv[0], "idlcachesize" ) == 0 ) { if ( argc < 2 ) { @@ -183,7 +182,6 @@ bdb_db_config( } if ( !( slapMode & SLAP_TOOL_MODE ) ) bdb->bi_idl_cache_max_size = atoi( argv[1] ); -#endif } else if ( strcasecmp( argv[0], "sessionlog" ) == 0 ) { int se_id = 0, se_size = 0; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 19dc5d3074..be302a6cdd 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -382,7 +382,6 @@ bdb_dn2id_children( ((char *)key.data)[0] = DN_ONE_PREFIX; AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 ); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { rc = bdb_idl_cache_get( bdb, db, &key, NULL ); if ( rc != LDAP_NO_SUCH_OBJECT ) { @@ -390,7 +389,7 @@ bdb_dn2id_children( return rc; } } -#endif + /* we actually could do a empty get... */ DBTzero( &data ); data.data = &id; @@ -630,11 +629,10 @@ hdb_dn2id_add( key.size = sizeof(ID); key.flags = DB_DBT_USERMEM; -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { bdb_idl_cache_del( bdb, db, &key ); } -#endif + data.data = d; data.size = sizeof(diskNode) + rlen + nrlen; data.flags = DB_DBT_USERMEM; @@ -680,11 +678,10 @@ hdb_dn2id_delete( data.dlen = data.size; data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL; -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { bdb_idl_cache_del( bdb, db, &key ); } -#endif + rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags ); if ( rc ) return rc; @@ -851,14 +848,13 @@ hdb_dn2id_children( key.data = &e->e_id; key.flags = DB_DBT_USERMEM; -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { rc = bdb_idl_cache_get( bdb, db, &key, NULL ); if ( rc != LDAP_NO_SUCH_OBJECT ) { return rc; } } -#endif + DBTzero(&data); data.data = &d; data.ulen = sizeof(d); @@ -926,7 +922,6 @@ hdb_dn2idl_internal( struct dn2id_cookie *cx ) { -#ifdef SLAP_IDL_CACHE if ( cx->bdb->bi_idl_cache_size ) { cx->rc = bdb_idl_cache_get(cx->bdb, cx->db, &cx->key, cx->tmp); if ( cx->rc == DB_NOTFOUND ) { @@ -936,7 +931,7 @@ hdb_dn2idl_internal( goto gotit; } } -#endif + BDB_IDL_ZERO( cx->tmp ); if ( !cx->ei ) { @@ -1032,11 +1027,10 @@ hdb_dn2idl_internal( } saveit: -#ifdef SLAP_IDL_CACHE if ( cx->bdb->bi_idl_cache_max_size ) { bdb_idl_cache_put( cx->bdb, cx->db, &cx->key, cx->tmp, cx->rc ); } -#endif + ; gotit: if ( !BDB_IDL_IS_ZERO( cx->tmp )) { diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 5ecae44977..0913883726 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -27,7 +27,6 @@ #define IDL_CMP(x,y) ( x < y ? -1 : ( x > y ? 1 : 0 ) ) -#ifdef SLAP_IDL_CACHE #define IDL_LRU_DELETE( bdb, e ) do { \ if ( e->idl_lru_prev != NULL ) { \ e->idl_lru_prev->idl_lru_next = e->idl_lru_next; \ @@ -63,7 +62,6 @@ bdb_idl_entry_cmp( const void *v_idl1, const void *v_idl2 ) if ((rc = idl1->kstr.bv_len - idl2->kstr.bv_len )) return rc; return ( memcmp ( idl1->kstr.bv_val, idl2->kstr.bv_val , idl1->kstr.bv_len ) ); } -#endif #if IDL_DEBUG > 0 static void idl_check( ID *ids ) @@ -304,8 +302,6 @@ bdb_show_key( } } -#ifdef SLAP_IDL_CACHE - /* Find a db/key pair in the IDL cache. If ids is non-NULL, * copy the cached IDL into it, otherwise just return the status. */ @@ -444,7 +440,6 @@ bdb_idl_cache_del( } ldap_pvt_thread_rdwr_wunlock( &bdb->bi_idl_tree_rwlock ); } -#endif int bdb_idl_fetch_key( @@ -495,12 +490,10 @@ bdb_idl_fetch_key( assert( ids != NULL ); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { rc = bdb_idl_cache_get( bdb, db, key, ids ); if ( rc != LDAP_NO_SUCH_OBJECT ) return rc; } -#endif DBTzero( &data ); @@ -575,12 +568,7 @@ bdb_idl_fetch_key( return rc2; } - if( rc == DB_NOTFOUND ) { -#ifndef SLAP_IDL_CACHE - return rc; -#endif - - } else if( rc != 0 ) { + if( rc != 0 && rc != DB_NOTFOUND ) { #ifdef NEW_LOGGING LDAP_LOG( INDEX, ERR, "bdb_idl_fetch_key: get failed: %s (%d)\n", @@ -619,11 +607,9 @@ bdb_idl_fetch_key( return -1; } -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_max_size ) { bdb_idl_cache_put( bdb, db, key, ids, rc ); } -#endif return rc; } @@ -659,11 +645,9 @@ bdb_idl_insert_key( assert( id != NOID ); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_size ) { bdb_idl_cache_del( bdb, db, key ); } -#endif DBTzero( &data ); data.size = sizeof( ID ); @@ -856,11 +840,9 @@ bdb_idl_delete_key( } assert( id != NOID ); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_max_size ) { bdb_idl_cache_del( bdb, db, key ); } -#endif DBTzero( &data ); data.data = &tmp; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 0b64dd192d..63685bc635 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -208,14 +208,12 @@ bdb_db_open( BackendDB *be ) bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall ); bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect ); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_max_size ) { bdb->bi_idl_tree = NULL; ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock ); ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock ); bdb->bi_idl_cache_size = 0; } -#endif #ifdef BDB_SUBDIRS { @@ -469,9 +467,7 @@ bdb_db_close( BackendDB *be ) int rc; struct bdb_info *bdb = (struct bdb_info *) be->be_private; struct bdb_db_info *db; -#ifdef SLAP_IDL_CACHE bdb_idl_cache_entry_t *entry, *next_entry; -#endif while( bdb->bi_ndatabases-- ) { db = bdb->bi_databases[bdb->bi_ndatabases]; @@ -486,7 +482,6 @@ bdb_db_close( BackendDB *be ) bdb_cache_release_all (&bdb->bi_cache); -#ifdef SLAP_IDL_CACHE if ( bdb->bi_idl_cache_max_size ) { ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock ); avl_free( bdb->bi_idl_tree, NULL ); @@ -501,7 +496,6 @@ bdb_db_close( BackendDB *be ) } ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock ); } -#endif return 0; } @@ -552,12 +546,11 @@ bdb_db_destroy( BackendDB *be ) ldap_pvt_thread_rdwr_destroy ( &bdb->bi_pslist_rwlock ); ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex ); ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex ); -#ifdef SLAP_IDL_CACHE + if ( bdb->bi_idl_cache_max_size ) { ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock ); ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock ); } -#endif ch_free( bdb ); be->be_private = NULL; diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 8561e1ca5d..f3e6eb5682 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -203,7 +203,6 @@ BI_entry_get_rw bdb_entry_get; /* * idl.c */ -#ifdef SLAP_IDL_CACHE #define bdb_idl_cache_get BDB_SYMBOL(idl_cache_get) #define bdb_idl_cache_put BDB_SYMBOL(idl_cache_put) @@ -228,7 +227,6 @@ bdb_idl_cache_del( struct bdb_info *bdb, DB *db, DBT *key ); -#endif #define bdb_idl_first BDB_SYMBOL(idl_first) #define bdb_idl_next BDB_SYMBOL(idl_next) -- 2.39.5