[Box Backup-commit] COMMIT r1481 - box/chris/merge/bin/bbackupd

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sat, 24 Mar 2007 23:12:20 +0000


Author: chris
Date: 2007-03-24 23:12:20 +0000 (Sat, 24 Mar 2007)
New Revision: 1481

Modified:
   box/chris/merge/bin/bbackupd/BackupDaemon.cpp
Log:
iUse our new ClientException codes for clock skew and archive problems.
(refs #3, merges part of [1459])


Modified: box/chris/merge/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2007-03-24 23:07:13 UTC (rev 1480)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2007-03-24 23:12:20 UTC (rev 1481)
@@ -74,6 +74,7 @@
 #include "Archive.h"
 #include "Timer.h"
 #include "Logging.h"
+#include "autogen_ClientException.h"
 
 #include "MemLeakFindOn.h"
 
@@ -642,7 +643,19 @@
 			
 			// Calculate the sync period of files to examine
 			box_time_t syncPeriodStart = lastSyncTime;
-			box_time_t syncPeriodEnd = currentSyncStartTime - minimumFileAge;
+			box_time_t syncPeriodEnd = currentSyncStartTime - 
+				minimumFileAge;
+
+			if(syncPeriodStart >= syncPeriodEnd)
+			{
+				BOX_ERROR("Invalid (negative) sync period: "
+					"perhaps your clock is going "
+					"backwards (" << syncPeriodStart <<
+					" to " << syncPeriodEnd << ")");
+				THROW_EXCEPTION(ClientException,
+					ClockWentBackwards);
+			}
+
 			// Check logic
 			ASSERT(syncPeriodEnd > syncPeriodStart);
 			// Paranoid check on sync times
@@ -669,10 +682,8 @@
 				BOX_ERROR("Failed to delete the "
 					"StoreObjectInfoFile, backup cannot "
 					"continue safely.");
-				// prevent runaway process where the logs fill up -- without this
-				// the log message will be emitted in a tight loop.
-				::sleep(60); 
-				continue;
+				THROW_EXCEPTION(ClientException, 
+					FailedToDeleteStoreObjectInfoFile);
 			}
 
 			// In case the backup throws an exception,
@@ -836,6 +847,7 @@
 				BOX_ERROR("Internal error during "
 					"backup run: " << e.what());
 				errorOccurred = true;
+				errorString = e.what();
 			}
 			catch(...)
 			{
@@ -2215,7 +2227,7 @@
 	else
 	{
 		// there is something going on here
-		THROW_EXCEPTION(CommonException, Internal)
+		THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);
 	}
 
 	//
@@ -2240,7 +2252,7 @@
 	else
 	{
 		// there is something going on here
-		THROW_EXCEPTION(CommonException, Internal)
+		THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);
 	}
 
 	//
@@ -2265,7 +2277,7 @@
 	else
 	{
 		// there is something going on here
-		THROW_EXCEPTION(CommonException, Internal)
+		THROW_EXCEPTION(ClientException, CorruptStoreObjectInfoFile);
 	}
 }