[Box Backup-dev] COMMIT r547 - box/trunk/bin/bbackupd

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sun, 19 Mar 2006 10:08:57 +0000 (GMT)


Author: ben
Date: 2006-03-19 10:08:56 +0000 (Sun, 19 Mar 2006)
New Revision: 547

Modified:
   box/trunk/bin/bbackupd/BackupDaemon.cpp
Log:
Prevent runaway behaviour when the StoreObjectInfo file doesn't exist when it's expected to exist. Not a fix to the underlying problem.

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2006-03-14 06:08:20 UTC (rev 546)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2006-03-19 10:08:56 UTC (rev 547)
@@ -616,6 +616,9 @@
 				::syslog(LOG_ERR, "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;
 			}
 			
@@ -2417,14 +2420,25 @@
 		return false;
 	}
 
-	std::string StoreObjectInfoFile = 
-		GetConfiguration().GetKeyValue("StoreObjectInfoFile");
+	std::string storeObjectInfoFile(GetConfiguration().GetKeyValue("StoreObjectInfoFile"));
 
-	if (::unlink(StoreObjectInfoFile.c_str()) != 0)
+	// Check to see if the file exists
+	if(!FileExists(storeObjectInfoFile.c_str()))
 	{
+		// File doesn't exist -- so can't be deleted. But something isn't quite right, so log a message
+		::syslog(LOG_ERR, "Expected to be able to delete "
+			"store object info file '%s', but the file did not exist.",
+			storeObjectInfoFile.c_str());
+		// Return true to stop things going around in a loop
+		return true;
+	}
+
+	// Actually delete it
+	if(::unlink(storeObjectInfoFile.c_str()) != 0)
+	{
 		::syslog(LOG_ERR, "Failed to delete the old "
 			"store object info file '%s': %s",
-			StoreObjectInfoFile.c_str(), strerror(errno));
+			storeObjectInfoFile.c_str(), strerror(errno));
 		return false;
 	}