From 9013ee0d52bb88a5ea08b78c1d31ea5b1b0cd95d Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Tue, 13 Nov 2012 13:06:29 +0100 Subject: [PATCH] Minor code cleanup --- src/epoll.cpp | 5 +++-- src/kqueue.cpp | 5 +++-- src/poll.cpp | 6 +++--- src/select.cpp | 5 +++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/epoll.cpp b/src/epoll.cpp index a62345d4..3855ddfd 100644 --- a/src/epoll.cpp +++ b/src/epoll.cpp @@ -140,9 +140,10 @@ void zmq::epoll_t::loop () // Wait for events. int n = epoll_wait (epoll_fd, &ev_buf [0], max_io_events, timeout ? timeout : -1); - if (n == -1 && errno == EINTR) + if (n == -1) { + errno_assert (errno == EINTR); continue; - errno_assert (n != -1); + } for (int i = 0; i < n; i ++) { poll_entry_t *pe = ((poll_entry_t*) ev_buf [i].data.ptr); diff --git a/src/kqueue.cpp b/src/kqueue.cpp index 0b07faba..5fbd01c3 100644 --- a/src/kqueue.cpp +++ b/src/kqueue.cpp @@ -163,9 +163,10 @@ void zmq::kqueue_t::loop () timespec ts = {timeout / 1000, (timeout % 1000) * 1000000}; int n = kevent (kqueue_fd, NULL, 0, &ev_buf [0], max_io_events, timeout ? &ts: NULL); - if (n == -1 && errno == EINTR) + if (n == -1) { + errno_assert (errno == EINTR); continue; - errno_assert (n != -1); + } for (int i = 0; i < n; i ++) { poll_entry_t *pe = (poll_entry_t*) ev_buf [i].udata; diff --git a/src/poll.cpp b/src/poll.cpp index de7e0da3..e41f8fb4 100644 --- a/src/poll.cpp +++ b/src/poll.cpp @@ -125,10 +125,10 @@ void zmq::poll_t::loop () // Wait for events. int rc = poll (&pollset [0], pollset.size (), timeout ? timeout : -1); - if (rc == -1 && errno == EINTR) + if (rc == -1) { + errno_assert (errno == EINTR); continue; - errno_assert (rc != -1); - + } // If there are no events (i.e. it's a timeout) there's no point // in checking the pollset. diff --git a/src/select.cpp b/src/select.cpp index 56b87ae6..d1792f01 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -168,9 +168,10 @@ void zmq::select_t::loop () #else int rc = select (maxfd + 1, &readfds, &writefds, &exceptfds, timeout ? &tv : NULL); - if (rc == -1 && errno == EINTR) + if (rc == -1) { + errno_assert (errno == EINTR); continue; - errno_assert (rc != -1); + } #endif // If there are no events (i.e. it's a timeout) there's no point