/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2003-2006 The OpenLDAP Foundation.
+ * Copyright 2003-2007 The OpenLDAP Foundation.
* Portions Copyright 2003 IBM Corporation.
* Portions Copyright 2003 Symas Corporation.
* All rights reserved.
rc = 0;
}
} else {
- be_entry_release_w( op, e );
+ if ( op->ora_e == e )
+ be_entry_release_w( op, e );
rc = 1;
}
{
Filter* fs;
Filter* fi;
- const char* text;
MatchingRule* mrule = NULL;
int res=0, eqpass= 0;
int ret, rc, dir;
Filter *first;
Debug( pcache_debug, "Lock QC index = %p\n",
- templa, 0, 0 );
+ (void *) templa, 0, 0 );
qbase.base = query->base;
first = filter_first( query->filter );
Debug( pcache_debug,
"Not answerable: Unlock QC index=%p\n",
- templa, 0, 0 );
+ (void *) templa, 0, 0 );
ldap_pvt_thread_rdwr_runlock(&templa->t_rwlock);
}
return NULL;
/* Adding a query */
Debug( pcache_debug, "Lock AQ index = %p\n",
- templ, 0, 0 );
+ (void *) templ, 0, 0 );
ldap_pvt_thread_rdwr_wlock(&templ->t_rwlock);
qbase = avl_find( templ->qbase, &qb, pcache_dn_cmp );
if ( !qbase ) {
filter_free( query->filter );
}
Debug( pcache_debug, "TEMPLATE %p QUERIES++ %d\n",
- templ, templ->no_of_queries, 0 );
+ (void *) templ, templ->no_of_queries, 0 );
Debug( pcache_debug, "Unlock AQ index = %p \n",
- templ, 0, 0 );
+ (void *) templ, 0, 0 );
ldap_pvt_thread_rdwr_wunlock(&templ->t_rwlock);
/* Adding on top of LRU list */
*result = bottom->q_uuid;
bottom->q_uuid.bv_val = NULL;
- Debug( pcache_debug, "Lock CR index = %p\n", temp, 0, 0 );
+ Debug( pcache_debug, "Lock CR index = %p\n", (void *) temp, 0, 0 );
ldap_pvt_thread_rdwr_wlock(&temp->t_rwlock);
remove_from_template(bottom, temp);
Debug( pcache_debug, "TEMPLATE %p QUERIES-- %d\n",
- temp, temp->no_of_queries, 0 );
- Debug( pcache_debug, "Unlock CR index = %p\n", temp, 0, 0 );
+ (void *) temp, temp->no_of_queries, 0 );
+ Debug( pcache_debug, "Unlock CR index = %p\n", (void *) temp, 0, 0 );
ldap_pvt_thread_rdwr_wunlock(&temp->t_rwlock);
free_query(bottom);
}
slap_overinst *on = si->on;
cache_manager *cm = on->on_bi.bi_private;
query_manager* qm = cm->qm;
- struct berval uuid;
if ( si->save_attrs != NULL ) {
rs->sr_attrs = si->save_attrs;
while (query && (query->expiry_time < op->o_time)) {
int rem = 0;
Debug( pcache_debug, "Lock CR index = %p\n",
- templ, 0, 0 );
+ (void *) templ, 0, 0 );
ldap_pvt_thread_rdwr_wlock(&templ->t_rwlock);
if ( query == templ->query_last ) {
rem = 1;
remove_from_template(query, templ);
Debug( pcache_debug, "TEMPLATE %p QUERIES-- %d\n",
- templ, templ->no_of_queries, 0 );
+ (void *) templ, templ->no_of_queries, 0 );
Debug( pcache_debug, "Unlock CR index = %p\n",
- templ, 0, 0 );
+ (void *) templ, 0, 0 );
}
ldap_pvt_thread_rdwr_wunlock(&templ->t_rwlock);
if ( !rem ) {
return( 1 );
}
- if ( !backend_db_init( c->argv[1], &cm->db )) {
+ if ( !backend_db_init( c->argv[1], &cm->db, -1 )) {
snprintf( c->msg, sizeof( c->msg ), "unknown backend type (arg #1)" );
Debug( LDAP_DEBUG_CONFIG, "%s: %s.\n", c->log, c->msg, 0 );
return( 1 );
static int
pcache_db_init(
- BackendDB *be
-)
+ BackendDB *be )
{
slap_overinst *on = (slap_overinst *)be->bd_info;
cache_manager *cm;
static int
pcache_db_open(
- BackendDB *be
-)
+ BackendDB *be )
{
slap_overinst *on = (slap_overinst *)be->bd_info;
cache_manager *cm = on->on_bi.bi_private;
cm->db.be_acl = be->be_acl;
cm->db.be_dfltaccess = be->be_dfltaccess;
+ if ( SLAP_DBMONITORING( be ) ) {
+ SLAP_DBFLAGS( &cm->db ) |= SLAP_DBFLAG_MONITORING;
+
+ } else {
+ SLAP_DBFLAGS( &cm->db ) &= ~SLAP_DBFLAG_MONITORING;
+ }
+
rc = backend_startup_one( &cm->db );
/* There is no runqueue in TOOL mode */
if ( cm->db.bd_info->bi_db_close ) {
rc = cm->db.bd_info->bi_db_close( &cm->db );
}
- while ( tm = qm->templates ) {
+ while ( (tm = qm->templates) != NULL ) {
CachedQuery *qc, *qn;
qm->templates = tm->qmnext;
for ( qc = tm->query; qc; qc = qn ) {
cache_manager *cm = on->on_bi.bi_private;
query_manager *qm = cm->qm;
- /* cleanup stuff inherited from the original database... */
- cm->db.be_suffix = NULL;
- cm->db.be_nsuffix = NULL;
- BER_BVZERO( &cm->db.be_rootdn );
- BER_BVZERO( &cm->db.be_rootndn );
- BER_BVZERO( &cm->db.be_rootpw );
- /* FIXME: there might be more... */
-
if ( cm->db.be_private != NULL ) {
- backend_destroy_one( &cm->db, 0 );
+ backend_stopdown_one( &cm->db );
}
ldap_pvt_thread_mutex_destroy( &qm->lru_mutex );
int pcache_initialize()
{
- LDAPAttributeType *at;
int code;
- const char *err;
struct berval debugbv = BER_BVC("pcache");
if (( code = slap_loglevel_get( &debugbv, &pcache_debug )))
return code;
- at = ldap_str2attributetype( queryid_schema, &code, &err,
- LDAP_SCHEMA_ALLOW_ALL );
- if ( !at ) {
- Debug( LDAP_DEBUG_ANY,
- "pcache_initialize: ldap_str2attributetype failed %s %s\n",
- ldap_scherr2str(code), err, 0 );
- return code;
- }
- code = at_add( at, 0, NULL, &err );
- if ( !code ) {
- slap_str2ad( at->at_names[0], &ad_queryid, &err );
- }
- ldap_memfree( at );
+ code = register_at( queryid_schema, &ad_queryid, 0 );
if ( code ) {
Debug( LDAP_DEBUG_ANY,
- "pcache_initialize: at_add failed %s %s\n",
- scherr2str(code), err, 0 );
+ "pcache_initialize: register_at failed\n", 0, 0, 0 );
return code;
}