From cdf951635090755796c1b3bb1a7d70811b7c6c80 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 4 Sep 2014 01:36:23 +0000 Subject: Allow access to BackupDaemon's BackupClientContext for tests. The std::auto_ptr is now returned unclosed. If the caller of RunSyncNow() does nothing with the return value, then it will be released, closing the connection. However the caller can save the std::auto_ptr locally and poke around in it if necessary. This interface is designed for tests only! Merged back changes from the test refactor branch to reduce diffs. Fix failure to record client store marker, after BackupClientContext refactor. This caused the daemon not to abort safely if the CSM changed under our feet, meaning that our cached data is invalid. Fix for earlier patch to allow tests to access the BackupClientContext after backup completes, because a new CSM wasn't generated in time for bbackupd to record it, because the connection wasn't closed yet. --- bin/bbackupd/BackupClientContext.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'bin/bbackupd/BackupClientContext.cpp') diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index 0c229f94..96f99806 100644 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -212,6 +212,17 @@ BackupProtocolCallable &BackupClientContext::GetConnection() "same account?"); } } + else // mClientStoreMarker == ClientStoreMarker_NotKnown + { + // Yes, choose one, the current time will do + box_time_t marker = GetCurrentBoxTime(); + + // Set it on the store + mapConnection->QuerySetClientStoreMarker(marker); + + // Record it so that it can be picked up later. + mClientStoreMarker = marker; + } // Log success BOX_INFO("Connection made, login successful"); @@ -250,19 +261,6 @@ void BackupClientContext::CloseAnyOpenConnection() { try { - // Need to set a client store marker? - if(mClientStoreMarker == ClientStoreMarker_NotKnown) - { - // Yes, choose one, the current time will do - box_time_t marker = GetCurrentBoxTime(); - - // Set it on the store - mapConnection->QuerySetClientStoreMarker(marker); - - // Record it so that it can be picked up later. - mClientStoreMarker = marker; - } - // Quit nicely mapConnection->QueryFinished(); } -- cgit v1.2.3