mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 13:47:13 +01:00
Fix socket_t::recv() hang scenario where initial call to process_commands() eats signal
Added block boolean var to second process_commands() invocation for blocking sockets instead of always using true. This prevents the process_commands() call from hanging when a message is received with an empty queue after the call to xrecv() but prior to the initial call to process_commands() invoked when ++ticks == inbound_poll_rate. Signed-off-by: Marc Rossi <mrossi19@gmail.com>
This commit is contained in:
committed by
Martin Sustrik
parent
eb83678b2b
commit
f7123de943
@@ -437,15 +437,17 @@ int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
|
||||
|
||||
// In blocking scenario, commands are processed over and over again until
|
||||
// we are able to fetch a message.
|
||||
bool block = (ticks != 0);
|
||||
while (rc != 0) {
|
||||
if (errno != EAGAIN)
|
||||
return -1;
|
||||
if (unlikely (!app_thread->process_commands (true, false))) {
|
||||
if (unlikely (!app_thread->process_commands (block, false))) {
|
||||
errno = ETERM;
|
||||
return -1;
|
||||
}
|
||||
rc = xrecv (msg_, flags_);
|
||||
ticks = 0;
|
||||
block = true;
|
||||
}
|
||||
|
||||
rcvmore = msg_->flags & ZMQ_MSG_MORE;
|
||||
|
||||
Reference in New Issue
Block a user