summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-09-07 21:55:07 +0000
committerChris Wilson <chris+github@qwirx.com>2007-09-07 21:55:07 +0000
commit783e3baacc9e101c540fd2cb39e94c02d32f8e72 (patch)
tree5fb17f49e3d60ea7bcb449f1329ee04a1b5a0de1 /bin
parente2efafa787ffa1b45063551b6832a9590141dceb (diff)
Don't initialise MemLeakFinder twice when running as a service.
Return a non-zero exit code if running as a service fails. (merges [1813])
Diffstat (limited to 'bin')
-rw-r--r--bin/bbackupd/Win32BackupService.cpp8
-rw-r--r--bin/bbackupd/Win32ServiceFunctions.cpp5
-rw-r--r--bin/bbackupd/Win32ServiceFunctions.h6
-rw-r--r--bin/bbackupd/bbackupd.cpp12
4 files changed, 13 insertions, 18 deletions
diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp
index 1470b42d..9f0ac867 100644
--- a/bin/bbackupd/Win32BackupService.cpp
+++ b/bin/bbackupd/Win32BackupService.cpp
@@ -31,12 +31,6 @@ DWORD Win32BackupService::WinService(const char* pConfigFileName)
{
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 @@ DWORD Win32BackupService::WinService(const char* pConfigFileName)
ret = this->Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE);
}
- MAINHELPER_END
-
return ret;
}
diff --git a/bin/bbackupd/Win32ServiceFunctions.cpp b/bin/bbackupd/Win32ServiceFunctions.cpp
index f4c8894b..5acf5f67 100644
--- a/bin/bbackupd/Win32ServiceFunctions.cpp
+++ b/bin/bbackupd/Win32ServiceFunctions.cpp
@@ -161,7 +161,7 @@ VOID ServiceMain(DWORD argc, LPTSTR *argv)
}
}
-void OurService(char* pConfigFileName)
+int OurService(char* pConfigFileName)
{
spConfigFileName = pConfigFileName;
@@ -180,7 +180,10 @@ void OurService(char* pConfigFileName)
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)
diff --git a/bin/bbackupd/Win32ServiceFunctions.h b/bin/bbackupd/Win32ServiceFunctions.h
index 70e1f085..cecd5c7b 100644
--- a/bin/bbackupd/Win32ServiceFunctions.h
+++ b/bin/bbackupd/Win32ServiceFunctions.h
@@ -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
diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp
index b8c8f61a..e094d499 100644
--- a/bin/bbackupd/bbackupd.cpp
+++ b/bin/bbackupd/bbackupd.cpp
@@ -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 @@ int main(int argc, const char *argv[])
EnableBackupRights();
- int ExitCode = 0;
-
if (runAsWin32Service)
{
BOX_INFO("Box Backup service starting");
@@ -77,7 +77,7 @@ int main(int argc, const char *argv[])
config = strdup(argv[2]);
}
- OurService(config);
+ ExitCode = OurService(config);
if (config)
{
@@ -94,14 +94,14 @@ int main(int argc, const char *argv[])
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;
}