From 9cc598dc355819a99b1d3a9a15e44bd4468a33b9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 8 Mar 2007 22:59:11 +0000 Subject: Run housekeeping in idle time on Win32 (refs #3) --- bin/bbstored/BBStoreDHousekeeping.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'bin/bbstored/BBStoreDHousekeeping.cpp') 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()) { -- cgit v1.2.3