From 4ba6a03aec3a97e1e4002a68905024fc1209c3cf Mon Sep 17 00:00:00 2001 From: Phillip Toland Date: Fri, 30 Jan 2009 12:42:58 -0600 Subject: [PATCH] Change the way timing is handled for the checkpointer to avoid problems on shutdown. --- c_src/bdberl_drv.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index 3e24806..2f69378 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -1346,17 +1346,29 @@ static void* trickle_write(void* arg) static void* txn_checkpoint(void* arg) { DBG("Checkpoint interval: %d seconds\n", G_CHECKPOINT_INTERVAL); + + int elapsed_secs = 0; while (G_CHECKPOINT_ACTIVE) { - G_DB_ENV->txn_checkpoint(G_DB_ENV, 0, 0, 0); - G_DB_ENV->log_archive(G_DB_ENV, NULL, DB_ARCH_REMOVE); + if (elapsed_secs == G_CHECKPOINT_INTERVAL) + { + G_DB_ENV->txn_checkpoint(G_DB_ENV, 0, 0, 0); + G_DB_ENV->log_archive(G_DB_ENV, NULL, DB_ARCH_REMOVE); #ifdef DEBUG - time_t tm = time(NULL); - printf("Transaction checkpoint complete at %s\n", ctime(&tm)); + time_t tm = time(NULL); + printf("Transaction checkpoint complete at %s\n", ctime(&tm)); #endif - sleep(G_CHECKPOINT_INTERVAL); + // Reset the counter + elapsed_secs = 0; + } + else + { + // TODO: Use nanosleep + usleep(1000 * 1000); /* Sleep for 1 second */ + elapsed_secs++; + } } DBG("Checkpointer exiting.\n");