[Box Backup-commit] COMMIT r2262 - box/trunk/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Aug 21 12:18:39 BST 2008


Author: chris
Date: 2008-08-21 12:18:39 +0100 (Thu, 21 Aug 2008)
New Revision: 2262

Modified:
   box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
   box/trunk/bin/bbstored/BackupStoreContext.cpp
   box/trunk/bin/bbstored/BackupStoreContext.h
   box/trunk/bin/bbstored/BackupStoreDaemon.cpp
   box/trunk/bin/bbstored/BackupStoreDaemon.h
Log:
Run housekeeping synchronously on all platforms if daemon is run in 
single process mode (-D), not just on Windows.

Add a housekeeping interface to allow Boxi to run housekeeping.


Modified: box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
===================================================================
--- box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp	2008-08-21 11:15:12 UTC (rev 2261)
+++ box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp	2008-08-21 11:18:39 UTC (rev 2262)
@@ -155,7 +155,11 @@
 
 void BackupStoreDaemon::OnIdle()
 {
-	#ifdef WIN32
+	if (!IsSingleProcess())
+	{
+		return;
+	}
+
 	if (!mHousekeepingInited)
 	{
 		HousekeepingInit();
@@ -163,7 +167,6 @@
 	}
 
 	RunHousekeepingIfNeeded();
-	#endif
 }
 
 // --------------------------------------------------------------------------

Modified: box/trunk/bin/bbstored/BackupStoreContext.cpp
===================================================================
--- box/trunk/bin/bbstored/BackupStoreContext.cpp	2008-08-21 11:15:12 UTC (rev 2261)
+++ box/trunk/bin/bbstored/BackupStoreContext.cpp	2008-08-21 11:18:39 UTC (rev 2262)
@@ -53,7 +53,8 @@
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
-BackupStoreContext::BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon)
+BackupStoreContext::BackupStoreContext(int32_t ClientID,
+	HousekeepingInterface &rDaemon)
 	: mClientID(ClientID),
 	  mrDaemon(rDaemon),
 	  mProtocolPhase(Phase_START),

Modified: box/trunk/bin/bbstored/BackupStoreContext.h
===================================================================
--- box/trunk/bin/bbstored/BackupStoreContext.h	2008-08-21 11:15:12 UTC (rev 2261)
+++ box/trunk/bin/bbstored/BackupStoreContext.h	2008-08-21 11:18:39 UTC (rev 2262)
@@ -26,6 +26,13 @@
 class BackupProtocolObject;
 class StreamableMemBlock;
 
+class HousekeepingInterface
+{
+	public:
+	virtual ~HousekeepingInterface() { }
+	virtual void SendMessageToHousekeepingProcess(const void *Msg, int MsgLen) = 0;
+};
+
 // --------------------------------------------------------------------------
 //
 // Class
@@ -37,7 +44,7 @@
 class BackupStoreContext
 {
 public:
-	BackupStoreContext(int32_t ClientID, BackupStoreDaemon &rDaemon);
+	BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon);
 	~BackupStoreContext();
 private:
 	BackupStoreContext(const BackupStoreContext &rToCopy);
@@ -131,7 +138,7 @@
 
 private:
 	int32_t mClientID;
-	BackupStoreDaemon &mrDaemon;
+	HousekeepingInterface &mrDaemon;
 	int mProtocolPhase;
 	bool mClientHasAccount;
 	std::string mStoreRoot;	// has final directory separator

Modified: box/trunk/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/trunk/bin/bbstored/BackupStoreDaemon.cpp	2008-08-21 11:15:12 UTC (rev 2261)
+++ box/trunk/bin/bbstored/BackupStoreDaemon.cpp	2008-08-21 11:18:39 UTC (rev 2262)
@@ -172,11 +172,12 @@
 	const Configuration &config(GetConfiguration());
 	mExtendedLogging = config.GetKeyValueBool("ExtendedLogging");
 	
-#ifdef WIN32	
-	// Housekeeping runs synchronously on Win32
-#else
-	// Fork off housekeeping daemon -- must only do this the first time Run() is called
-	if(!mHaveForkedHousekeeping)
+	// Fork off housekeeping daemon -- must only do this the first
+	// time Run() is called.  Housekeeping runs synchronously on Win32
+	// because IsSingleProcess() is always true
+	
+#ifndef WIN32
+	if(!IsSingleProcess() && !mHaveForkedHousekeeping)
 	{
 		// Open a socket pair for communication
 		int sv[2] = {-1,-1};
@@ -206,7 +207,9 @@
 				// Log that housekeeping started
 				BOX_INFO("Housekeeping process started");
 				// Ignore term and hup
-				// Parent will handle these and alert the child via the socket, don't want to randomly die
+				// Parent will handle these and alert the
+				// child via the socket, don't want to
+				// randomly die!
 				::signal(SIGHUP, SIG_IGN);
 				::signal(SIGTERM, SIG_IGN);
 			}

Modified: box/trunk/bin/bbstored/BackupStoreDaemon.h
===================================================================
--- box/trunk/bin/bbstored/BackupStoreDaemon.h	2008-08-21 11:15:12 UTC (rev 2261)
+++ box/trunk/bin/bbstored/BackupStoreDaemon.h	2008-08-21 11:18:39 UTC (rev 2262)
@@ -28,7 +28,8 @@
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
-class BackupStoreDaemon : public ServerTLS<BOX_PORT_BBSTORED>
+class BackupStoreDaemon : public ServerTLS<BOX_PORT_BBSTORED>,
+	HousekeepingInterface
 {
 	friend class HousekeepStoreAccount;
 




More information about the Boxbackup-commit mailing list