From 9a6b3851cd1da2d29c93b1076597512551ccc064 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 19 Sep 2015 23:06:18 +0100 Subject: Comments and whitespace fixes --- lib/backupstore/BackupStoreDirectory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreDirectory.cpp b/lib/backupstore/BackupStoreDirectory.cpp index 332eca7a..9507ab0d 100644 --- a/lib/backupstore/BackupStoreDirectory.cpp +++ b/lib/backupstore/BackupStoreDirectory.cpp @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------- // // File -// Name: BackupStoreDirectory.h +// Name: BackupStoreDirectory.cpp // Purpose: Representation of a backup directory // Created: 2003/08/26 // @@ -172,7 +172,7 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) int count = ntohl(hdr.mNumEntries); // Clear existing list - for(std::vector::iterator i = mEntries.begin(); + for(std::vector::iterator i = mEntries.begin(); i != mEntries.end(); i++) { delete (*i); -- cgit v1.2.3 From eaa6b1883ba00ab32715f74572ba240286821a6b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 19 Sep 2015 23:06:35 +0100 Subject: Add a test for reading and writing BackupStoreDirectory binary data. See discussion of incompatible struct packing on ARM processors: http://lists.boxbackup.org/pipermail/boxbackup/2010-November/005818.html http://lists.boxbackup.org/pipermail/boxbackup/2011-February/005978.html Thanks to Leif Linderstam for identifying the problem and proposing a solution. This is just a test for the problem, not a fix in itself. --- lib/backupstore/BackupStoreDirectory.cpp | 5 ----- lib/backupstore/BackupStoreDirectory.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreDirectory.cpp b/lib/backupstore/BackupStoreDirectory.cpp index 9507ab0d..d158cdd4 100644 --- a/lib/backupstore/BackupStoreDirectory.cpp +++ b/lib/backupstore/BackupStoreDirectory.cpp @@ -36,11 +36,6 @@ typedef struct // Then a StreamableMemBlock for attributes } dir_StreamFormat; -typedef enum -{ - Option_DependencyInfoPresent = 1 -} dir_StreamFormatOptions; - typedef struct { uint64_t mModificationTime; diff --git a/lib/backupstore/BackupStoreDirectory.h b/lib/backupstore/BackupStoreDirectory.h index 5bbb0b35..788a3ad0 100644 --- a/lib/backupstore/BackupStoreDirectory.h +++ b/lib/backupstore/BackupStoreDirectory.h @@ -47,6 +47,11 @@ public: } #endif + typedef enum + { + Option_DependencyInfoPresent = 1 + } dir_StreamFormatOptions; + BackupStoreDirectory(); BackupStoreDirectory(int64_t ObjectID, int64_t ContainerID); // Convenience constructor from a stream -- cgit v1.2.3 From 2cbdea2166057c3c3996e733d78048d528fa694e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 20 Sep 2015 21:31:23 +0100 Subject: Remove all timing dependency from test_ssl_keepalives(). This test has always been fragile, and usually fails on Travis for reasons unknown, so replace the log parsing and intercepts with simple mocking code. This doesn't cover 100% of what the old test did, including diff timer aborts and the number of blocks used by the uploaded files, but it should be completely robust. --- lib/backupstore/BackupStoreFileEncodeStream.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreFileEncodeStream.h b/lib/backupstore/BackupStoreFileEncodeStream.h index 6db09182..5b9b4a61 100644 --- a/lib/backupstore/BackupStoreFileEncodeStream.h +++ b/lib/backupstore/BackupStoreFileEncodeStream.h @@ -90,6 +90,9 @@ public: int64_t GetBytesToUpload() { return mBytesToUpload; } int64_t GetTotalBytesSent() { return mTotalBytesSent; } + static void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut, + int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut); + private: enum { @@ -98,15 +101,12 @@ private: Status_BlockListing = 2, Status_Finished = 3 }; - -private: + void EncodeCurrentBlock(); - void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut, int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut); void SkipPreviousBlocksInInstruction(); void SetForInstruction(); void StoreBlockIndexEntry(int64_t WncSizeOrBlkIndex, int32_t ClearSize, uint32_t WeakChecksum, uint8_t *pStrongChecksum); -private: Recipe *mpRecipe; IOStream *mpFile; // source file CollectInBufferStream mData; // buffer for header and index entries -- cgit v1.2.3 From d8378f071e54512f41e076547357f663125bea7f Mon Sep 17 00:00:00 2001 From: AG Date: Mon, 26 Oct 2015 22:28:24 +0100 Subject: min & max are not from std namespace u_int8_t is unsigned char strings.h file is missing errors generated by deprecated functions are now hidden (C4996 warning) --- lib/backupstore/BackupStoreFile.cpp | 4 ++-- lib/backupstore/BackupStoreRefCountDatabase.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreFile.cpp b/lib/backupstore/BackupStoreFile.cpp index 99562685..5ceefe90 100644 --- a/lib/backupstore/BackupStoreFile.cpp +++ b/lib/backupstore/BackupStoreFile.cpp @@ -304,7 +304,7 @@ void BackupStoreFile::VerifyStream::Write(const void *pBuffer, int NBytes, int T size_t BytesLeftInCurrentUnit = mCurrentUnitSize - mCurrentUnitData.GetSize(); // Add however many bytes are needed/available to the current unit's buffer. - BytesToAdd = std::min(BytesLeftInCurrentUnit, (size_t)NBytes); + BytesToAdd = min(BytesLeftInCurrentUnit, (size_t)NBytes); } // We must make progress here, or we could have infinite recursion. @@ -502,7 +502,7 @@ void BackupStoreFile::VerifyStream::Close(bool CloseCopyStream) CollectInBufferStream* pPreviousBuffer = mCurrentBufferIsAlternate ? &mCurrentUnitData : &mAlternateData; - int64_t BytesFromCurrentBuffer = std::min(mBlockIndexSize, + int64_t BytesFromCurrentBuffer = min(mBlockIndexSize, (int64_t)pCurrentBuffer->GetSize()); int64_t BytesFromPreviousBuffer = mBlockIndexSize - BytesFromCurrentBuffer; diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp index 8b51b70a..24c7b38e 100644 --- a/lib/backupstore/BackupStoreRefCountDatabase.cpp +++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp @@ -346,7 +346,7 @@ int BackupStoreRefCountDatabase::ReportChangesTo(BackupStoreRefCountDatabase& rO int64_t MaxNewObjectId = GetLastObjectIDUsed(); for (int64_t ObjectID = BACKUPSTORE_ROOT_DIRECTORY_ID; - ObjectID < std::max(MaxOldObjectId, MaxNewObjectId); + ObjectID < max(MaxOldObjectId, MaxNewObjectId); ObjectID++) { typedef BackupStoreRefCountDatabase::refcount_t refcount_t; -- cgit v1.2.3 From 57198ec30c5678c5a5ed26ef6b345d289bb48e50 Mon Sep 17 00:00:00 2001 From: AG Date: Mon, 26 Oct 2015 23:18:51 +0100 Subject: add specific define to allow the use of std::min and sd::max from windows --- lib/backupstore/BackupStoreFile.cpp | 4 ++-- lib/backupstore/BackupStoreRefCountDatabase.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreFile.cpp b/lib/backupstore/BackupStoreFile.cpp index 5ceefe90..99562685 100644 --- a/lib/backupstore/BackupStoreFile.cpp +++ b/lib/backupstore/BackupStoreFile.cpp @@ -304,7 +304,7 @@ void BackupStoreFile::VerifyStream::Write(const void *pBuffer, int NBytes, int T size_t BytesLeftInCurrentUnit = mCurrentUnitSize - mCurrentUnitData.GetSize(); // Add however many bytes are needed/available to the current unit's buffer. - BytesToAdd = min(BytesLeftInCurrentUnit, (size_t)NBytes); + BytesToAdd = std::min(BytesLeftInCurrentUnit, (size_t)NBytes); } // We must make progress here, or we could have infinite recursion. @@ -502,7 +502,7 @@ void BackupStoreFile::VerifyStream::Close(bool CloseCopyStream) CollectInBufferStream* pPreviousBuffer = mCurrentBufferIsAlternate ? &mCurrentUnitData : &mAlternateData; - int64_t BytesFromCurrentBuffer = min(mBlockIndexSize, + int64_t BytesFromCurrentBuffer = std::min(mBlockIndexSize, (int64_t)pCurrentBuffer->GetSize()); int64_t BytesFromPreviousBuffer = mBlockIndexSize - BytesFromCurrentBuffer; diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp index 24c7b38e..8b51b70a 100644 --- a/lib/backupstore/BackupStoreRefCountDatabase.cpp +++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp @@ -346,7 +346,7 @@ int BackupStoreRefCountDatabase::ReportChangesTo(BackupStoreRefCountDatabase& rO int64_t MaxNewObjectId = GetLastObjectIDUsed(); for (int64_t ObjectID = BACKUPSTORE_ROOT_DIRECTORY_ID; - ObjectID < max(MaxOldObjectId, MaxNewObjectId); + ObjectID < std::max(MaxOldObjectId, MaxNewObjectId); ObjectID++) { typedef BackupStoreRefCountDatabase::refcount_t refcount_t; -- cgit v1.2.3