]> git.sur5r.net Git - openldap/commitdiff
Refuse to operate on cacheDB if it hasn't been started yet
authorHoward Chu <hyc@openldap.org>
Mon, 8 Oct 2007 06:34:57 +0000 (06:34 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 8 Oct 2007 06:34:57 +0000 (06:34 +0000)
servers/slapd/overlays/pcache.c

index b6c59566fa752aa05bdeb75de7be5ee44721589f..f9b66904e3dc71c41258a4e4cc320d3c6113264d 100644 (file)
@@ -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,