diff options
author | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-20 08:20:33 +0000 |
---|---|---|
committer | Martin Ebourne <martin@ebourne.me.uk> | 2005-12-20 08:20:33 +0000 |
commit | 8c4be43948dbe9a3bafd9d2fa8f350cb3359828e (patch) | |
tree | fc06a296bb9622bd5da7adad52e94d900aa48809 /bin | |
parent | ee95f5d73a7f2ca50d38dea6e862a6c683dfc8cc (diff) |
Rationalise type usage for time values. Now:
Box time is always box_time_t
seconds is time_t
microseconds is uint64_t
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbackupd/BackupClientContext.cpp | 2 | ||||
-rw-r--r-- | bin/bbackupd/BackupDaemon.cpp | 21 | ||||
-rw-r--r-- | bin/bbackupquery/BackupQueries.cpp | 2 | ||||
-rw-r--r-- | bin/bbstored/BBStoreDHousekeeping.cpp | 4 |
4 files changed, 15 insertions, 14 deletions
diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index 50f2cd08..38d0b98c 100644 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -201,7 +201,7 @@ void BackupClientContext::CloseAnyOpenConnection() if(mClientStoreMarker == ClientStoreMarker_NotKnown) { // Yes, choose one, the current time will do - int64_t marker = GetCurrentBoxTime(); + box_time_t marker = GetCurrentBoxTime(); // Set it on the store mpConnection->QuerySetClientStoreMarker(marker); diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index c56aaa59..6c5422ca 100644 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -64,7 +64,7 @@ #include "MemLeakFindOn.h" -#define MAX_SLEEP_TIME ((unsigned int)1024) +static const time_t MAX_SLEEP_TIME = 1024; // Make the actual sync period have a little bit of extra time, up to a 64th of the main sync period. // This prevents repetative cycles of load on the server @@ -444,16 +444,16 @@ void BackupDaemon::Run2() // Setup various timings // How often to connect to the store (approximate) - box_time_t updateStoreInterval = SecondsToBoxTime((uint32_t)conf.GetKeyValueInt("UpdateStoreInterval")); + box_time_t updateStoreInterval = SecondsToBoxTime(conf.GetKeyValueInt("UpdateStoreInterval")); // But are we connecting automatically? bool automaticBackup = conf.GetKeyValueBool("AutomaticBackup"); // The minimum age a file needs to be before it will be considered for uploading - box_time_t minimumFileAge = SecondsToBoxTime((uint32_t)conf.GetKeyValueInt("MinimumFileAge")); + box_time_t minimumFileAge = SecondsToBoxTime(conf.GetKeyValueInt("MinimumFileAge")); // The maximum time we'll wait to upload a file, regardless of how often it's modified - box_time_t maxUploadWait = SecondsToBoxTime((uint32_t)conf.GetKeyValueInt("MaxUploadWait")); + box_time_t maxUploadWait = SecondsToBoxTime(conf.GetKeyValueInt("MaxUploadWait")); // Adjust by subtracting the minimum file age, so is relative to sync period end in comparisons maxUploadWait = (maxUploadWait > minimumFileAge)?(maxUploadWait - minimumFileAge):(0); @@ -492,7 +492,8 @@ void BackupDaemon::Run2() // Pause a while, but no more than MAX_SLEEP_TIME seconds (use the conditional because times are unsigned) box_time_t requiredDelay = (nextSyncTime < currentTime)?(0):(nextSyncTime - currentTime); // If there isn't automatic backup happening, set a long delay. And limit delays at the same time. - if(!automaticBackup || requiredDelay > SecondsToBoxTime((uint32_t)MAX_SLEEP_TIME)) requiredDelay = SecondsToBoxTime((uint32_t)MAX_SLEEP_TIME); + if(!automaticBackup || requiredDelay > SecondsToBoxTime(MAX_SLEEP_TIME)) + requiredDelay = SecondsToBoxTime(MAX_SLEEP_TIME); // Only do the delay if there is a delay required if(requiredDelay > 0) @@ -506,7 +507,7 @@ void BackupDaemon::Run2() else { // No command socket or connection, just do a normal sleep - int sleepSeconds = BoxTimeToSeconds(requiredDelay); + time_t sleepSeconds = BoxTimeToSeconds(requiredDelay); ::sleep((sleepSeconds <= 0)?1:sleepSeconds); } } @@ -528,7 +529,7 @@ void BackupDaemon::Run2() if(d > 0) { // Script has asked for a delay - nextSyncTime = GetCurrentBoxTime() + SecondsToBoxTime((uint32_t)d); + nextSyncTime = GetCurrentBoxTime() + SecondsToBoxTime(d); doSync = false; } } @@ -562,7 +563,7 @@ void BackupDaemon::Run2() // files which are modified after the scan run started. // Of course, they may be eligable to be synced again the next time round, // but this should be OK, because the changes only upload should upload no data. - syncPeriodEndExtended += SecondsToBoxTime((uint32_t)(356*24*3600)); + syncPeriodEndExtended += SecondsToBoxTime((time_t)(356*24*3600)); } // Do sync @@ -587,7 +588,7 @@ void BackupDaemon::Run2() params.mMaxUploadWait = maxUploadWait; params.mFileTrackingSizeThreshold = conf.GetKeyValueInt("FileTrackingSizeThreshold"); params.mDiffingUploadSizeThreshold = conf.GetKeyValueInt("DiffingUploadSizeThreshold"); - params.mMaxFileTimeInFuture = SecondsToBoxTime((uint32_t)conf.GetKeyValueInt("MaxFileTimeInFuture")); + params.mMaxFileTimeInFuture = SecondsToBoxTime(conf.GetKeyValueInt("MaxFileTimeInFuture")); // Set store marker clientContext.SetClientStoreMarker(clientStoreMarker); @@ -1397,7 +1398,7 @@ TRACE0("new location\n"); ASSERT(mUnusedRootDirEntries.size() > 0); // Time to delete them mDeleteUnusedRootDirEntriesAfter = - GetCurrentBoxTime() + SecondsToBoxTime((uint32_t)BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER); + GetCurrentBoxTime() + SecondsToBoxTime(BACKUP_DELETE_UNUSED_ROOT_ENTRIES_AFTER); } } diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index b37abc9d..02b60aa3 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -956,7 +956,7 @@ void BackupQueries::CommandCompare(const std::vector<std::string> &args, const b { // Files modified after this time shouldn't be on the server, so report errors slightly differently params.mLatestFileUploadTime = FileModificationTime(st) - - SecondsToBoxTime((uint32_t)mrConfiguration.GetKeyValueInt("MinimumFileAge")); + - SecondsToBoxTime(mrConfiguration.GetKeyValueInt("MinimumFileAge")); } else { diff --git a/bin/bbstored/BBStoreDHousekeeping.cpp b/bin/bbstored/BBStoreDHousekeeping.cpp index 2eb19089..d3656630 100644 --- a/bin/bbstored/BBStoreDHousekeeping.cpp +++ b/bin/bbstored/BBStoreDHousekeeping.cpp @@ -33,7 +33,7 @@ void BackupStoreDaemon::HousekeepingProcess() { // Get the time between housekeeping runs const Configuration &rconfig(GetConfiguration()); - int64_t housekeepingInterval = SecondsToBoxTime((uint32_t)rconfig.GetKeyValueInt("TimeBetweenHousekeeping")); + int64_t housekeepingInterval = SecondsToBoxTime(rconfig.GetKeyValueInt("TimeBetweenHousekeeping")); int64_t lastHousekeepingRun = 0; @@ -108,7 +108,7 @@ void BackupStoreDaemon::HousekeepingProcess() // Calculate how long should wait before doing the next housekeeping run timeNow = GetCurrentBoxTime(); - int64_t secondsToGo = BoxTimeToSeconds((lastHousekeepingRun + housekeepingInterval) - timeNow); + time_t secondsToGo = BoxTimeToSeconds((lastHousekeepingRun + housekeepingInterval) - timeNow); if(secondsToGo < 1) secondsToGo = 1; if(secondsToGo > 60) secondsToGo = 60; int32_t millisecondsToGo = ((int)secondsToGo) * 1000; |