| 54 | } |
| 55 | |
| 56 | void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) |
| 57 | { |
| 58 | do |
| 59 | { |
| 60 | try |
| 61 | { |
| 62 | arm::pipe::Packet packet = profilingConnection.ReadPacket(m_Timeout.load()); |
| 63 | |
| 64 | if (packet.IsEmpty()) |
| 65 | { |
| 66 | // Nothing to do, continue |
| 67 | continue; |
| 68 | } |
| 69 | |
| 70 | arm::pipe::Version version = m_PacketVersionResolver.ResolvePacketVersion(packet.GetPacketFamily(), |
| 71 | packet.GetPacketId()); |
| 72 | |
| 73 | arm::pipe::CommandHandlerFunctor* commandHandlerFunctor = |
| 74 | m_CommandHandlerRegistry.GetFunctor(packet.GetPacketFamily(), |
| 75 | packet.GetPacketId(), |
| 76 | version.GetEncodedValue()); |
| 77 | ARM_PIPE_ASSERT(commandHandlerFunctor); |
| 78 | commandHandlerFunctor->operator()(packet); |
| 79 | } |
| 80 | catch (const arm::pipe::TimeoutException&) |
| 81 | { |
| 82 | if (m_StopAfterTimeout.load()) |
| 83 | { |
| 84 | m_KeepRunning.store(false); |
| 85 | } |
| 86 | } |
| 87 | catch (const arm::pipe::ProfilingException& e) |
| 88 | { |
| 89 | // Log the error and continue |
| 90 | ARM_PIPE_LOG(warning) << "An error has occurred when handling a command: " << e.what(); |
| 91 | // Did we get here because the socket failed? |
| 92 | if ( !profilingConnection.IsOpen() ) |
| 93 | { |
| 94 | // We're going to stop processing commands. |
| 95 | // This will leave the thread idle. There is no mechanism to restart the profiling service when the |
| 96 | // connection is lost. |
| 97 | m_KeepRunning.store(false); |
| 98 | } |
| 99 | } |
| 100 | catch (...) |
| 101 | { |
| 102 | // Log the error and continue |
| 103 | ARM_PIPE_LOG(warning) << "An unknown error has occurred when handling a command"; |
| 104 | // Did we get here because the socket failed? |
| 105 | if ( !profilingConnection.IsOpen() ) |
| 106 | { |
| 107 | // We're going to stop processing commands. |
| 108 | // This will leave the thread idle. There is no mechanism to restart the profiling service when the |
| 109 | // connection is lost. |
| 110 | m_KeepRunning.store(false); |
| 111 | } |
| 112 | } |
| 113 | } |
nothing calls this directly
no test coverage detected