summaryrefslogtreecommitdiffstats
path: root/src/Root.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Root.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index dbea1fd9e..9ccb18729 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Root.h"
+#include "main.h"
// STD lib hreaders:
#include <iostream>
@@ -49,8 +50,18 @@
-extern bool g_RunAsService;
-cRoot * cRoot::s_Root = nullptr;
+#ifdef __clang__
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wglobal-constructors"
+#endif
+
+decltype(cRoot::s_Root) cRoot::s_Root;
+decltype(cRoot::s_NextState) cRoot::s_NextState;
+decltype(cRoot::s_StopEvent) cRoot::s_StopEvent;
+
+#ifdef __clang__
+ #pragma clang diagnostic pop
+#endif
@@ -196,7 +207,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
m_StartTime = std::chrono::steady_clock::now();
HandleInput();
- m_StopEvent.Wait();
+ s_StopEvent.Wait();
// Stop the server:
m_WebAdmin->Stop();
@@ -235,7 +246,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
LOG("Shutdown successful!");
LOG("--- Stopped Log ---");
- return m_NextState == NextState::Restart;
+ return s_NextState == NextState::Restart;
}
@@ -959,7 +970,7 @@ void cRoot::HandleInput()
cLogCommandOutputCallback Output;
AString Command;
- while (m_NextState == NextState::Run)
+ while (s_NextState == NextState::Run)
{
#ifndef _WIN32
timeval Timeout{ 0, 0 };
@@ -982,7 +993,7 @@ void cRoot::HandleInput()
return;
}
- if (m_NextState != NextState::Run)
+ if (s_NextState != NextState::Run)
{
// Already shutting down, can't execute commands
break;
@@ -1003,7 +1014,7 @@ void cRoot::HandleInput()
void cRoot::TransitionNextState(NextState a_NextState)
{
{
- auto Current = m_NextState.load();
+ auto Current = s_NextState.load();
do
{
// Stopping is final, so stops override restarts:
@@ -1012,15 +1023,15 @@ void cRoot::TransitionNextState(NextState a_NextState)
return;
}
}
- while (!m_NextState.compare_exchange_strong(Current, a_NextState));
+ while (!s_NextState.compare_exchange_strong(Current, a_NextState));
}
- if (m_NextState == NextState::Run)
+ if (s_NextState == NextState::Run)
{
return;
}
- m_StopEvent.Set();
+ s_StopEvent.Set();
#ifdef WIN32