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

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Mar 3 21:47:28 GMT 2007


Author: chris
Date: 2007-03-03 21:47:28 +0000 (Sat, 03 Mar 2007)
New Revision: 1322

Modified:
   box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
   box/chris/general/bin/bbstored/BackupStoreDaemon.h
Log:
Avoid infinite loops if we can't bind socket, or something else goes wrong
and throws an exception before the server starts accepting connections
(from chris/merge)


Modified: box/chris/general/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2007-03-03 21:46:01 UTC (rev 1321)
+++ box/chris/general/bin/bbstored/BackupStoreDaemon.cpp	2007-03-03 21:47:28 UTC (rev 1322)
@@ -228,26 +228,7 @@
 	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());
-		}
+		ServerTLS<BOX_PORT_BBSTORED>::Run();
 
 		if (!mInterProcessCommsSocket.IsOpened())
 		{
@@ -267,17 +248,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());
 	

Modified: box/chris/general/bin/bbstored/BackupStoreDaemon.h
===================================================================
--- box/chris/general/bin/bbstored/BackupStoreDaemon.h	2007-03-03 21:46:01 UTC (rev 1321)
+++ box/chris/general/bin/bbstored/BackupStoreDaemon.h	2007-03-03 21:47:28 UTC (rev 1322)
@@ -52,7 +52,8 @@
 
 	virtual void Run();
 
-	void Connection(SocketStreamTLS &rStream);
+	virtual void Connection(SocketStreamTLS &rStream);
+	void Connection2(SocketStreamTLS &rStream);
 	
 	virtual const char *DaemonName() const;
 	virtual const char *DaemonBanner() const;




More information about the Boxbackup-commit mailing list