diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-09-08 08:39:27 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-09-08 08:39:27 +0200 |
commit | 91ea20464439b5359a5d803181141fc756fa817c (patch) | |
tree | 00cafd9ce918211a4a5e14d373253acb5956b7ef /src/zmq.cpp | |
parent | f374431ebe0f3e18a2b2adeafa8093ff59a9eac2 (diff) |
EINTR returned from the blocking functions
Diffstat (limited to 'src/zmq.cpp')
-rw-r--r-- | src/zmq.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/zmq.cpp b/src/zmq.cpp index 736f764..9a4bdec 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -409,17 +409,12 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) while (true) { - // Wait for events. Ignore interrupts if there's infinite timeout. + // Wait for events. while (true) { int rc = poll (pollfds, nitems_, first_pass ? 0 : timeout); if (rc == -1 && errno == EINTR) { - if (timeout_ < 0) - continue; - else { - // TODO: Calculate remaining timeout and restart poll (). - free (pollfds); - return 0; - } + free (pollfds); + return -1; } errno_assert (rc >= 0); break; @@ -474,6 +469,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) if (timeout == -1 && nevents == 0) continue; + // TODO: if nevents is zero recompute timeout and loop + // if it is not yet reached. + break; } @@ -544,13 +542,8 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) #if defined ZMQ_HAVE_WINDOWS wsa_assert (rc != SOCKET_ERROR); #else - if (rc == -1 && errno == EINTR) { - if (timeout_ < 0) - continue; - else - // TODO: Calculate remaining timeout and restart select (). - return 0; - } + if (rc == -1 && errno == EINTR) + return -1; errno_assert (rc >= 0); #endif break; @@ -610,6 +603,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) if (timeout_ < 0 && nevents == 0) continue; + // TODO: if nevents is zero recompute timeout and loop + // if it is not yet reached. + break; } |