[Box Backup-commit] COMMIT r1068 - box/chris/general/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Mon Oct 16 00:05:17 BST 2006


Author: chris
Date: 2006-10-16 00:05:17 +0100 (Mon, 16 Oct 2006)
New Revision: 1068

Modified:
   box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
Log:
Win32 compile fix.

Don't allow exceptions thrown in the child to kill the whole server.


Modified: box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2006-10-15 23:04:37 UTC (rev 1067)
+++ box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2006-10-15 23:05:17 UTC (rev 1068)
@@ -41,8 +41,8 @@
 	  mpAccounts(0),
 	  mExtendedLogging(false),
 	  mHaveForkedHousekeeping(false),
+	  mIsHousekeepingProcess(false),
 	  mHousekeepingInited(false),
-	  mIsHousekeepingProcess(false),
 	  mInterProcessComms(mInterProcessCommsSocket)
 {
 }
@@ -162,11 +162,9 @@
 	
 #ifdef WIN32	
 	// Housekeeping runs synchronously on Win32
-	if(false)
 #else
 	// Fork off housekeeping daemon -- must only do this the first time Run() is called
 	if(!mHaveForkedHousekeeping)
-#endif
 	{
 		// Open a socket pair for communication
 		int sv[2] = {-1,-1};
@@ -220,6 +218,7 @@
 			THROW_EXCEPTION(ServerException, SocketCloseError)
 		}
 	}
+#endif // WIN32
 
 	if(mIsHousekeepingProcess)
 	{
@@ -229,13 +228,38 @@
 	else
 	{
 		// In server process -- use the base class to do the magic
-		ServerTLS<BOX_PORT_BBSTORED>::Run();
-		
+		try
+		{
+			ServerTLS<BOX_PORT_BBSTORED>::Run();
+		}
+		catch(BoxException &e)
+		{
+			::syslog(LOG_ERR, "%s: disconnecting due to "
+				"exception %s (%d/%d)", DaemonName(), 
+				e.what(), e.GetType(), e.GetSubType());
+		}
+		catch(std::exception &e)
+		{
+			::syslog(LOG_ERR, "%s: disconnecting due to "
+				"exception %s", DaemonName(), e.what());
+		}
+		catch(...)
+		{
+			::syslog(LOG_ERR, "%s: disconnecting due to "
+				"unknown exception", DaemonName());
+		}
+
+		if (!mInterProcessCommsSocket.IsOpened())
+		{
+			return;
+		}
+
 		// Why did it stop? Tell the housekeeping process to do the same
 		if(IsReloadConfigWanted())
 		{
 			mInterProcessCommsSocket.Write("h\n", 2);
 		}
+
 		if(IsTerminateWanted())
 		{
 			mInterProcessCommsSocket.Write("t\n", 2);




More information about the Boxbackup-commit mailing list