From: Howard Chu Date: Sat, 23 Apr 2005 16:16:54 +0000 (+0000) Subject: Add hdb symbols, make sure only one indexer runs X-Git-Tag: OPENLDAP_AC_BP~813 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5639c07137ccef3bb7170f3a4d316a828f7b5757;p=openldap Add hdb symbols, make sure only one indexer runs --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index fb089a3413..dea33f671d 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -172,6 +172,7 @@ struct bdb_info { u_int32_t bi_txn_cp_min; u_int32_t bi_txn_cp_kbyte; void *bi_txn_cp_task; + void *bi_index_task; int bi_lock_detect; long bi_shm_key; diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index fcee27c978..6db61b2c49 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -30,6 +30,12 @@ # define SLAP_BDB_ALLOW_DIRTY_READ #endif +#define bdb_cf_oc BDB_SYMBOL(cf_oc) +#define bdb_cf_gen BDB_SYMBOL(cf_gen) +#define bdb_cf_cleanup BDB_SYMBOL(cf_cleanup) +#define bdb_checkpoint BDB_SYMBOL(checkpoint) +#define bdb_online_index BDB_SYMBOL(online_index) + static ObjectClass *bdb_oc; static ConfigDriver bdb_cf_oc, bdb_cf_gen; @@ -267,6 +273,7 @@ bdb_online_index( void *ctx, void *arg ) out: ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_stoptask( &slapd_rq, rtask ); + bdb->bi_index_task = NULL; ldap_pvt_runqueue_remove( &slapd_rq, rtask ); ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); @@ -299,15 +306,18 @@ bdb_cf_cleanup( ConfigArgs *c ) bdb_attr_flush( bdb ); bdb->bi_flags ^= BDB_DEL_INDEX; } - + if ( bdb->bi_flags & BDB_RE_OPEN ) { bdb->bi_flags ^= BDB_RE_OPEN; rc = c->be->bd_info->bi_db_close( c->be ); if ( rc == 0 ) rc = c->be->bd_info->bi_db_open( c->be ); /* If this fails, we need to restart */ - if ( rc ) - slapd_shutdown = 1; + if ( rc ) { + slapd_shutdown = 2; + Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_cf_cleanup) + ": failed to reopen database, rc=%d", rc, 0, 0 ); + } } return rc; } @@ -471,7 +481,7 @@ bdb_cf_gen(ConfigArgs *c) else bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb, - "bdb_checkpoint", c->be->be_suffix[0].bv_val ); + LDAP_XSTRING(bdb_checkpoint), c->be->be_suffix[0].bv_val ); } break; @@ -546,11 +556,11 @@ bdb_cf_gen(ConfigArgs *c) c->argc - 1, &c->argv[1] ); if( rc != LDAP_SUCCESS ) return 1; - if ( bdb->bi_flags & BDB_IS_OPEN ) { + if (( bdb->bi_flags & BDB_IS_OPEN ) && !bdb->bi_index_task ) { /* Start the task as soon as we finish here */ - ldap_pvt_runqueue_insert( &slapd_rq, 60, + bdb->bi_index_task = ldap_pvt_runqueue_insert( &slapd_rq, 60, bdb_online_index, c->be, - "bdb_online_index", c->be->be_suffix[0].bv_val ); + LDAP_XSTRING(bdb_online_index), c->be->be_suffix[0].bv_val ); } break;