[Box Backup-commit] COMMIT r1204 - box/trunk/bin/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Dec 14 22:54:14 GMT 2006


Author: chris
Date: 2006-12-14 22:54:14 +0000 (Thu, 14 Dec 2006)
New Revision: 1204

Modified:
   box/trunk/bin/bbackupd/Win32BackupService.cpp
   box/trunk/bin/bbackupd/bbackupd.cpp
Log:

 * Replace global daemon object with a pointer, to allow deletion and 
   clean up reported memory leaks 
 * No need to initialise Winsock here, now that lib/server/Daemon does it 
   for us 
 * Initialise logging properly

(merges [1027]+[1031])


Modified: box/trunk/bin/bbackupd/Win32BackupService.cpp
===================================================================
--- box/trunk/bin/bbackupd/Win32BackupService.cpp	2006-12-14 22:46:21 UTC (rev 1203)
+++ box/trunk/bin/bbackupd/Win32BackupService.cpp	2006-12-14 22:54:14 UTC (rev 1204)
@@ -12,19 +12,19 @@
 
 #include "Win32BackupService.h"
 
-Win32BackupService gDaemonService;
+Win32BackupService* gpDaemonService = NULL;
 extern HANDLE gStopServiceEvent;
 
 unsigned int WINAPI RunService(LPVOID lpParameter)
 {
-	DWORD retVal = gDaemonService.WinService((const char*) lpParameter);
+	DWORD retVal = gpDaemonService->WinService((const char*) lpParameter);
 	SetEvent(gStopServiceEvent);
 	return retVal;
 }
 
 void TerminateService(void)
 {
-	gDaemonService.SetTerminateWanted();
+	gpDaemonService->SetTerminateWanted();
 }
 
 DWORD Win32BackupService::WinService(const char* pConfigFileName)

Modified: box/trunk/bin/bbackupd/bbackupd.cpp
===================================================================
--- box/trunk/bin/bbackupd/bbackupd.cpp	2006-12-14 22:46:21 UTC (rev 1203)
+++ box/trunk/bin/bbackupd/bbackupd.cpp	2006-12-14 22:54:14 UTC (rev 1204)
@@ -19,7 +19,7 @@
 	#include "Win32ServiceFunctions.h"
 	#include "Win32BackupService.h"
 
-	extern Win32BackupService gDaemonService;
+	extern Win32BackupService* gpDaemonService;
 #endif
 
 int main(int argc, const char *argv[])
@@ -28,7 +28,7 @@
 
 #ifdef WIN32
 
-	::openlog("Box Backup (bbackupd)", 0, 0);
+	::openlog("Box Backup (bbackupd)", LOG_PID, LOG_LOCAL6);
 
 	if(argc == 2 &&
 		(::strcmp(argv[1], "--help") == 0 ||
@@ -57,18 +57,8 @@
 	{
 		runAsWin32Service = true;
 	}
-	
-	// Under win32 we must initialise the Winsock library
-	// before using sockets
-		
-	WSADATA info;
 
-	if (WSAStartup(0x0101, &info) == SOCKET_ERROR) 
-	{
-		// box backup will not run without sockets
-		::syslog(LOG_ERR, "Failed to initialise Windows Sockets");
-		THROW_EXCEPTION(BackupStoreException, Internal)
-	}
+	gpDaemonService = new Win32BackupService();
 
 	EnableBackupRights();
 
@@ -95,15 +85,14 @@
 	}
 	else
 	{
-		ExitCode = gDaemonService.Main(
+		ExitCode = gpDaemonService->Main(
 			BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
 	}
 
-	// Clean up our sockets
-	WSACleanup();
-
 	::closelog();
 
+	delete gpDaemonService;
+
 	return ExitCode;
 
 #else // !WIN32




More information about the Boxbackup-commit mailing list