aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/profiling/CommandHandler.cpp')
-rw-r--r--src/profiling/CommandHandler.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp
index cc68dcf74d..b0603b0ed5 100644
--- a/src/profiling/CommandHandler.cpp
+++ b/src/profiling/CommandHandler.cpp
@@ -4,6 +4,7 @@
//
#include "CommandHandler.hpp"
+#include "ProfilingService.hpp"
#include <boost/log/trivial.hpp>
@@ -20,6 +21,11 @@ void CommandHandler::Start(IProfilingConnection& profilingConnection)
return;
}
+ if (m_CommandThread.joinable())
+ {
+ m_CommandThread.join();
+ }
+
m_IsRunning.store(true);
m_KeepRunning.store(true);
m_CommandThread = std::thread(&CommandHandler::HandleCommands, this, std::ref(profilingConnection));
@@ -67,6 +73,14 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
{
// Log the error and continue
BOOST_LOG_TRIVIAL(warning) << "An error has occurred when handling a command: " << e.what() << std::endl;
+ // Did we get here because the socket failed?
+ if ( !profilingConnection.IsOpen() )
+ {
+ // We're going to stop processing commands.
+ // This will leave the thread idle. There is no mechanism to restart the profiling service when the
+ // connection is lost.
+ m_KeepRunning.store(false);
+ }
}
}
while (m_KeepRunning.load());