From 1ba7ac3c54d6db947e4a8a34fc56f7603d6e10a9 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Thu, 19 Dec 2019 13:43:07 -0500 Subject: [PATCH] only run pre_callbacks if the caller tells us to wait only the network & worker threads use the pre callbacks. And, the only thing they do is lower the wait time. So if we're told to not wait, then don't bother asking caller if the timers should be lowered. --- src/lib/util/event.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/util/event.c b/src/lib/util/event.c index d36f9f2b5b47..8c2192280860 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -1478,13 +1478,18 @@ int fr_event_corral(fr_event_list_t *el, fr_time_t now, bool wait) * Run the status callbacks. It may tell us that the * application has more work to do, in which case we * re-set the timeout to be instant. + * + * We only run these callbacks if the caller is otherwise + * idle. */ - for (pre = fr_dlist_head(&el->pre_callbacks); - pre != NULL; - pre = fr_dlist_next(&el->pre_callbacks, pre)) { - if (pre->callback(pre->uctx, wake ? *wake : 0) > 0) { - wake = &when; - when = 0; + if (wait) { + for (pre = fr_dlist_head(&el->pre_callbacks); + pre != NULL; + pre = fr_dlist_next(&el->pre_callbacks, pre)) { + if (pre->callback(pre->uctx, wake ? *wake : 0) > 0) { + wake = &when; + when = 0; + } } }