[Box Backup-commit] COMMIT r1167 - box/chris/merge/bin/bbstored

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Mon, 13 Nov 2006 19:52:05 +0000


Author: chris
Date: 2006-11-13 19:52:05 +0000 (Mon, 13 Nov 2006)
New Revision: 1167

Modified:
   box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp
Log:
Revert [1096] as it causes infinite loops if the listening socket 
can't be opened (refs #3)


Modified: box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp	2006-11-13 16:19:59 UTC (rev 1166)
+++ box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp	2006-11-13 19:52:05 UTC (rev 1167)
@@ -227,38 +227,13 @@
 	else
 	{
 		// In server process -- use the base class to do the magic
-		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;
-		}
-
+		ServerTLS<BOX_PORT_BBSTORED>::Run();
+		
 		// 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);
@@ -266,17 +241,49 @@
 	}
 }
 
-
 // --------------------------------------------------------------------------
 //
 // Function
 //		Name:    BackupStoreDaemon::Connection(SocketStreamTLS &)
-//		Purpose: Handles a connection
+//		Purpose: Handles a connection, by catching exceptions and
+//			 delegating to Connection2
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
 void BackupStoreDaemon::Connection(SocketStreamTLS &rStream)
 {
+	try
+	{
+		Connection2(rStream);
+	}
+	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());
+	}
+}
+	
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    BackupStoreDaemon::Connection2(SocketStreamTLS &)
+//		Purpose: Handles a connection from bbackupd
+//		Created: 2006/11/12
+//
+// --------------------------------------------------------------------------
+void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream)
+{
 	// Get the common name from the certificate
 	std::string clientCommonName(rStream.GetPeerCommonName());