| 284 | } |
| 285 | |
| 286 | std::optional<CNetMessage> DynSock::Pipe::GetNetMsg() |
| 287 | { |
| 288 | V1Transport transport{NodeId{0}}; |
| 289 | |
| 290 | { |
| 291 | WAIT_LOCK(m_mutex, lock); |
| 292 | |
| 293 | WaitForDataOrEof(lock); |
| 294 | if (m_eof && m_data.empty()) { |
| 295 | return std::nullopt; |
| 296 | } |
| 297 | |
| 298 | for (;;) { |
| 299 | std::span<const uint8_t> s{m_data}; |
| 300 | if (!transport.ReceivedBytes(s)) { // Consumed bytes are removed from the front of s. |
| 301 | return std::nullopt; |
| 302 | } |
| 303 | m_data.erase(m_data.begin(), m_data.begin() + m_data.size() - s.size()); |
| 304 | if (transport.ReceivedMessageComplete()) { |
| 305 | break; |
| 306 | } |
| 307 | if (m_data.empty()) { |
| 308 | WaitForDataOrEof(lock); |
| 309 | if (m_eof && m_data.empty()) { |
| 310 | return std::nullopt; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | bool reject{false}; |
| 317 | CNetMessage msg{transport.GetReceivedMessage(/*time=*/{}, reject)}; |
| 318 | if (reject) { |
| 319 | return std::nullopt; |
| 320 | } |
| 321 | return std::make_optional<CNetMessage>(std::move(msg)); |
| 322 | } |
| 323 | |
| 324 | void DynSock::Pipe::PushBytes(const void* buf, size_t len) |
| 325 | { |
nothing calls this directly
no test coverage detected