From: Roy Marples Date: Sat, 10 Nov 2012 18:06:14 +0000 (+0000) Subject: Break after processing a callback X-Git-Tag: v5.99.3~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9dcf151f42193d3b68e5afde4da02d2bbfa80a1;p=thirdparty%2Fdhcpcd.git Break after processing a callback --- diff --git a/eloop.c b/eloop.c index 457e0d7e..c856c7f3 100644 --- a/eloop.c +++ b/eloop.c @@ -295,10 +295,9 @@ start_eloop(const sigset_t *cursigs) const struct timespec *tsp; for (;;) { - get_monotonic(&now); - /* Run all timeouts first */ if (timeouts) { + get_monotonic(&now); if (timercmp(&now, &timeouts->when, >)) { t = timeouts; timeouts = timeouts->next; @@ -340,8 +339,13 @@ start_eloop(const sigset_t *cursigs) /* Process any triggered events. */ if (n) { for (e = events; e; e = e->next) { - if (FD_ISSET(e->fd, &read_fds)) + if (FD_ISSET(e->fd, &read_fds)) { e->callback(e->arg); + /* We need to break here as the + * callback could destroy the next + * fd to process. */ + break; + } } } }