diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-02-27 23:35:50 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-02-27 23:35:50 +0000 |
commit | 9ffa4cabbcac60555f0656640e603f4830a7cb98 (patch) | |
tree | 7a8852c7f50d73c0c40656fd2b73b469b899eaea | |
parent | 119880f3c92aba8884086dfe4f5faf3e55820f74 (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.
-rw-r--r-- | bin/bbstored/BackupStoreDaemon.cpp | 2 | ||||
-rw-r--r-- | lib/backupstore/BackupProtocol.h | 2 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreContext.cpp | 8 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreContext.h | 5 |
4 files changed, 9 insertions, 8 deletions
diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp index 70ca1d67..2649e0a2 100644 --- a/bin/bbstored/BackupStoreDaemon.cpp +++ b/bin/bbstored/BackupStoreDaemon.cpp @@ -329,7 +329,7 @@ void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream) Logging::Tagger tagWithClientID(tag.str()); // Create a context, using this ID - BackupStoreContext context(id, *this, GetConnectionDetails()); + BackupStoreContext context(id, this, GetConnectionDetails()); if (mpTestHook) { 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 |