Commit f7123de9 authored by Marc Rossi's avatar Marc Rossi Committed by Martin Sustrik

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: 's avatarMarc Rossi <mrossi19@gmail.com>
parent eb83678b
...@@ -20,6 +20,7 @@ Ivo Danihelka <ivo@danihelka.net> ...@@ -20,6 +20,7 @@ Ivo Danihelka <ivo@danihelka.net>
Joe Thornber <joe.thornber@gmail.com> Joe Thornber <joe.thornber@gmail.com>
Jon Dyte <jon@totient.co.uk> Jon Dyte <jon@totient.co.uk>
Kamil Shakirov <kamils80@gmail.com> Kamil Shakirov <kamils80@gmail.com>
Marc Rossi <mrossi19@gmail.com>
Martin Hurton <hurtonm@gmail.com> Martin Hurton <hurtonm@gmail.com>
Martin Lucina <mato@kotelna.sk> Martin Lucina <mato@kotelna.sk>
Martin Sustrik <sustrik@250bpm.com> Martin Sustrik <sustrik@250bpm.com>
......
...@@ -437,15 +437,17 @@ int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_) ...@@ -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 // In blocking scenario, commands are processed over and over again until
// we are able to fetch a message. // we are able to fetch a message.
bool block = (ticks != 0);
while (rc != 0) { while (rc != 0) {
if (errno != EAGAIN) if (errno != EAGAIN)
return -1; return -1;
if (unlikely (!app_thread->process_commands (true, false))) { if (unlikely (!app_thread->process_commands (block, false))) {
errno = ETERM; errno = ETERM;
return -1; return -1;
} }
rc = xrecv (msg_, flags_); rc = xrecv (msg_, flags_);
ticks = 0; ticks = 0;
block = true;
} }
rcvmore = msg_->flags & ZMQ_MSG_MORE; rcvmore = msg_->flags & ZMQ_MSG_MORE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment