[Box Backup-commit] COMMIT r1063 - box/chris/general/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sun Oct 15 21:18:34 BST 2006


Author: chris
Date: 2006-10-15 21:18:33 +0100 (Sun, 15 Oct 2006)
New Revision: 1063

Modified:
   box/chris/general/bin/bbstored/BBStoreDHousekeeping.cpp
   box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
   box/chris/general/bin/bbstored/BackupStoreDaemon.h
Log:
Remove some #ifdefs to share more code between Win32 port and other platforms.


Modified: box/chris/general/bin/bbstored/BBStoreDHousekeeping.cpp
===================================================================
--- box/chris/general/bin/bbstored/BBStoreDHousekeeping.cpp	2006-10-15 19:59:30 UTC (rev 1062)
+++ box/chris/general/bin/bbstored/BBStoreDHousekeeping.cpp	2006-10-15 20:18:33 UTC (rev 1063)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 
 #ifdef HAVE_SYSLOG_H
-#include <syslog.h>
+	#include <syslog.h>
 #endif
 
 #include "BackupStoreDaemon.h"
@@ -38,7 +38,6 @@
 	mLastHousekeepingRun = 0;
 }
 
-#ifndef WIN32
 void BackupStoreDaemon::HousekeepingProcess()
 {
 	HousekeepingInit();
@@ -53,7 +52,9 @@
 
 		// Calculate how long should wait before doing the next housekeeping run
 		int64_t timeNow = GetCurrentBoxTime();
-		time_t secondsToGo = BoxTimeToSeconds((mLastHousekeepingRun + housekeepingInterval) - timeNow);
+		time_t secondsToGo = BoxTimeToSeconds(
+			(mLastHousekeepingRun + housekeepingInterval) - 
+			timeNow);
 		if(secondsToGo < 1) secondsToGo = 1;
 		if(secondsToGo > 60) secondsToGo = 60;
 		int32_t millisecondsToGo = ((int)secondsToGo) * 1000;
@@ -62,7 +63,6 @@
 		CheckForInterProcessMsg(0 /* no account */, millisecondsToGo);
 	}
 }
-#endif
 
 void BackupStoreDaemon::RunHousekeepingIfNeeded()
 {
@@ -124,10 +124,16 @@
 				*i);
 		}
 	
-#ifndef WIN32	
+		int64_t timeNow = GetCurrentBoxTime();
+		time_t secondsToGo = BoxTimeToSeconds(
+			(mLastHousekeepingRun + housekeepingInterval) - 
+			timeNow);
+		if(secondsToGo < 1) secondsToGo = 1;
+		if(secondsToGo > 60) secondsToGo = 60;
+		int32_t millisecondsToGo = ((int)secondsToGo) * 1000;
+
 		// Check to see if there's any message pending
-		CheckForInterProcessMsg(0 /* no account */);
-#endif
+		CheckForInterProcessMsg(0 /* no account */, millisecondsToGo);
 
 		// Stop early?
 		if(StopRun())
@@ -142,7 +148,6 @@
 	SetProcessTitle("housekeeping, idle");
 }
 
-#ifdef WIN32
 void BackupStoreDaemon::OnIdle()
 {
 	if (!mHousekeepingInited)
@@ -153,7 +158,6 @@
 
 	RunHousekeepingIfNeeded();
 }
-#endif
 
 // --------------------------------------------------------------------------
 //
@@ -164,7 +168,6 @@
 //		Created: 11/12/03
 //
 // --------------------------------------------------------------------------
-#ifndef WIN32
 bool BackupStoreDaemon::CheckForInterProcessMsg(int AccountNum, int MaximumWaitTime)
 {
 	// First, check to see if it's EOF -- this means something has gone wrong, and the housekeeping should terminate.
@@ -208,6 +211,5 @@
 	
 	return false;
 }
-#endif
 
 

Modified: box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2006-10-15 19:59:30 UTC (rev 1062)
+++ box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2006-10-15 20:18:33 UTC (rev 1063)
@@ -14,7 +14,7 @@
 #include <signal.h>
 
 #ifdef HAVE_SYSLOG_H
-#include <syslog.h>
+	#include <syslog.h>
 #endif
 
 #include "BackupContext.h"
@@ -41,12 +41,9 @@
 	  mpAccounts(0),
 	  mExtendedLogging(false),
 	  mHaveForkedHousekeeping(false),
-#ifdef WIN32
-	  mHousekeepingInited(false)
-#else
+	  mHousekeepingInited(false),
 	  mIsHousekeepingProcess(false),
 	  mInterProcessComms(mInterProcessCommsSocket)
-#endif
 {
 }
 
@@ -163,9 +160,13 @@
 	const Configuration &config(GetConfiguration());
 	mExtendedLogging = config.GetKeyValueBool("ExtendedLogging");
 	
-#ifndef WIN32	
+#ifdef WIN32	
+	// Housekeeping runs synchronously on Win32
+	if(false)
+#else
 	// Fork off housekeeping daemon -- must only do this the first time Run() is called
 	if(!mHaveForkedHousekeeping)
+#endif
 	{
 		// Open a socket pair for communication
 		int sv[2] = {-1,-1};
@@ -227,11 +228,9 @@
 	}
 	else
 	{
-#endif // !WIN32
 		// In server process -- use the base class to do the magic
 		ServerTLS<BOX_PORT_BBSTORED>::Run();
 		
-#ifndef WIN32	
 		// Why did it stop? Tell the housekeeping process to do the same
 		if(IsReloadConfigWanted())
 		{
@@ -242,7 +241,6 @@
 			mInterProcessCommsSocket.Write("t\n", 2);
 		}
 	}
-#endif
 }
 
 

Modified: box/chris/general/bin/bbstored/BackupStoreDaemon.h
===================================================================
--- box/chris/general/bin/bbstored/BackupStoreDaemon.h	2006-10-15 19:59:30 UTC (rev 1062)
+++ box/chris/general/bin/bbstored/BackupStoreDaemon.h	2006-10-15 20:18:33 UTC (rev 1063)
@@ -59,11 +59,9 @@
 
 	const ConfigurationVerify *GetConfigVerify() const;
 	
-#ifndef WIN32	
 	// Housekeeping functions
 	void HousekeepingProcess();
 	bool CheckForInterProcessMsg(int AccountNum = 0, int MaximumWaitTime = 0);
-#endif
 
 	void LogConnectionStats(const char *commonName, const SocketStreamTLS &s);
 
@@ -72,15 +70,12 @@
 	BackupStoreAccounts *mpAccounts;
 	bool mExtendedLogging;
 	bool mHaveForkedHousekeeping;
+	bool mIsHousekeepingProcess;
 	
-#ifdef WIN32
 	bool mHousekeepingInited;
 	virtual void OnIdle();
-#else
 	SocketStream mInterProcessCommsSocket;
 	IOStreamGetLine mInterProcessComms;
-	bool mIsHousekeepingProcess;
-#endif
 
 	void HousekeepingInit();
 	void RunHousekeepingIfNeeded();




More information about the Boxbackup-commit mailing list