From dbcf98b4d9ca10a7e2365765b970887eb3fd4d61 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 8 Oct 2007 06:34:57 +0000 Subject: [PATCH] Refuse to operate on cacheDB if it hasn't been started yet --- servers/slapd/overlays/pcache.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index b6c59566fa..f9b66904e3 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -2206,6 +2206,13 @@ pcache_op_privdb( return SLAP_CB_CONTINUE; } + /* The cache DB isn't open yet */ + if ( cm->defer_db_open ) { + send_ldap_error( op, rs, LDAP_UNAVAILABLE, + "pcachePrivDB: cacheDB not available" ); + return rs->sr_err; + } + /* FIXME: might be a little bit exaggerated... */ if ( !be_isroot( op ) ) { save_cb = op->o_callback; @@ -2278,6 +2285,13 @@ pcache_op_search( } #endif /* PCACHE_CONTROL_PRIVDB */ + /* The cache DB isn't open yet */ + if ( cm->defer_db_open ) { + send_ldap_error( op, rs, LDAP_UNAVAILABLE, + "pcachePrivDB: cacheDB not available" ); + return rs->sr_err; + } + tempstr.bv_val = op->o_tmpalloc( op->ors_filterstr.bv_len+1, op->o_tmpmemctx ); tempstr.bv_len = 0; if ( filter2template( op, op->ors_filter, &tempstr, &filter_attrs, @@ -3184,9 +3198,12 @@ pcache_db_open2( int rc; rc = backend_startup_one( &cm->db, NULL ); + if ( rc == 0 ) { + cm->defer_db_open = 0; + } /* There is no runqueue in TOOL mode */ - if ( slapMode & SLAP_SERVER_MODE ) { + if (( slapMode & SLAP_SERVER_MODE ) && rc == 0 ) { ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_insert( &slapd_rq, cm->cc_period, consistency_check, on, -- 2.39.5