From 74da2306ff9aec8f49eff77ddccc53e25431ed15 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 3 Dec 2004 17:11:39 +0000 Subject: [PATCH] Add a checkpoint task if time-based checkpointing is configured. --- servers/slapd/back-bdb/init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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; } -- 2.39.5