From bbfe603e5ae42317a2b67d713d00882bea341c88 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Mon, 20 Jul 2020 16:57:44 +0100 Subject: IVGCVSW-5166 Pull out the common and server side code into standalone libraries Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735 Signed-off-by: Jim Flynn --- src/profiling/CommandHandler.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/profiling/CommandHandler.cpp') diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp index cae7037327..9f536445e9 100644 --- a/src/profiling/CommandHandler.cpp +++ b/src/profiling/CommandHandler.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2019 Arm Ltd. All rights reserved. +// Copyright © 2019 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -47,7 +47,7 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) { try { - Packet packet = profilingConnection.ReadPacket(m_Timeout.load()); + arm::pipe::Packet packet = profilingConnection.ReadPacket(m_Timeout.load()); if (packet.IsEmpty()) { @@ -55,12 +55,12 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) continue; } - Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(), - packet.GetPacketId()); + arm::pipe::Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(), + packet.GetPacketId()); - CommandHandlerFunctor* commandHandlerFunctor = - m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(), - packet.GetPacketId(), + arm::pipe::CommandHandlerFunctor* commandHandlerFunctor = + m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(), + packet.GetPacketId(), version.GetEncodedValue()); ARMNN_ASSERT(commandHandlerFunctor); commandHandlerFunctor->operator()(packet); @@ -72,6 +72,19 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) m_KeepRunning.store(false); } } + catch (const arm::pipe::ProfilingException& e) + { + // Log the error and continue + ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what(); + // 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); + } + } catch (const Exception& e) { // Log the error and continue -- cgit v1.2.1