Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | 6da6a45 | 2020-07-14 14:26:27 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "SocketProfilingConnection.hpp" |
| 7 | |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 8 | #include <common/include/SocketConnectionException.hpp> |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 9 | |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 10 | #include <cerrno> |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 11 | #include <cstring> |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 12 | #include <fcntl.h> |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 13 | #include <string> |
| 14 | |
Rob Hughes | 25b7436 | 2020-01-13 11:14:59 +0000 | [diff] [blame] | 15 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 16 | namespace arm |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 17 | { |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 18 | namespace pipe |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 19 | { |
| 20 | |
| 21 | SocketProfilingConnection::SocketProfilingConnection() |
| 22 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 23 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 24 | arm::pipe::Initialize(); |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 25 | memset(m_Socket, 0, sizeof(m_Socket)); |
| 26 | // Note: we're using Linux specific SOCK_CLOEXEC flag. |
| 27 | m_Socket[0].fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); |
| 28 | if (m_Socket[0].fd == -1) |
| 29 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 30 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 31 | std::string("SocketProfilingConnection: Socket construction failed: ") + strerror(errno), |
| 32 | m_Socket[0].fd, |
| 33 | errno); |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | // Connect to the named unix domain socket. |
Rob Hughes | 25b7436 | 2020-01-13 11:14:59 +0000 | [diff] [blame] | 37 | sockaddr_un server{}; |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 38 | memset(&server, 0, sizeof(sockaddr_un)); |
| 39 | // As m_GatorNamespace begins with a null character we need to ignore that when getting its length. |
| 40 | memcpy(server.sun_path, m_GatorNamespace, strlen(m_GatorNamespace + 1) + 1); |
| 41 | server.sun_family = AF_UNIX; |
| 42 | if (0 != connect(m_Socket[0].fd, reinterpret_cast<const sockaddr*>(&server), sizeof(sockaddr_un))) |
| 43 | { |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 44 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 45 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 46 | std::string("SocketProfilingConnection: Cannot connect to stream socket: ") + strerror(errno), |
| 47 | m_Socket[0].fd, |
| 48 | errno); |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | // Our socket will only be interested in polling reads. |
| 52 | m_Socket[0].events = POLLIN; |
| 53 | |
| 54 | // Make the socket non blocking. |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 55 | if (!arm::pipe::SetNonBlocking(m_Socket[0].fd)) |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 56 | { |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 57 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 58 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 59 | std::string("SocketProfilingConnection: Failed to set socket as non blocking: ") + strerror(errno), |
| 60 | m_Socket[0].fd, |
| 61 | errno); |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 62 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 63 | #endif |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 66 | bool SocketProfilingConnection::IsOpen() const |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 67 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 68 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 69 | return m_Socket[0].fd > 0; |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 70 | #else |
| 71 | return false; |
| 72 | #endif |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void SocketProfilingConnection::Close() |
| 76 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 77 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 78 | if (arm::pipe::Close(m_Socket[0].fd) != 0) |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 79 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 80 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 81 | std::string("SocketProfilingConnection: Cannot close stream socket: ") + strerror(errno), |
| 82 | m_Socket[0].fd, |
| 83 | errno); |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 84 | } |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 85 | |
| 86 | memset(m_Socket, 0, sizeof(m_Socket)); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 87 | #endif |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 88 | } |
| 89 | |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 90 | bool SocketProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length) |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 91 | { |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 92 | if (buffer == nullptr || length == 0) |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 93 | { |
| 94 | return false; |
| 95 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 96 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 97 | return arm::pipe::Write(m_Socket[0].fd, buffer, length) != -1; |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 98 | #else |
| 99 | return false; |
| 100 | #endif |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 101 | } |
| 102 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 103 | arm::pipe::Packet SocketProfilingConnection::ReadPacket(uint32_t timeout) |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 104 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 105 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 106 | // Is there currently at least a header worth of data waiting to be read? |
| 107 | int bytes_available = 0; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 108 | arm::pipe::Ioctl(m_Socket[0].fd, FIONREAD, &bytes_available); |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 109 | if (bytes_available >= 8) |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 110 | { |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 111 | // Yes there is. Read it: |
| 112 | return ReceivePacket(); |
| 113 | } |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 114 | |
| 115 | // Poll for data on the socket or until timeout occurs |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 116 | int pollResult = arm::pipe::Poll(&m_Socket[0], 1, static_cast<int>(timeout)); |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 117 | |
| 118 | switch (pollResult) |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 119 | { |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 120 | case -1: // Error |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 121 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 122 | std::string("SocketProfilingConnection: Error occured while reading from socket: ") + strerror(errno), |
| 123 | m_Socket[0].fd, |
| 124 | errno); |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 125 | |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 126 | case 0: // Timeout |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 127 | throw arm::pipe::TimeoutException("SocketProfilingConnection: Timeout while reading from socket"); |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 128 | |
| 129 | default: // Normal poll return but it could still contain an error signal |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 130 | // Check if the socket reported an error |
| 131 | if (m_Socket[0].revents & (POLLNVAL | POLLERR | POLLHUP)) |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 132 | { |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 133 | if (m_Socket[0].revents == POLLNVAL) |
| 134 | { |
| 135 | // This is an unrecoverable error. |
| 136 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 137 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 138 | std::string("SocketProfilingConnection: Error occured while polling receiving socket: POLLNVAL."), |
| 139 | m_Socket[0].fd); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 140 | } |
| 141 | if (m_Socket[0].revents == POLLERR) |
| 142 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 143 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 144 | std::string( |
| 145 | "SocketProfilingConnection: Error occured while polling receiving socket: POLLERR: ") |
| 146 | + strerror(errno), |
| 147 | m_Socket[0].fd, |
| 148 | errno); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 149 | } |
| 150 | if (m_Socket[0].revents == POLLHUP) |
| 151 | { |
| 152 | // This is an unrecoverable error. |
| 153 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 154 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 155 | std::string("SocketProfilingConnection: Connection closed by remote client: POLLHUP."), |
| 156 | m_Socket[0].fd); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 157 | } |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 158 | } |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 159 | |
| 160 | // Check if there is data to read |
| 161 | if (!(m_Socket[0].revents & (POLLIN))) |
| 162 | { |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 163 | // This is a corner case. The socket as been woken up but not with any data. |
| 164 | // We'll throw a timeout exception to loop around again. |
Jim Flynn | decd08b | 2022-03-13 22:35:46 +0000 | [diff] [blame] | 165 | throw arm::pipe::TimeoutException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 166 | "SocketProfilingConnection: File descriptor was polled but no data was available to receive."); |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | return ReceivePacket(); |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 170 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 171 | #else |
| 172 | IgnoreUnused(timeout); |
| 173 | throw arm::pipe::TimeoutException( |
| 174 | "SocketProfilingConnection: Cannot use ReadPacket function with sockets disabled"); |
| 175 | #endif |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 176 | } |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 177 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 178 | arm::pipe::Packet SocketProfilingConnection::ReceivePacket() |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 179 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 180 | #if !defined(ARMNN_DISABLE_SOCKETS) |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 181 | char header[8] = {}; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 182 | long receiveResult = arm::pipe::Read(m_Socket[0].fd, &header, sizeof(header)); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 183 | // We expect 8 as the result here. 0 means EOF, socket is closed. -1 means there been some other kind of error. |
| 184 | switch( receiveResult ) |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 185 | { |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 186 | case 0: |
| 187 | // Socket has closed. |
| 188 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 189 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 190 | std::string("SocketProfilingConnection: Remote socket has closed the connection."), |
| 191 | m_Socket[0].fd); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 192 | case -1: |
| 193 | // There's been a socket error. We will presume it's unrecoverable. |
| 194 | Close(); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 195 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 196 | std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno), |
| 197 | m_Socket[0].fd, |
| 198 | errno); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 199 | default: |
| 200 | if (receiveResult < 8) |
| 201 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 202 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 203 | std::string( |
| 204 | "SocketProfilingConnection: The received packet did not contains a valid PIPE header."), |
| 205 | m_Socket[0].fd); |
Colm Donelan | 9ea7700 | 2019-10-17 14:02:44 +0100 | [diff] [blame] | 206 | } |
| 207 | break; |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 208 | } |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 209 | |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 210 | // stream_metadata_identifier is the first 4 bytes |
| 211 | uint32_t metadataIdentifier = 0; |
| 212 | std::memcpy(&metadataIdentifier, header, sizeof(metadataIdentifier)); |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 213 | |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 214 | // data_length is the next 4 bytes |
| 215 | uint32_t dataLength = 0; |
| 216 | std::memcpy(&dataLength, header + 4u, sizeof(dataLength)); |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 217 | |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 218 | std::unique_ptr<unsigned char[]> packetData; |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 219 | if (dataLength > 0) |
| 220 | { |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 221 | packetData = std::make_unique<unsigned char[]>(dataLength); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 222 | long receivedLength = arm::pipe::Read(m_Socket[0].fd, packetData.get(), dataLength); |
Jim Flynn | e11ff89 | 2019-10-04 04:25:43 -0700 | [diff] [blame] | 223 | if (receivedLength < 0) |
| 224 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 225 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 226 | std::string("SocketProfilingConnection: Error occured while reading the packet: ") + strerror(errno), |
| 227 | m_Socket[0].fd, |
| 228 | errno); |
Jim Flynn | e11ff89 | 2019-10-04 04:25:43 -0700 | [diff] [blame] | 229 | } |
| 230 | if (dataLength != static_cast<uint32_t>(receivedLength)) |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 231 | { |
| 232 | // What do we do here if we can't read in a full packet? |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 233 | throw arm::pipe::SocketConnectionException( |
Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame] | 234 | std::string("SocketProfilingConnection: Invalid PIPE packet."), |
| 235 | m_Socket[0].fd); |
Matteo Martincigh | 24e8f92 | 2019-09-19 11:57:46 +0100 | [diff] [blame] | 236 | } |
FinnWilliamsArm | a0c7871 | 2019-09-16 12:06:47 +0100 | [diff] [blame] | 237 | } |
Colm Donelan | a21620d | 2019-10-11 13:09:49 +0100 | [diff] [blame] | 238 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 239 | return arm::pipe::Packet(metadataIdentifier, dataLength, packetData); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame] | 240 | #else |
| 241 | throw arm::pipe::TimeoutException( |
| 242 | "SocketProfilingConnection: Cannot use ReceivePacket function with sockets disabled"); |
| 243 | #endif |
Teresa Charlin | 9bab496 | 2019-09-06 12:28:35 +0100 | [diff] [blame] | 244 | } |
| 245 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 246 | } // namespace pipe |
| 247 | } // namespace arm |