]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check for event loop exiting on fd/timer add event
authorAlan T. DeKok <aland@freeradius.org>
Sat, 26 Nov 2016 21:18:30 +0000 (16:18 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 26 Nov 2016 21:24:08 +0000 (16:24 -0500)
src/lib/event.c

index 512e00baebe5cab41694afc684fdca19c1c8a7ea..62e3ca40612e11b010aff295307069d46b631d43 100644 (file)
@@ -275,6 +275,11 @@ fr_event_fd_t *fr_event_fd_insert(fr_event_list_t *el, int fd,
                return NULL;
        }
 
+       if (el->exit) {
+               fr_strerror_printf("Event loop exiting");
+               return NULL;
+       }
+
        memset(&find, 0, sizeof(find));
 
        /*
@@ -416,6 +421,11 @@ int fr_event_timer_insert(fr_event_list_t *el, fr_event_callback_t callback, voi
                return -1;
        }
 
+       if (el->exit) {
+               fr_strerror_printf("Event loop exiting");
+               return -1;
+       }
+
        /*
         *      If there is an event, re-use it instead of freeing it
         *      and allocating a new one.
@@ -558,7 +568,10 @@ int fr_event_corral(fr_event_list_t *el, bool wait)
        struct timeval when, *wake;
        struct timespec ts_when, *ts_wake;
 
-       if (el->exit) return -1;
+       if (el->exit) {
+               fr_strerror_printf("Event loop exiting");
+               return -1;
+       }
 
        /*
         *      Find the first event.  If there's none, we wait
@@ -631,6 +644,8 @@ void fr_event_service(fr_event_list_t *el)
 {
        int i;
 
+       if (el->exit) return;
+
        /*
         *      Loop over all of the events, servicing them.
         */