Commit a2500ae3 authored by Chia-liang Kao's avatar Chia-liang Kao Committed by Martin Sustrik

Fix a bug that zmq_poll's select backend spins when timeout=-1, due to

ptimeout not properly recalculated after first pass.
Signed-off-by: 's avatarChia-liang Kao <clkao@clkao.org>
parent 8abe6735
...@@ -8,6 +8,7 @@ Bernd Prager <bernd@prager.ws> ...@@ -8,6 +8,7 @@ Bernd Prager <bernd@prager.ws>
Bernd Melchers <melchers@ZEDAT.FU-Berlin.DE> Bernd Melchers <melchers@ZEDAT.FU-Berlin.DE>
Brian Buchanan <bwb@holo.org> Brian Buchanan <bwb@holo.org>
Burak Arslan <burak-github@arskom.com.tr> Burak Arslan <burak-github@arskom.com.tr>
Chia-liang Kao <clkao@clkao.org>
Chris Wong <chris@chriswongstudio.com> Chris Wong <chris@chriswongstudio.com>
Christian Gudrian <christian.gudrian@fluidon.com> Christian Gudrian <christian.gudrian@fluidon.com>
Conrad D. Steenberg <conrad.steenberg@caltech.edu> Conrad D. Steenberg <conrad.steenberg@caltech.edu>
......
...@@ -545,24 +545,24 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) ...@@ -545,24 +545,24 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
int nevents = 0; int nevents = 0;
fd_set inset, outset, errset; fd_set inset, outset, errset;
// Compute the timeout for the subsequent poll.
timeval timeout;
timeval *ptimeout;
if (first_pass) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
ptimeout = &timeout;
}
else if (timeout_ < 0)
ptimeout = NULL;
else {
timeout.tv_sec = (long) ((end - now) / 1000);
timeout.tv_usec = (long) ((end - now) % 1000 * 1000);
ptimeout = &timeout;
}
while (true) { while (true) {
// Compute the timeout for the subsequent poll.
timeval timeout;
timeval *ptimeout;
if (first_pass) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
ptimeout = &timeout;
}
else if (timeout_ < 0)
ptimeout = NULL;
else {
timeout.tv_sec = (long) ((end - now) / 1000);
timeout.tv_usec = (long) ((end - now) % 1000 * 1000);
ptimeout = &timeout;
}
// Wait for events. Ignore interrupts if there's infinite timeout. // Wait for events. Ignore interrupts if there's infinite timeout.
while (true) { while (true) {
memcpy (&inset, &pollset_in, sizeof (fd_set)); memcpy (&inset, &pollset_in, sizeof (fd_set));
......
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