[Box Backup-commit] COMMIT r1380 - box/chris/merge/bin/bbstored

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Thu, 08 Mar 2007 22:59:11 +0000


Author: chris
Date: 2007-03-08 22:59:11 +0000 (Thu, 08 Mar 2007)
New Revision: 1380

Modified:
   box/chris/merge/bin/bbstored/BBStoreDHousekeeping.cpp
   box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp
   box/chris/merge/bin/bbstored/BackupStoreDaemon.h
Log:
Run housekeeping in idle time on Win32 (refs #3)


Modified: box/chris/merge/bin/bbstored/BBStoreDHousekeeping.cpp
===================================================================
--- box/chris/merge/bin/bbstored/BBStoreDHousekeeping.cpp	2007-03-08 22:49:04 UTC (rev 1379)
+++ box/chris/merge/bin/bbstored/BBStoreDHousekeeping.cpp	2007-03-08 22:59:11 UTC (rev 1380)
@@ -50,7 +50,8 @@
 	{
 		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 @@
 
 	// 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 @@
 	SetProcessTitle("housekeeping, idle");
 }
 
+void BackupStoreDaemon::OnIdle()
+{
+	#ifdef WIN32
+	if (!mHousekeepingInited)
+	{
+		HousekeepingInit();
+		mHousekeepingInited = true;
+	}
+
+	RunHousekeepingIfNeeded();
+	#endif
+}
+
 // --------------------------------------------------------------------------
 //
 // Function
@@ -159,6 +174,11 @@
 // --------------------------------------------------------------------------
 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())
 	{

Modified: box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp	2007-03-08 22:49:04 UTC (rev 1379)
+++ box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp	2007-03-08 22:59:11 UTC (rev 1380)
@@ -42,6 +42,7 @@
 	  mExtendedLogging(false),
 	  mHaveForkedHousekeeping(false),
 	  mIsHousekeepingProcess(false),
+	  mHousekeepingInited(false),
 	  mInterProcessComms(mInterProcessCommsSocket)
 {
 }

Modified: box/chris/merge/bin/bbstored/BackupStoreDaemon.h
===================================================================
--- box/chris/merge/bin/bbstored/BackupStoreDaemon.h	2007-03-08 22:49:04 UTC (rev 1379)
+++ box/chris/merge/bin/bbstored/BackupStoreDaemon.h	2007-03-08 22:59:11 UTC (rev 1380)
@@ -72,10 +72,12 @@
 	bool mExtendedLogging;
 	bool mHaveForkedHousekeeping;
 	bool mIsHousekeepingProcess;
+	bool mHousekeepingInited;
 	
 	SocketStream mInterProcessCommsSocket;
 	IOStreamGetLine mInterProcessComms;
 
+	virtual void OnIdle();
 	void HousekeepingInit();
 	void RunHousekeepingIfNeeded();
 	int64_t mLastHousekeepingRun;