summaryrefslogtreecommitdiff
path: root/lib/backupstore
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-02-27 23:35:50 +0000
committerChris Wilson <chris+github@qwirx.com>2014-02-27 23:35:50 +0000
commit9ffa4cabbcac60555f0656640e603f4830a7cb98 (patch)
tree7a8852c7f50d73c0c40656fd2b73b469b899eaea /lib/backupstore
parent119880f3c92aba8884086dfe4f5faf3e55820f74 (diff)
Fix crash in BackupStoreContext with no HousekeepingInterface pointer.
Rename mrDaemon to mpHousekeeping and make it a pointer, so that it can officially be NULL, and don't crash if it is, and we fail to get a lock on the account.
Diffstat (limited to 'lib/backupstore')
-rw-r--r--lib/backupstore/BackupProtocol.h2
-rw-r--r--lib/backupstore/BackupStoreContext.cpp8
-rw-r--r--lib/backupstore/BackupStoreContext.h5
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/backupstore/BackupProtocol.h b/lib/backupstore/BackupProtocol.h
index d2fe8b7f..8736b44f 100644
--- a/lib/backupstore/BackupProtocol.h
+++ b/lib/backupstore/BackupProtocol.h
@@ -35,7 +35,7 @@ public:
// This is rather ugly: the BackupProtocolLocal constructor must not
// touch the Context, because it's not initialised yet!
: BackupProtocolLocal(mContext),
- mContext(AccountNumber, *(HousekeepingInterface *)NULL,
+ mContext(AccountNumber, (HousekeepingInterface *)NULL,
ConnectionDetails)
{
mContext.SetClientHasAccount(AccountRootDir, DiscSetNumber);
diff --git a/lib/backupstore/BackupStoreContext.cpp b/lib/backupstore/BackupStoreContext.cpp
index 155abd7f..771bc960 100644
--- a/lib/backupstore/BackupStoreContext.cpp
+++ b/lib/backupstore/BackupStoreContext.cpp
@@ -54,10 +54,10 @@
//
// --------------------------------------------------------------------------
BackupStoreContext::BackupStoreContext(int32_t ClientID,
- HousekeepingInterface &rDaemon, const std::string& rConnectionDetails)
+ HousekeepingInterface* pHousekeeping, const std::string& rConnectionDetails)
: mConnectionDetails(rConnectionDetails),
mClientID(ClientID),
- mrDaemon(rDaemon),
+ mpHousekeeping(pHousekeeping),
mProtocolPhase(Phase_START),
mClientHasAccount(false),
mStoreDiscSet(-1),
@@ -160,13 +160,13 @@ bool BackupStoreContext::AttemptToGetWriteLock()
// Request the lock
bool gotLock = mWriteLock.TryAndGetLock(writeLockFile.c_str(), 0600 /* restrictive file permissions */);
- if(!gotLock)
+ if(!gotLock && mpHousekeeping)
{
// The housekeeping process might have the thing open -- ask it to stop
char msg[256];
int msgLen = sprintf(msg, "r%x\n", mClientID);
// Send message
- mrDaemon.SendMessageToHousekeepingProcess(msg, msgLen);
+ mpHousekeeping->SendMessageToHousekeepingProcess(msg, msgLen);
// Then try again a few times
int tries = MAX_WAIT_FOR_HOUSEKEEPING_TO_RELEASE_ACCOUNT;
diff --git a/lib/backupstore/BackupStoreContext.h b/lib/backupstore/BackupStoreContext.h
index 9dde2075..e0162636 100644
--- a/lib/backupstore/BackupStoreContext.h
+++ b/lib/backupstore/BackupStoreContext.h
@@ -45,7 +45,8 @@ class HousekeepingInterface
class BackupStoreContext
{
public:
- BackupStoreContext(int32_t ClientID, HousekeepingInterface &rDaemon,
+ BackupStoreContext(int32_t ClientID,
+ HousekeepingInterface* mpHousekeeping,
const std::string& rConnectionDetails);
~BackupStoreContext();
private:
@@ -173,7 +174,7 @@ private:
std::string mConnectionDetails;
int32_t mClientID;
- HousekeepingInterface &mrDaemon;
+ HousekeepingInterface *mpHousekeeping;
int mProtocolPhase;
bool mClientHasAccount;
std::string mAccountRootDir; // has final directory separator