aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandHandler.cpp
diff options
context:
space:
mode:
authorColm Donelan <Colm.Donelan@arm.com>2019-10-17 14:02:44 +0100
committerJim Flynn Arm <jim.flynn@arm.com>2019-10-17 17:03:36 +0000
commit9ea7700bde128f2601d5b7d8849e96c0a08e15c6 (patch)
treeaf95b791cefe0fa55aa04bc7d578f47cbe9dc54f /src/profiling/CommandHandler.cpp
parentb682d840bb0b4cc34f4febb69c2385feec880ae1 (diff)
downloadarmnn-9ea7700bde128f2601d5b7d8849e96c0a08e15c6.tar.gz
IVGCVSW-3409 Create the ProfilingService class
* Improve the error handling in SocketProfilingConnection to close the socket when an error has been detected. * Update the CommandHandler thread to handle a closed socket. Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Change-Id: I1577c8d7d57a7af9bde98c2dec12cb19a3afb21d
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());