]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Break after processing a callback
authorRoy Marples <roy@marples.name>
Sat, 10 Nov 2012 18:06:14 +0000 (18:06 +0000)
committerRoy Marples <roy@marples.name>
Sat, 10 Nov 2012 18:06:14 +0000 (18:06 +0000)
eloop.c

diff --git a/eloop.c b/eloop.c
index 457e0d7e4506ed9948b97b106d728f3455f30d0f..c856c7f3be2fe32a02e87f446bb0b0a519c499ee 100644 (file)
--- 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;
+                               }
                        }
                }
        }