diff options
author | Ben Summers <ben@fluffy.co.uk> | 2006-02-13 13:30:21 +0000 |
---|---|---|
committer | Ben Summers <ben@fluffy.co.uk> | 2006-02-13 13:30:21 +0000 |
commit | 830aa82e44381c85d8486e46de7ae0e26830457e (patch) | |
tree | f29edb3c3013990a3ae758e1ccfdb56a2d20923f /lib/backupclient | |
parent | 2edd0a00e3244cc4dbc369d81ed1748768a06fb8 (diff) |
Merge chris/win32/vc2005-compile-fixes @ r455, add infrastructure/msvc to distribution
Diffstat (limited to 'lib/backupclient')
-rw-r--r-- | lib/backupclient/BackupClientFileAttributes.cpp | 14 | ||||
-rw-r--r-- | lib/backupclient/BackupClientRestore.cpp | 5 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFile.cpp | 7 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFileDiff.cpp | 53 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreFilenameClear.cpp | 4 | ||||
-rw-r--r-- | lib/backupclient/BackupStoreObjectDump.cpp | 8 |
6 files changed, 55 insertions, 36 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index 3e59a265..3bb7dfeb 100644 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -9,10 +9,13 @@ #include "Box.h" +#ifdef HAVE_UNISTD_H + #include <unistd.h> +#endif + #include <sys/types.h> #include <sys/stat.h> #include <string.h> -#include <unistd.h> #include <limits.h> #include <algorithm> #include <new> @@ -334,7 +337,12 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM box_time_t modSecs = BoxTimeToSeconds(modTime); __time64_t winTime = modSecs; - if (_gmtime64(&winTime) == 0 ) + // _MAX__TIME64_T doesn't seem to be defined, but the code below + // will throw an assertion failure if we exceed it :-) + // Microsoft says dates up to the year 3000 are valid, which + // is a bit more than 15 * 2^32. Even that doesn't seem + // to be true (still aborts), but it can at least hold 2^32. + if (winTime >= 0x100000000LL || _gmtime64(&winTime) == 0) { ::syslog(LOG_ERR, "Invalid Modification Time " "caught for file: %s", Filename); @@ -345,7 +353,7 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM modSecs = BoxTimeToSeconds(modTime); winTime = modSecs; - if (_gmtime64(&winTime) == 0 ) + if (winTime > 0x100000000LL || _gmtime64(&winTime) == 0) { ::syslog(LOG_ERR, "Invalid Attribute Modification " "Time caught for file: %s", Filename); diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp index ebe1d365..fbb4ee47 100644 --- a/lib/backupclient/BackupClientRestore.cpp +++ b/lib/backupclient/BackupClientRestore.cpp @@ -9,11 +9,14 @@ #include "Box.h" +#ifdef HAVE_UNISTD_H + #include <unistd.h> +#endif + #include <sys/types.h> #include <sys/stat.h> #include <string> #include <set> -#include <unistd.h> #include <limits.h> #include <stdio.h> diff --git a/lib/backupclient/BackupStoreFile.cpp b/lib/backupclient/BackupStoreFile.cpp index fd1a8918..f5a55207 100644 --- a/lib/backupclient/BackupStoreFile.cpp +++ b/lib/backupclient/BackupStoreFile.cpp @@ -9,7 +9,10 @@ #include "Box.h" -#include <unistd.h> +#ifdef HAVE_UNISTD_H + #include <unistd.h> +#endif + #include <sys/stat.h> #include <string.h> #include <new> @@ -1480,7 +1483,9 @@ void BackupStoreFile::EncodingBuffer::Allocate(int Size) // -------------------------------------------------------------------------- void BackupStoreFile::EncodingBuffer::Reallocate(int NewSize) { +#ifndef WIN32 TRACE2("Reallocating EncodingBuffer from %d to %d\n", mBufferSize, NewSize); +#endif ASSERT(mpBuffer != 0); uint8_t *buffer = (uint8_t*)BackupStoreFile::CodingChunkAlloc(NewSize); if(buffer == 0) diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp index 78890008..ee09f1c8 100644 --- a/lib/backupclient/BackupStoreFileDiff.cpp +++ b/lib/backupclient/BackupStoreFileDiff.cpp @@ -577,6 +577,31 @@ static void SearchForMatchingBlocks(IOStream &rFile, std::map<int64_t, int64_t> int rollOverInitialBytes = 0; while(true) { + if(sDiffTimerExpired) + { + ASSERT(TimeMgmtEpoch > 0); + ASSERT(pDiffTimer != NULL); + + time_t tTotalRunIntvl = time(NULL) - TimeMgmtEpoch; + + if(MaximumDiffingTime > 0 && + tTotalRunIntvl >= MaximumDiffingTime) + { + TRACE0("MaximumDiffingTime reached - " + "suspending file diff\n"); + abortSearch = true; + break; + } + else if(KeepAliveTime > 0) + { + TRACE0("KeepAliveTime reached - " + "initiating keep-alive\n"); + pDiffTimer->DoKeepAlive(); + } + + sDiffTimerExpired = false; + } + // Load in another block of data, and record how big it is int bytesInEndings = rFile.Read(endings, Sizes[s]); int tmp; @@ -661,38 +686,12 @@ static void SearchForMatchingBlocks(IOStream &rFile, std::map<int64_t, int64_t> break; } - bool DiffTimedOut = false; - - if(sDiffTimerExpired) - { - ASSERT(TimeMgmtEpoch > 0); - ASSERT(pDiffTimer != NULL); - - time_t tTotalRunIntvl = time(NULL) - TimeMgmtEpoch; - - if(MaximumDiffingTime > 0 && - tTotalRunIntvl >= MaximumDiffingTime) - { - TRACE0("MaximumDiffingTime reached - " - "suspending file diff\n"); - DiffTimedOut = true; - } - else if(KeepAliveTime > 0) - { - TRACE0("KeepAliveTime reached - " - "initiating keep-alive\n"); - pDiffTimer->DoKeepAlive(); - } - - sDiffTimerExpired = false; - } - int64_t NumBlocksFound = static_cast<int64_t>( rFoundBlocks.size()); int64_t MaxBlocksFound = NumBlocks * BACKUP_FILE_DIFF_MAX_BLOCK_FIND_MULTIPLE; - if(NumBlocksFound > MaxBlocksFound || DiffTimedOut) + if(NumBlocksFound > MaxBlocksFound) { abortSearch = true; break; diff --git a/lib/backupclient/BackupStoreFilenameClear.cpp b/lib/backupclient/BackupStoreFilenameClear.cpp index 7c36d5b3..c415b9bb 100644 --- a/lib/backupclient/BackupStoreFilenameClear.cpp +++ b/lib/backupclient/BackupStoreFilenameClear.cpp @@ -191,7 +191,9 @@ static void EnsureEncDecBufferSize(int BufSize) { if(spEncDecBuffer == 0) { +#ifndef WIN32 TRACE1("Allocating filename encoding/decoding buffer with size %d\n", BufSize); +#endif spEncDecBuffer = new MemoryBlockGuard<uint8_t *>(BufSize); MEMLEAKFINDER_NOT_A_LEAK(spEncDecBuffer); MEMLEAKFINDER_NOT_A_LEAK(*spEncDecBuffer); @@ -201,7 +203,9 @@ static void EnsureEncDecBufferSize(int BufSize) { if(sEncDecBufferSize < BufSize) { +#ifndef WIN32 TRACE2("Reallocating filename encoding/decoding buffer from %d to %d\n", sEncDecBufferSize, BufSize); +#endif spEncDecBuffer->Resize(BufSize); sEncDecBufferSize = BufSize; MEMLEAKFINDER_NOT_A_LEAK(*spEncDecBuffer); diff --git a/lib/backupclient/BackupStoreObjectDump.cpp b/lib/backupclient/BackupStoreObjectDump.cpp index 8e6331c4..b4ccc731 100644 --- a/lib/backupclient/BackupStoreObjectDump.cpp +++ b/lib/backupclient/BackupStoreObjectDump.cpp @@ -96,18 +96,18 @@ void BackupStoreDirectory::Dump(void *clibFileHandle, bool ToTrace) int depends_l = 0; if((*i)->GetDependsNewer() != 0) { -#ifdef WIN32 +#ifdef _MSC_VER depends_l += ::sprintf(depends + depends_l, " depNew(%I64x)", (*i)->GetDependsNewer()); #else - depends_l += ::sprintf(depends + depends_l, " depNew(%llx)", (*i)->GetDependsNewer()); + depends_l += ::sprintf(depends + depends_l, " depNew(%llx)", (long long)((*i)->GetDependsNewer())); #endif } if((*i)->GetDependsOlder() != 0) { -#ifdef WIN32 +#ifdef _MSC_VER depends_l += ::sprintf(depends + depends_l, " depOld(%I64x)", (*i)->GetDependsOlder()); #else - depends_l += ::sprintf(depends + depends_l, " depOld(%llx)", (*i)->GetDependsOlder()); + depends_l += ::sprintf(depends + depends_l, " depOld(%llx)", (long long)((*i)->GetDependsOlder())); #endif } |