[Box Backup-commit] COMMIT r1824 - box/chris/merge/bin/bbackupd
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Fri, 07 Sep 2007 22:55:08 +0100
Author: chris
Date: 2007-09-07 22:55:07 +0100 (Fri, 07 Sep 2007)
New Revision: 1824
Modified:
box/chris/merge/bin/bbackupd/Win32BackupService.cpp
box/chris/merge/bin/bbackupd/Win32ServiceFunctions.cpp
box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h
box/chris/merge/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.
(merges [1813])
Modified: box/chris/merge/bin/bbackupd/Win32BackupService.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/Win32BackupService.cpp 2007-09-07 21:54:33 UTC (rev 1823)
+++ box/chris/merge/bin/bbackupd/Win32BackupService.cpp 2007-09-07 21:55:07 UTC (rev 1824)
@@ -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/merge/bin/bbackupd/Win32ServiceFunctions.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/Win32ServiceFunctions.cpp 2007-09-07 21:54:33 UTC (rev 1823)
+++ box/chris/merge/bin/bbackupd/Win32ServiceFunctions.cpp 2007-09-07 21:55:07 UTC (rev 1824)
@@ -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/merge/bin/bbackupd/Win32ServiceFunctions.h
===================================================================
--- box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h 2007-09-07 21:54:33 UTC (rev 1823)
+++ box/chris/merge/bin/bbackupd/Win32ServiceFunctions.h 2007-09-07 21:55:07 UTC (rev 1824)
@@ -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/merge/bin/bbackupd/bbackupd.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/bbackupd.cpp 2007-09-07 21:54:33 UTC (rev 1823)
+++ box/chris/merge/bin/bbackupd/bbackupd.cpp 2007-09-07 21:55:07 UTC (rev 1824)
@@ -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;
}