[Box Backup-commit] COMMIT r1813 - box/chris/general/bin/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Sep 6 23:39:18 BST 2007


Author: chris
Date: 2007-09-06 23:39:18 +0100 (Thu, 06 Sep 2007)
New Revision: 1813

Modified:
   box/chris/general/bin/bbackupd/Win32BackupService.cpp
   box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp
   box/chris/general/bin/bbackupd/Win32ServiceFunctions.h
   box/chris/general/bin/bbackupd/bbackupd.cpp
Log:
Don't initialise MemLeakFinder twice when running as a service.

Return a non-zero exit code if running as a service fails.


Modified: box/chris/general/bin/bbackupd/Win32BackupService.cpp
===================================================================
--- box/chris/general/bin/bbackupd/Win32BackupService.cpp	2007-09-06 22:37:38 UTC (rev 1812)
+++ box/chris/general/bin/bbackupd/Win32BackupService.cpp	2007-09-06 22:39:18 UTC (rev 1813)
@@ -31,12 +31,6 @@
 {
 	DWORD ret;
 
-	// keep MAINHELPER_START happy
-	int argc = 0;
-	char* argv[] = {NULL};
-
-	MAINHELPER_START
-
 	if (pConfigFileName != NULL)
 	{
 		ret = this->Main(pConfigFileName);
@@ -46,8 +40,6 @@
 		ret = this->Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE);
 	}
 
-	MAINHELPER_END
-
 	return ret;
 }
 

Modified: box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp
===================================================================
--- box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp	2007-09-06 22:37:38 UTC (rev 1812)
+++ box/chris/general/bin/bbackupd/Win32ServiceFunctions.cpp	2007-09-06 22:39:18 UTC (rev 1813)
@@ -161,7 +161,7 @@
 	}
 }
 
-void OurService(char* pConfigFileName)
+int OurService(char* pConfigFileName)
 {
 	spConfigFileName = pConfigFileName;
 
@@ -180,7 +180,10 @@
 		ErrorHandler("Failed to start service. Did you start "
 			"Box Backup from the Service Control Manager? "
 			"(StartServiceCtrlDispatcher)", GetLastError());
+		return 1;
 	}
+
+	return 0;
 }
 
 int InstallService(const char* pConfigFileName)

Modified: box/chris/general/bin/bbackupd/Win32ServiceFunctions.h
===================================================================
--- box/chris/general/bin/bbackupd/Win32ServiceFunctions.h	2007-09-06 22:37:38 UTC (rev 1812)
+++ box/chris/general/bin/bbackupd/Win32ServiceFunctions.h	2007-09-06 22:39:18 UTC (rev 1813)
@@ -12,8 +12,8 @@
 #ifndef WIN32SERVICEFUNCTIONS_H
 #define WIN32SERVICEFUNCTIONS_H
 
-int  RemoveService  (void);
-int  InstallService (const char* pConfigFilePath);
-void OurService     (char* pConfigFileName);
+int RemoveService  (void);
+int InstallService (const char* pConfigFilePath);
+int OurService     (char* pConfigFileName);
 
 #endif

Modified: box/chris/general/bin/bbackupd/bbackupd.cpp
===================================================================
--- box/chris/general/bin/bbackupd/bbackupd.cpp	2007-09-06 22:37:38 UTC (rev 1812)
+++ box/chris/general/bin/bbackupd/bbackupd.cpp	2007-09-06 22:39:18 UTC (rev 1813)
@@ -25,6 +25,8 @@
 
 int main(int argc, const char *argv[])
 {
+	int ExitCode = 0;
+
 	MAINHELPER_START
 
 	Logging::SetProgramName("Box Backup (bbackupd)");
@@ -65,8 +67,6 @@
 
 	EnableBackupRights();
 
-	int ExitCode = 0;
-
 	if (runAsWin32Service)
 	{
 		BOX_INFO("Box Backup service starting");
@@ -77,7 +77,7 @@
 			config = strdup(argv[2]);
 		}
 
-		OurService(config);
+		ExitCode = OurService(config);
 
 		if (config)
 		{
@@ -94,14 +94,14 @@
 
 	delete gpDaemonService;
 
-	return ExitCode;
-
 #else // !WIN32
 
 	BackupDaemon daemon;
-	return daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
+	ExitCode = daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
 
 #endif // WIN32
 
 	MAINHELPER_END
+
+	return ExitCode;
 }




More information about the Boxbackup-commit mailing list