summaryrefslogtreecommitdiff
path: root/bin/bbstored/BackupStoreDaemon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbstored/BackupStoreDaemon.cpp')
-rw-r--r--bin/bbstored/BackupStoreDaemon.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp
index 28e28176..4de0a078 100644
--- a/bin/bbstored/BackupStoreDaemon.cpp
+++ b/bin/bbstored/BackupStoreDaemon.cpp
@@ -17,7 +17,7 @@
#include <syslog.h>
#endif
-#include "BackupContext.h"
+#include "BackupStoreContext.h"
#include "BackupStoreDaemon.h"
#include "BackupStoreConfigVerify.h"
#include "autogen_BackupProtocolServer.h"
@@ -43,7 +43,8 @@ BackupStoreDaemon::BackupStoreDaemon()
mHaveForkedHousekeeping(false),
mIsHousekeepingProcess(false),
mHousekeepingInited(false),
- mInterProcessComms(mInterProcessCommsSocket)
+ mInterProcessComms(mInterProcessCommsSocket),
+ mpTestHook(NULL)
{
}
@@ -171,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};
@@ -205,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);
}
@@ -317,10 +321,18 @@ void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream)
}
// Make ps listings clearer
- SetProcessTitle("client %08x", id);
+ std::ostringstream tag;
+ tag << "client=" << BOX_FORMAT_ACCOUNT(id);
+ SetProcessTitle(tag.str().c_str());
+ Logging::Tagger tagWithClientID(tag.str());
// Create a context, using this ID
- BackupContext context(id, *this);
+ BackupStoreContext context(id, *this);
+
+ if (mpTestHook)
+ {
+ context.SetTestHook(*mpTestHook);
+ }
// See if the client has an account?
if(mpAccounts && mpAccounts->AccountExists(id))
@@ -352,7 +364,7 @@ void BackupStoreDaemon::LogConnectionStats(const char *commonName,
const SocketStreamTLS &s)
{
// Log the amount of data transferred
- BOX_INFO("Connection statistics for " << commonName << ":"
+ BOX_NOTICE("Connection statistics for " << commonName << ":"
" IN=" << s.GetBytesRead() <<
" OUT=" << s.GetBytesWritten() <<
" TOTAL=" << (s.GetBytesRead() + s.GetBytesWritten()));