diff options
author | luigi1111 <luigi1111w@gmail.com> | 2024-01-18 17:57:30 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2024-01-18 17:57:30 -0500 |
commit | 9d7b2532634e4c3e0978b6dd85164305609df90f (patch) | |
tree | 56c200a4cbc1f31b7ceaab8bf24d12c269ea3078 /src/rpc | |
parent | Merge pull request #9049 (diff) | |
parent | Fix EAGAIN bug in ZMQ-RPC/ZMQ-PUB (diff) | |
download | monero-9d7b2532634e4c3e0978b6dd85164305609df90f.tar.xz |
Merge pull request #9052
4acae11 Fix EAGAIN bug in ZMQ-RPC/ZMQ-PUB (Lee *!* Clagett)
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/zmq_server.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp index cb8a8bea4..d73ea3bc9 100644 --- a/src/rpc/zmq_server.cpp +++ b/src/rpc/zmq_server.cpp @@ -158,13 +158,22 @@ void ZmqServer::serve() if (!pub || sockets[2].revents) { - std::string message = MONERO_UNWRAP(net::zmq::receive(rep.get(), read_flags)); - MDEBUG("Received RPC request: \"" << message << "\""); - epee::byte_slice response = handler.handle(std::move(message)); - - const boost::string_ref response_view{reinterpret_cast<const char*>(response.data()), response.size()}; - MDEBUG("Sending RPC reply: \"" << response_view << "\""); - MONERO_UNWRAP(net::zmq::send(std::move(response), rep.get())); + expect<std::string> message = net::zmq::receive(rep.get(), read_flags); + if (!message) + { + // EAGAIN can occur when using `zmq_poll`, which doesn't inspect for message validity + if (message != net::zmq::make_error_code(EAGAIN)) + MONERO_THROW(message.error(), "Read failure on ZMQ-RPC"); + } + else // no errors + { + MDEBUG("Received RPC request: \"" << *message << "\""); + epee::byte_slice response = handler.handle(std::move(*message)); + + const boost::string_ref response_view{reinterpret_cast<const char*>(response.data()), response.size()}; + MDEBUG("Sending RPC reply: \"" << response_view << "\""); + MONERO_UNWRAP(net::zmq::send(std::move(response), rep.get())); + } } } } |