summaryrefslogtreecommitdiff
path: root/bin/bbstored/BBStoreDHousekeeping.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-03-08 22:59:11 +0000
committerChris Wilson <chris+github@qwirx.com>2007-03-08 22:59:11 +0000
commit9cc598dc355819a99b1d3a9a15e44bd4468a33b9 (patch)
tree7823a8e079a0119dfd691c11396da8b256aa5b24 /bin/bbstored/BBStoreDHousekeeping.cpp
parent9b2936484eab81f77eae0a64ca843fde0fd00f7e (diff)
Run housekeeping in idle time on Win32 (refs #3)
Diffstat (limited to 'bin/bbstored/BBStoreDHousekeeping.cpp')
-rw-r--r--bin/bbstored/BBStoreDHousekeeping.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/bbstored/BBStoreDHousekeeping.cpp b/bin/bbstored/BBStoreDHousekeeping.cpp
index 8c725b0f..a4b26a93 100644
--- a/bin/bbstored/BBStoreDHousekeeping.cpp
+++ b/bin/bbstored/BBStoreDHousekeeping.cpp
@@ -50,7 +50,8 @@ void BackupStoreDaemon::HousekeepingProcess()
{
RunHousekeepingIfNeeded();
- // Calculate how long should wait before doing the next housekeeping run
+ // Calculate how long should wait before doing the next
+ // housekeeping run
int64_t timeNow = GetCurrentBoxTime();
time_t secondsToGo = BoxTimeToSeconds(
(mLastHousekeepingRun + housekeepingInterval) -
@@ -72,6 +73,7 @@ void BackupStoreDaemon::RunHousekeepingIfNeeded()
// Time now
int64_t timeNow = GetCurrentBoxTime();
+
// Do housekeeping if the time interval has elapsed since the last check
if((timeNow - mLastHousekeepingRun) < housekeepingInterval)
{
@@ -148,6 +150,19 @@ void BackupStoreDaemon::RunHousekeepingIfNeeded()
SetProcessTitle("housekeeping, idle");
}
+void BackupStoreDaemon::OnIdle()
+{
+ #ifdef WIN32
+ if (!mHousekeepingInited)
+ {
+ HousekeepingInit();
+ mHousekeepingInited = true;
+ }
+
+ RunHousekeepingIfNeeded();
+ #endif
+}
+
// --------------------------------------------------------------------------
//
// Function
@@ -159,6 +174,11 @@ void BackupStoreDaemon::RunHousekeepingIfNeeded()
// --------------------------------------------------------------------------
bool BackupStoreDaemon::CheckForInterProcessMsg(int AccountNum, int MaximumWaitTime)
{
+ if(!mInterProcessCommsSocket.IsOpened())
+ {
+ return false;
+ }
+
// First, check to see if it's EOF -- this means something has gone wrong, and the housekeeping should terminate.
if(mInterProcessComms.IsEOF())
{