summaryrefslogtreecommitdiff
path: root/ot_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_event.c')
-rw-r--r--ot_event.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ot_event.c b/ot_event.c
index ce0feef..1542bf5 100644
--- a/ot_event.c
+++ b/ot_event.c
@@ -83,8 +83,10 @@ int event_wait(ot_event *out, int max, int timeout_ms) {
83 g_ready_space = max; 83 g_ready_space = max;
84 } 84 }
85 85
86 while ((count = epoll_wait(g_epoll, g_ready, max, timeout_ms)) == -1 && errno == EINTR) 86 /* An interrupted wait is reported as no events rather than retried here,
87 ; 87 so that the caller gets to look at whatever the signal was about */
88 if ((count = epoll_wait(g_epoll, g_ready, max, timeout_ms)) == -1)
89 return errno == EINTR ? 0 : -1;
88 for (i = 0; i < count; ++i) { 90 for (i = 0; i < count; ++i) {
89 uint32_t events = g_ready[i].events; 91 uint32_t events = g_ready[i].events;
90 92
@@ -189,8 +191,10 @@ int event_wait(ot_event *out, int max, int timeout_ms) {
189 deadline = &timeout; 191 deadline = &timeout;
190 } 192 }
191 193
192 while ((count = kevent(g_kqueue, NULL, 0, g_ready, max, deadline)) == -1 && errno == EINTR) 194 /* An interrupted wait is reported as no events rather than retried here,
193 ; 195 so that the caller gets to look at whatever the signal was about */
196 if ((count = kevent(g_kqueue, NULL, 0, g_ready, max, deadline)) == -1)
197 return errno == EINTR ? 0 : -1;
194 for (i = 0; i < count; ++i) { 198 for (i = 0; i < count; ++i) {
195 uint64_t udata = (uint64_t)(uintptr_t)g_ready[i].udata; 199 uint64_t udata = (uint64_t)(uintptr_t)g_ready[i].udata;
196 int eof = (g_ready[i].flags & (EV_EOF | EV_ERROR)) != 0; 200 int eof = (g_ready[i].flags & (EV_EOF | EV_ERROR)) != 0;
@@ -310,8 +314,10 @@ int event_del(int fd) {
310int event_wait(ot_event *out, int max, int timeout_ms) { 314int event_wait(ot_event *out, int max, int timeout_ms) {
311 int ready, found = 0, i; 315 int ready, found = 0, i;
312 316
313 while ((ready = poll(g_pfds, (nfds_t)g_count, timeout_ms)) == -1 && errno == EINTR) 317 /* An interrupted wait is reported as no events rather than retried here,
314 ; 318 so that the caller gets to look at whatever the signal was about */
319 if ((ready = poll(g_pfds, (nfds_t)g_count, timeout_ms)) == -1)
320 return errno == EINTR ? 0 : -1;
315 if (ready <= 0) 321 if (ready <= 0)
316 return ready; 322 return ready;
317 323