From: Alan T. DeKok Date: Sat, 26 Nov 2016 21:18:30 +0000 (-0500) Subject: check for event loop exiting on fd/timer add event X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e81c64f0bd683edf2a980d4328190018bdb9244d;p=thirdparty%2Ffreeradius-server.git check for event loop exiting on fd/timer add event --- diff --git a/src/lib/event.c b/src/lib/event.c index 512e00baebe..62e3ca40612 100644 --- a/src/lib/event.c +++ b/src/lib/event.c @@ -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. */