aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CommandHandler.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-09 16:47:04 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-09 17:44:11 +0100
commitd0613b56cea7eba0604e0548bddffd773a4eb554 (patch)
tree18e5a28c346018340910c456eedd56717ab01c9c /src/profiling/CommandHandler.cpp
parent09ca49cdcfbe377da979a19df9bcdb7cbffc7b50 (diff)
downloadarmnn-d0613b56cea7eba0604e0548bddffd773a4eb554.tar.gz
IVGCVSW-3937 Improve the Connection Acknowledged Handler
* The Connection Acknowledged Handler should report an error is it's called while in a wrong state * Stopping the threads in the ProfilingService before having to start them again * Updated the unit tests to check the changes * Removed unnecessary Packet.cpp file * Fixed memory leak Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I8c4d33b4d97994df86fe6c9f8c659f880ec64c16
Diffstat (limited to 'src/profiling/CommandHandler.cpp')
-rw-r--r--src/profiling/CommandHandler.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp
index 86fa2571df..cc68dcf74d 100644
--- a/src/profiling/CommandHandler.cpp
+++ b/src/profiling/CommandHandler.cpp
@@ -5,6 +5,8 @@
#include "CommandHandler.hpp"
+#include <boost/log/trivial.hpp>
+
namespace armnn
{
@@ -39,7 +41,14 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
{
try
{
- Packet packet = profilingConnection.ReadPacket(m_Timeout);
+ Packet packet = profilingConnection.ReadPacket(m_Timeout.load());
+
+ if (packet.IsEmpty())
+ {
+ // Nothing to do, continue
+ continue;
+ }
+
Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketId());
CommandHandlerFunctor* commandHandlerFunctor =
@@ -49,19 +58,15 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection)
}
catch (const armnn::TimeoutException&)
{
- if (m_StopAfterTimeout)
+ if (m_StopAfterTimeout.load())
{
- m_KeepRunning.store(false, std::memory_order_relaxed);
+ m_KeepRunning.store(false);
}
}
catch (const Exception& e)
{
- // Log the error
- BOOST_LOG_TRIVIAL(warning) << "An error has occurred when handling a command: "
- << e.what();
-
- // Might want to differentiate the errors more
- m_KeepRunning.store(false);
+ // Log the error and continue
+ BOOST_LOG_TRIVIAL(warning) << "An error has occurred when handling a command: " << e.what() << std::endl;
}
}
while (m_KeepRunning.load());