From 91ea20464439b5359a5d803181141fc756fa817c Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 8 Sep 2010 08:39:27 +0200 Subject: EINTR returned from the blocking functions --- src/zmq.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/zmq.cpp') 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; } -- cgit v1.2.3