diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 11:18:39 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 11:18:39 +0000 |
commit | 9cae0cb415d50e28d4819e54ce76131fbd9f7c1c (patch) | |
tree | d0adebf44b25de0b1ffd47b1de3182d3e24f69c5 /bin/bbstored | |
parent | 7dbcaff4f698c914f9307cb69e742983e3a1a4e1 (diff) |
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.
Diffstat (limited to 'bin/bbstored')
-rw-r--r-- | bin/bbstored/BBStoreDHousekeeping.cpp | 7 | ||||
-rw-r--r-- | bin/bbstored/BackupStoreContext.cpp | 3 | ||||
-rw-r--r-- | bin/bbstored/BackupStoreContext.h | 11 | ||||
-rw-r--r-- | bin/bbstored/BackupStoreDaemon.cpp | 15 | ||||
-rw-r--r-- | bin/bbstored/BackupStoreDaemon.h | 3 |
5 files changed, 27 insertions, 12 deletions
diff --git a/bin/bbstored/BBStoreDHousekeeping.cpp b/bin/bbstored/BBStoreDHousekeeping.cpp index 4694c0bb..51c0e9d6 100644 --- a/bin/bbstored/BBStoreDHousekeeping.cpp +++ b/bin/bbstored/BBStoreDHousekeeping.cpp @@ -155,7 +155,11 @@ void BackupStoreDaemon::RunHousekeepingIfNeeded() void BackupStoreDaemon::OnIdle() { - #ifdef WIN32 + if (!IsSingleProcess()) + { + return; + } + if (!mHousekeepingInited) { HousekeepingInit(); @@ -163,7 +167,6 @@ void BackupStoreDaemon::OnIdle() } RunHousekeepingIfNeeded(); - #endif } // -------------------------------------------------------------------------- diff --git a/bin/bbstored/BackupStoreContext.cpp b/bin/bbstored/BackupStoreContext.cpp index 815f2aca..8334658a 100644 --- a/bin/bbstored/BackupStoreContext.cpp +++ b/bin/bbstored/BackupStoreContext.cpp @@ -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), diff --git a/bin/bbstored/BackupStoreContext.h b/bin/bbstored/BackupStoreContext.h index 3f0ba55a..da0a7668 100644 --- a/bin/bbstored/BackupStoreContext.h +++ b/bin/bbstored/BackupStoreContext.h @@ -26,6 +26,13 @@ class IOStream; class BackupProtocolObject; class StreamableMemBlock; +class HousekeepingInterface +{ + public: + virtual ~HousekeepingInterface() { } + virtual void SendMessageToHousekeepingProcess(const void *Msg, int MsgLen) = 0; +}; + // -------------------------------------------------------------------------- // // Class @@ -37,7 +44,7 @@ class StreamableMemBlock; 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: private: int32_t mClientID; - BackupStoreDaemon &mrDaemon; + HousekeepingInterface &mrDaemon; int mProtocolPhase; bool mClientHasAccount; std::string mStoreRoot; // has final directory separator diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp index ca620df2..50bd0a2b 100644 --- a/bin/bbstored/BackupStoreDaemon.cpp +++ b/bin/bbstored/BackupStoreDaemon.cpp @@ -172,11 +172,12 @@ void BackupStoreDaemon::Run() 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 @@ void BackupStoreDaemon::Run() // 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); } diff --git a/bin/bbstored/BackupStoreDaemon.h b/bin/bbstored/BackupStoreDaemon.h index dff918a5..a5d216f4 100644 --- a/bin/bbstored/BackupStoreDaemon.h +++ b/bin/bbstored/BackupStoreDaemon.h @@ -28,7 +28,8 @@ class HousekeepStoreAccount; // Created: 2003/08/20 // // -------------------------------------------------------------------------- -class BackupStoreDaemon : public ServerTLS<BOX_PORT_BBSTORED> +class BackupStoreDaemon : public ServerTLS<BOX_PORT_BBSTORED>, + HousekeepingInterface { friend class HousekeepStoreAccount; |