diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-04-06 19:41:26 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-04-06 19:41:26 +0000 |
commit | 5a1512912e369b8df78769a4a9ebd89c92e4556b (patch) | |
tree | e067a32e719309e126a7a4c56f6157a08a6e3138 | |
parent | 3cf9311eba9e6b8374b877eea385031936d187ba (diff) |
Fix test failures caused by failure to commit the temporary refcount DB.
Files need to be closed before renaming over them on Windows.
-rw-r--r-- | lib/backupstore/BackupStoreRefCountDatabase.cpp | 13 | ||||
-rw-r--r-- | lib/backupstore/HousekeepStoreAccount.cpp | 4 | ||||
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 5 |
3 files changed, 16 insertions, 6 deletions
diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp index 8929b691..8b51b70a 100644 --- a/lib/backupstore/BackupStoreRefCountDatabase.cpp +++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp @@ -96,15 +96,16 @@ void BackupStoreRefCountDatabase::Discard() "Cannot discard a permanent reference count database"); } - if (!mapDatabaseFile.get()) + // Under normal conditions, we should know whether the file is still + // open or not, and not Discard it unless it's open. However if the + // final rename() fails during Commit(), the file will already be + // closed, and we don't want to blow up here in that case. + if (mapDatabaseFile.get()) { - THROW_EXCEPTION_MESSAGE(CommonException, Internal, - "Reference count database is already closed"); + mapDatabaseFile->Close(); + mapDatabaseFile.reset(); } - mapDatabaseFile->Close(); - mapDatabaseFile.reset(); - if(unlink(mFilename.c_str()) != 0) { THROW_EMU_FILE_ERROR("Failed to delete temporary refcount " diff --git a/lib/backupstore/HousekeepStoreAccount.cpp b/lib/backupstore/HousekeepStoreAccount.cpp index 02e68857..6fcc3a7f 100644 --- a/lib/backupstore/HousekeepStoreAccount.cpp +++ b/lib/backupstore/HousekeepStoreAccount.cpp @@ -79,6 +79,10 @@ HousekeepStoreAccount::HousekeepStoreAccount(int AccountID, // -------------------------------------------------------------------------- HousekeepStoreAccount::~HousekeepStoreAccount() { + if(mapNewRefs.get()) + { + mapNewRefs->Discard(); + } } // -------------------------------------------------------------------------- diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 2e8f9f37..a39fd1ff 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -817,6 +817,11 @@ bool test_temporary_refcount_db_is_independent() BackupStoreException, UnknownObjectRefCountRequested); temp->Discard(); + // Need to delete perm object so it doesn't keep a filehandle open, + // preventing tearDown from rewriting the refcount DB and thus causing + // test failure. + perm.reset(); + return teardown_test_backupstore(); } |