summaryrefslogtreecommitdiff
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
parent9b2936484eab81f77eae0a64ca843fde0fd00f7e (diff)
Run housekeeping in idle time on Win32 (refs #3)
-rw-r--r--bin/bbstored/BBStoreDHousekeeping.cpp22
-rw-r--r--bin/bbstored/BackupStoreDaemon.cpp1
-rw-r--r--bin/bbstored/BackupStoreDaemon.h2
3 files changed, 24 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())
{
diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp
index 06d529c3..335135ce 100644
--- a/bin/bbstored/BackupStoreDaemon.cpp
+++ b/bin/bbstored/BackupStoreDaemon.cpp
@@ -42,6 +42,7 @@ BackupStoreDaemon::BackupStoreDaemon()
mExtendedLogging(false),
mHaveForkedHousekeeping(false),
mIsHousekeepingProcess(false),
+ mHousekeepingInited(false),
mInterProcessComms(mInterProcessCommsSocket)
{
}
diff --git a/bin/bbstored/BackupStoreDaemon.h b/bin/bbstored/BackupStoreDaemon.h
index eea47284..eb665440 100644
--- a/bin/bbstored/BackupStoreDaemon.h
+++ b/bin/bbstored/BackupStoreDaemon.h
@@ -72,10 +72,12 @@ private:
bool mExtendedLogging;
bool mHaveForkedHousekeeping;
bool mIsHousekeepingProcess;
+ bool mHousekeepingInited;
SocketStream mInterProcessCommsSocket;
IOStreamGetLine mInterProcessComms;
+ virtual void OnIdle();
void HousekeepingInit();
void RunHousekeepingIfNeeded();
int64_t mLastHousekeepingRun;