[Box Backup-dev] COMMIT r860 - box/chris/merge/bin/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Aug 31 09:51:45 BST 2006


Author: chris
Date: 2006-08-31 09:51:44 +0100 (Thu, 31 Aug 2006)
New Revision: 860

Modified:
   box/chris/merge/bin/bbackupd/BackupDaemon.cpp
Log:
* bin/bbackupd/BackupDaemon.cpp
- Reinstate missing mReceivedCommandConn
- Clean up exception handling


Modified: box/chris/merge/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2006-08-31 08:49:52 UTC (rev 859)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2006-08-31 08:51:44 UTC (rev 860)
@@ -262,6 +262,7 @@
 #ifdef WIN32
 void BackupDaemon::RunHelperThread(void)
 {
+	this->mReceivedCommandConn = false;
 	mpCommandSocketInfo = new CommandSocketInfo;
 	WinNamedPipeStream& rSocket(mpCommandSocketInfo->mListeningSocket);
 
@@ -472,7 +473,7 @@
 			}
 			catch(std::exception &e)
 			{
-				::syslog(LOG_ERR, "Internal error while "
+				::syslog(LOG_WARNING, "Internal error while "
 					"closing command socket after "
 					"another exception: %s", e.what());
 			}
@@ -939,34 +940,26 @@
 			}
 		}
 		
-		// Wait and then cleanup child process
-		int status = 0;
-		::waitpid(pid, &status, 0);
 	}
 	catch(std::exception &e)
 	{
 		::syslog(LOG_ERR, "Internal error running SyncAllowScript: "
 			"%s", e.what());
-		// Clean up
-		if(pid != 0)
-		{
-			int status = 0;
-			::waitpid(pid, &status, 0);
-		}
 	}
 	catch(...)
 	{
 		// Ignore any exceptions
 		// Log that something bad happened
 		::syslog(LOG_ERR, "Error running SyncAllowScript '%s'", conf.GetKeyValue("SyncAllowScript").c_str());
-		// Clean up though
-		if(pid != 0)
-		{
-			int status = 0;
-			::waitpid(pid, &status, 0);
-		}
 	}
 
+	// Wait and then cleanup child process, if any
+	if (pid != 0)
+	{
+		int status = 0;
+		::waitpid(pid, &status, 0);
+	}
+
 	return waitInSeconds;
 }
 
@@ -1164,7 +1157,17 @@
 	{
 		::syslog(LOG_ERR, "Internal error in command socket thread: "
 			"%s", e.what());
-		throw; // thread will die
+		// If an error occurs, and there is a connection active, just close that
+		// connection and continue. Otherwise, let the error propagate.
+		if(mpCommandSocketInfo->mpConnectedSocket.get() == 0)
+		{
+			throw; // thread will die
+		}
+		else
+		{
+			// Close socket and ignore error
+			CloseCommandConnection();
+		}
 	}
 	catch(...)
 	{
@@ -2345,10 +2348,16 @@
 		::syslog(LOG_INFO, "Saved store object info file '%s'", 
 			StoreObjectInfoFile.c_str());
 	}
+	catch(std::exception &e)
+	{
+		::syslog(LOG_ERR, "Internal error writing store object "
+			"info file (%s): %s",
+			StoreObjectInfoFile.c_str(), e.what());
+	}
 	catch(...)
 	{
-		::syslog(LOG_WARNING, "Requested store object info file '%s' "
-			"not accessible or could not be created", 
+		::syslog(LOG_ERR, "Internal error writing store object "
+			"info file (%s): unknown error",
 			StoreObjectInfoFile.c_str());
 	}
 
@@ -2504,12 +2513,14 @@
 	catch(std::exception &e)
 	{
 		::syslog(LOG_ERR, "Internal error reading store object "
-			"info file: %s", e.what());
+			"info file (%s): %s",
+			StoreObjectInfoFile.c_str(), e.what());
 	}
 	catch(...)
 	{
 		::syslog(LOG_ERR, "Internal error reading store object "
-			"info file: unknown error");
+			"info file (%s): unknown error",
+			StoreObjectInfoFile.c_str());
 	}
 
 	DeleteAllLocations();




More information about the Boxbackup-dev mailing list