From d75168ca03cec27c2b9f67732a1035b5c84fcd4f Mon Sep 17 00:00:00 2001 From: Anthony Birkett Date: Thu, 21 Jan 2016 15:22:05 +0000 Subject: Fix running as a service. Two problems identified, both traced to commit 4315a11 (main.cpp) ParseArguments() was no longer being called before checking cRoot::m_RunAsService. This led to m_RunAsService never being set (we use -d on the command line to instigate a service start). (Root.cpp) Terminate events were being ignored when running as a service. We only need to ignore the cin.good() call, not terminate events as a whole. --- src/Root.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/Root.cpp') diff --git a/src/Root.cpp b/src/Root.cpp index 71d5875a6..2465cdfd4 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -92,7 +92,8 @@ void cRoot::InputThread(cRoot & a_Params) } // We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running - if (!std::cin.good()) + // Ignore this when running as a service, cin was never opened in that case + if (!std::cin.good() && !m_RunAsService) { // Stop the server: a_Params.QueueExecuteConsoleCommand("stop"); @@ -232,15 +233,7 @@ void cRoot::Start(std::unique_ptr a_OverridesRepo) { m_StopEvent.Wait(); - if (m_TerminateEventRaised && m_RunAsService) - { - // Dont kill if running as a service - m_TerminateEventRaised = false; - } - else - { - break; - } + break; } // Stop the server: -- cgit v1.2.3