int numattrsets; /* number of attribute sets */
int cur_entries; /* current number of entries cached */
int max_entries; /* max number of entries cached */
- int num_entries_limit; /* max # of entries in a cacheable query */
+ int num_entries_limit; /* max # of entries in a cacheable query */
char response_cb; /* install the response callback
* at the tail of the callback list */
#define PCACHE_RESPONSE_CB_HEAD 0
#define PCACHE_RESPONSE_CB_TAIL 1
+ char defer_db_open; /* defer open for online add */
time_t cc_period; /* interval between successive consistency checks (sec) */
- int cc_paused;
+ int cc_paused;
void *cc_arg;
ldap_pvt_thread_mutex_t cache_mutex;
op->o_dn = cm->db.be_rootdn;
op->o_ndn = cm->db.be_rootndn;
- cm->cc_arg = arg;
+ cm->cc_arg = arg;
for (templ = qm->templates; templ; templ=templ->qmnext) {
query = templ->query_last;
{ NULL, NULL, 0, 0, 0, ARG_IGNORED }
};
+/* Need to no-op this keyword for dynamic config */
+static ConfigTable pcdummy[] = {
+ { "", "", 0, 0, 0, ARG_IGNORED,
+ NULL, "( OLcfgGlAt:13 NAME 'olcDatabase' "
+ "DESC 'The backend type for a database instance' "
+ "SUP olcBackend SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL },
+ { NULL, NULL, 0, 0, 0, ARG_IGNORED }
+};
+
static ConfigOCs pcocs[] = {
{ "( OLcfgOvOc:2.1 "
"NAME 'olcPcacheConfig' "
{ "( OLcfgOvOc:2.2 "
"NAME 'olcPcacheDatabase' "
"DESC 'Cache database configuration' "
- "AUXILIARY )", Cft_Misc, pccfg, pc_ldadd },
+ "AUXILIARY )", Cft_Misc, pcdummy, pc_ldadd },
{ NULL, 0, NULL }
};
+static int pcache_db_open2( slap_overinst *on, ConfigReply *cr );
+
+static int
+pc_ldadd_cleanup( ConfigArgs *c )
+{
+ slap_overinst *on = c->private;
+ return pcache_db_open2( on, &c->reply );
+}
+
static int
pc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
{
on = (slap_overinst *)p->ce_bi;
cm = on->on_bi.bi_private;
ca->be = &cm->db;
+ ca->cleanup = pc_ldadd_cleanup;
+ ca->private = on;
return LDAP_SUCCESS;
}
Debug( LDAP_DEBUG_CONFIG, "%s: %s.\n", c->log, c->cr_msg, 0 );
return( 1 );
}
+ if ( CONFIG_ONLINE_ADD( c ))
+ cm->defer_db_open = 1;
+
cm->cc_period = (time_t)t;
Debug( pcache_debug,
"Total # of attribute sets to be cached = %d.\n",
cm->max_queries = 10000;
cm->save_queries = 0;
cm->response_cb = PCACHE_RESPONSE_CB_TAIL;
+ cm->defer_db_open = 0;
cm->cc_period = 1000;
cm->cc_paused = 0;
+ cm->cc_arg = NULL;
qm->attr_sets = NULL;
qm->templates = NULL;
}
static int
-pcache_db_open(
- BackendDB *be,
+pcache_db_open2(
+ slap_overinst *on,
ConfigReply *cr )
{
- slap_overinst *on = (slap_overinst *)be->bd_info;
cache_manager *cm = on->on_bi.bi_private;
query_manager* qm = cm->qm;
- int i, ncf = 0, rf = 0, nrf = 0, rc = 0;
-
- /* check attr sets */
- for ( i = 0; i < cm->numattrsets; i++) {
- if ( !( qm->attr_sets[i].flags & PC_CONFIGURED ) ) {
- if ( qm->attr_sets[i].flags & PC_REFERENCED ) {
- Debug( LDAP_DEBUG_CONFIG, "pcache: attr set #%d not configured but referenced.\n", i, 0, 0 );
- rf++;
-
- } else {
- Debug( LDAP_DEBUG_CONFIG, "pcache: warning, attr set #%d not configured.\n", i, 0, 0 );
- }
- ncf++;
-
- } else if ( !( qm->attr_sets[i].flags & PC_REFERENCED ) ) {
- Debug( LDAP_DEBUG_CONFIG, "pcache: attr set #%d configured but not referenced.\n", i, 0, 0 );
- nrf++;
- }
- }
-
- if ( ncf || rf || nrf ) {
- Debug( LDAP_DEBUG_CONFIG, "pcache: warning, %d attr sets configured but not referenced.\n", nrf, 0, 0 );
- Debug( LDAP_DEBUG_CONFIG, "pcache: warning, %d attr sets not configured.\n", ncf, 0, 0 );
- Debug( LDAP_DEBUG_CONFIG, "pcache: %d attr sets not configured but referenced.\n", rf, 0, 0 );
-
- if ( rf > 0 ) {
- return 1;
- }
- }
-
- /* need to inherit something from the original database... */
- cm->db.be_def_limit = be->be_def_limit;
- cm->db.be_limits = be->be_limits;
- 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;
- }
+ int rc;
rc = backend_startup_one( &cm->db, NULL );
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
ldap_pvt_runqueue_insert( &slapd_rq, cm->cc_period,
consistency_check, on,
- "pcache_consistency", be->be_suffix[0].bv_val );
+ "pcache_consistency", cm->db.be_suffix[0].bv_val );
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
/* Cached database must have the rootdn */
rc = 0;
}
}
+ return rc;
+}
+
+static int
+pcache_db_open(
+ BackendDB *be,
+ ConfigReply *cr )
+{
+ slap_overinst *on = (slap_overinst *)be->bd_info;
+ cache_manager *cm = on->on_bi.bi_private;
+ query_manager* qm = cm->qm;
+ int i, ncf = 0, rf = 0, nrf = 0, rc = 0;
+
+ /* check attr sets */
+ for ( i = 0; i < cm->numattrsets; i++) {
+ if ( !( qm->attr_sets[i].flags & PC_CONFIGURED ) ) {
+ if ( qm->attr_sets[i].flags & PC_REFERENCED ) {
+ Debug( LDAP_DEBUG_CONFIG, "pcache: attr set #%d not configured but referenced.\n", i, 0, 0 );
+ rf++;
+
+ } else {
+ Debug( LDAP_DEBUG_CONFIG, "pcache: warning, attr set #%d not configured.\n", i, 0, 0 );
+ }
+ ncf++;
+
+ } else if ( !( qm->attr_sets[i].flags & PC_REFERENCED ) ) {
+ Debug( LDAP_DEBUG_CONFIG, "pcache: attr set #%d configured but not referenced.\n", i, 0, 0 );
+ nrf++;
+ }
+ }
+
+ if ( ncf || rf || nrf ) {
+ Debug( LDAP_DEBUG_CONFIG, "pcache: warning, %d attr sets configured but not referenced.\n", nrf, 0, 0 );
+ Debug( LDAP_DEBUG_CONFIG, "pcache: warning, %d attr sets not configured.\n", ncf, 0, 0 );
+ Debug( LDAP_DEBUG_CONFIG, "pcache: %d attr sets not configured but referenced.\n", rf, 0, 0 );
+
+ if ( rf > 0 ) {
+ return 1;
+ }
+ }
+
+ /* need to inherit something from the original database... */
+ cm->db.be_def_limit = be->be_def_limit;
+ cm->db.be_limits = be->be_limits;
+ 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;
+ }
+
+ if ( !cm->defer_db_open )
+ rc = pcache_db_open2( on, cr );
return rc;
}
code = config_register_schema( pccfg, pcocs );
if ( code ) return code;
+ {
+ const char *text;
+ code = slap_str2ad( "olcDatabase", &pcdummy[0].ad, &text );
+ if ( code ) return code;
+ }
return overlay_register( &pcache );
}