[Box Backup-dev] COMMIT r250 - in box/trunk: bin/bbackupd bin/bbackupquery bin/bbstored lib/common test/bbackupd
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Tue Dec 20 08:20:35 GMT 2005
Author: martin
Date: 2005-12-20 08:20:33 +0000 (Tue, 20 Dec 2005)
New Revision: 250
Modified:
box/trunk/bin/bbackupd/BackupClientContext.cpp
box/trunk/bin/bbackupd/BackupDaemon.cpp
box/trunk/bin/bbackupquery/BackupQueries.cpp
box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
box/trunk/lib/common/BoxTime.cpp
box/trunk/lib/common/BoxTime.h
box/trunk/lib/common/BoxTimeToText.cpp
box/trunk/test/bbackupd/testbbackupd.cpp
Log:
Rationalise type usage for time values. Now:
Box time is always box_time_t
seconds is time_t
microseconds is uint64_t
Modified: box/trunk/bin/bbackupd/BackupClientContext.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientContext.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/bin/bbackupd/BackupClientContext.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -201,7 +201,7 @@
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);
Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -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 @@
// 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 @@
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
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);
}
}
Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -956,7 +956,7 @@
{
// 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
{
Modified: box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
===================================================================
--- box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -33,7 +33,7 @@
{
// 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 @@
// 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;
Modified: box/trunk/lib/common/BoxTime.cpp
===================================================================
--- box/trunk/lib/common/BoxTime.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/lib/common/BoxTime.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -25,8 +25,7 @@
// --------------------------------------------------------------------------
box_time_t GetCurrentBoxTime()
{
- ASSERT(sizeof(uint32_t) == sizeof(time_t));
- return SecondsToBoxTime((uint32_t)time(0));
+ return SecondsToBoxTime(time(0));
}
Modified: box/trunk/lib/common/BoxTime.h
===================================================================
--- box/trunk/lib/common/BoxTime.h 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/lib/common/BoxTime.h 2005-12-20 08:20:33 UTC (rev 250)
@@ -23,19 +23,15 @@
box_time_t GetCurrentBoxTime();
-inline box_time_t SecondsToBoxTime(uint32_t Seconds)
+inline box_time_t SecondsToBoxTime(time_t Seconds)
{
return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
}
-inline box_time_t SecondsToBoxTime(uint64_t Seconds)
+inline time_t BoxTimeToSeconds(box_time_t Time)
{
- return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
-}
-inline box_time_t BoxTimeToSeconds(box_time_t Time)
-{
return Time / MICRO_SEC_IN_SEC_LL;
}
-inline box_time_t BoxTimeToMilliSeconds(box_time_t Time)
+inline uint64_t BoxTimeToMilliSeconds(box_time_t Time)
{
return Time / MILLI_SEC_IN_NANO_SEC_LL;
}
Modified: box/trunk/lib/common/BoxTimeToText.cpp
===================================================================
--- box/trunk/lib/common/BoxTimeToText.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/lib/common/BoxTimeToText.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -29,7 +29,7 @@
{
#ifdef WIN32
struct tm *time;
- box_time_t bob = BoxTimeToSeconds(Time);
+ time_t bob = BoxTimeToSeconds(Time);
__time64_t winTime = bob;
@@ -46,7 +46,7 @@
time->tm_mon + 1, time->tm_mday, time->tm_hour,
time->tm_min, time->tm_sec);
#else // ! WIN32
- time_t timeInSecs = (time_t)BoxTimeToSeconds(Time);
+ time_t timeInSecs = BoxTimeToSeconds(Time);
struct tm time;
gmtime_r(&timeInSecs, &time);
Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp 2005-12-20 08:15:28 UTC (rev 249)
+++ box/trunk/test/bbackupd/testbbackupd.cpp 2005-12-20 08:20:33 UTC (rev 250)
@@ -452,7 +452,7 @@
fclose(f);
// and then move the time backwards!
struct timeval times[2];
- BoxTimeToTimeval(SecondsToBoxTime((uint32_t)(365*24*60*60)), times[1]);
+ BoxTimeToTimeval(SecondsToBoxTime((time_t)(365*24*60*60)), times[1]);
times[0] = times[1];
TEST_THAT(::utimes("testfiles/TestDir1/sub23/rand.h", times) == 0);
}
@@ -646,7 +646,7 @@
fclose(f);
// and then move the time forwards!
struct timeval times[2];
- BoxTimeToTimeval(GetCurrentBoxTime() + SecondsToBoxTime((uint32_t)(365*24*60*60)), times[1]);
+ BoxTimeToTimeval(GetCurrentBoxTime() + SecondsToBoxTime((time_t)(365*24*60*60)), times[1]);
times[0] = times[1];
TEST_THAT(::utimes("testfiles/TestDir1/sub23/in-the-future", times) == 0);
}
More information about the Boxbackup-dev
mailing list