mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 18:03:50 +00:00
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: Chia-liang Kao <clkao@clkao.org>
This commit is contained in:
parent
8abe67357a
commit
a2500ae348
1
AUTHORS
1
AUTHORS
@ -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>
|
||||||
|
32
src/zmq.cpp
32
src/zmq.cpp
@ -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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user