From: Howard Chu Date: Fri, 3 Dec 2004 17:11:39 +0000 (+0000) Subject: Add a checkpoint task if time-based checkpointing is configured. X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~144 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=74da2306ff9aec8f49eff77ddccc53e25431ed15;p=openldap Add a checkpoint task if time-based checkpointing is configured. --- diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 3f7dd504e2..b4f752df9b 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -23,6 +23,7 @@ #include "back-bdb.h" #include +#include static const struct bdbi_database { char *file; @@ -125,6 +126,17 @@ bdb_bt_compare( return 0; } +static void * +bdb_checkpoint( void *ctx, void *arg ) +{ + struct re_s *rtask = arg; + struct bdb_info *bdb = rtask->arg; + + TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte, + bdb->bi_txn_cp_min, 0 ); + return NULL; +} + static int bdb_db_open( BackendDB *be ) { @@ -378,6 +390,17 @@ bdb_db_open( BackendDB *be ) XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker); + /* If we're in server mode and time-based checkpointing is enabled, + * submit a task to perform periodic checkpoints. + */ + if ( slapMode & SLAP_SERVER_MODE && bdb->bi_txn_cp && + bdb->bi_txn_cp_min ) { + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min*60, + bdb_checkpoint, bdb ); + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); + } + /* open (and create) index databases */ return 0; }