diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-10-16 17:56:25 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-10-16 17:56:25 +0200 |
commit | 8b8837688a97c4d05aff01a6dea7ac5a35b21fa2 (patch) | |
tree | 61f5af2f173a9e680525529524ae0f1fc46fa338 /src | |
parent | 72b15a6dae6c199d847ebde5ac73de238f0ebf75 (diff) |
Couple of bugs in zmq_poll fixed.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/zmq.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/zmq.cpp b/src/zmq.cpp index 5fcf078..c3aca6a 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -457,8 +457,11 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) // At this point we are meant to wait for events but there are none. // If timeout is infinite we can just loop until we get some events. - if (timeout_ < 0) + if (timeout_ < 0) { + if (first_pass) + first_pass = false; continue; + } // The timeout is finite and there are no events. In the first pass // we get a timestamp of when the polling have begun. (We assume that @@ -467,6 +470,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) if (first_pass) { now = clock.now_ms (); end = now + (timeout_ / 1000); + if (now == end) + break; + first_pass = false; continue; } @@ -617,8 +623,11 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) // At this point we are meant to wait for events but there are none. // If timeout is infinite we can just loop until we get some events. - if (timeout_ < 0) + if (timeout_ < 0) { + if (first_pass) + first_pass = false; continue; + } // The timeout is finite and there are no events. In the first pass // we get a timestamp of when the polling have begun. (We assume that @@ -627,6 +636,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) if (first_pass) { now = clock.now_ms (); end = now + (timeout_ / 1000); + if (now == end) + break; + first_pass = false; continue; } |