mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-22 07:22:25 +00:00
Merge pull request #9053
fe746dc
Fix EAGAIN bug in ZMQ-RPC/ZMQ-PUB (Lee *!* Clagett)
This commit is contained in:
commit
9a70f43440
1 changed files with 15 additions and 6 deletions
|
@ -158,13 +158,22 @@ void ZmqServer::serve()
|
||||||
|
|
||||||
if (!pub || sockets[2].revents)
|
if (!pub || sockets[2].revents)
|
||||||
{
|
{
|
||||||
std::string message = MONERO_UNWRAP(net::zmq::receive(rep.get(), read_flags));
|
expect<std::string> message = net::zmq::receive(rep.get(), read_flags);
|
||||||
MDEBUG("Received RPC request: \"" << message << "\"");
|
if (!message)
|
||||||
epee::byte_slice response = handler.handle(std::move(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()};
|
const boost::string_ref response_view{reinterpret_cast<const char*>(response.data()), response.size()};
|
||||||
MDEBUG("Sending RPC reply: \"" << response_view << "\"");
|
MDEBUG("Sending RPC reply: \"" << response_view << "\"");
|
||||||
MONERO_UNWRAP(net::zmq::send(std::move(response), rep.get()));
|
MONERO_UNWRAP(net::zmq::send(std::move(response), rep.get()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue