mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-05 14:42:10 -05:00
unifdef SLAP_IDL_CACHE
This commit is contained in:
parent
c558bd49bc
commit
896beebadc
6 changed files with 8 additions and 50 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 )) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue