]> git.sur5r.net Git - openldap/commitdiff
Add a checkpoint task if time-based checkpointing is configured.
authorHoward Chu <hyc@openldap.org>
Fri, 3 Dec 2004 17:11:39 +0000 (17:11 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 3 Dec 2004 17:11:39 +0000 (17:11 +0000)
servers/slapd/back-bdb/init.c

index 3f7dd504e2a2444e633bde368ae05d3b757f6b7c..b4f752df9b5f564f1f172bac47f0584e1f98c5ad 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "back-bdb.h"
 #include <lutil.h>
+#include <ldap_rq.h>
 
 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 );
+       }
+
        /* <insert> open (and create) index databases */
        return 0;
 }