summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-liang Kao <clkao@clkao.org>2010-11-12 19:16:00 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-11-12 19:16:00 +0100
commita2500ae3485d6243778b832d22dc6dc02a00f025 (patch)
tree93d805dd3c7741ccdb83ccb2a930983bf714126f
parent8abe67357ab905c5c86191c1d9005666f66b6ca0 (diff)
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>
-rw-r--r--AUTHORS1
-rw-r--r--src/zmq.cpp32
2 files changed, 17 insertions, 16 deletions
diff --git a/AUTHORS b/AUTHORS
index 6a7fe1d..bdb17a1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,6 +8,7 @@ Bernd Prager <bernd@prager.ws>
Bernd Melchers <melchers@ZEDAT.FU-Berlin.DE>
Brian Buchanan <bwb@holo.org>
Burak Arslan <burak-github@arskom.com.tr>
+Chia-liang Kao <clkao@clkao.org>
Chris Wong <chris@chriswongstudio.com>
Christian Gudrian <christian.gudrian@fluidon.com>
Conrad D. Steenberg <conrad.steenberg@caltech.edu>
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 82e98f6..c073f82 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -545,24 +545,24 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
int nevents = 0;
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) {
+ // 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.
while (true) {
memcpy (&inset, &pollset_in, sizeof (fd_set));