From: Miroslav Lichvar Date: Tue, 19 Aug 2014 09:45:30 +0000 (+0200) Subject: sched: make sure scheduler parameter change handler is first X-Git-Tag: 1.31-pre1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bdac2c7b39950f13111d268cd4c53c60c6c8227;p=thirdparty%2Fchrony.git sched: make sure scheduler parameter change handler is first This is needed to allow other handlers to add new timers. --- diff --git a/local.c b/local.c index ee70dacd..5a3fb436 100644 --- a/local.c +++ b/local.c @@ -252,6 +252,14 @@ void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void * /* ================================================== */ +int +LCL_IsFirstParameterChangeHandler(LCL_ParameterChangeHandler handler) +{ + return change_list.next->handler == handler; +} + +/* ================================================== */ + static void invoke_parameter_change_handlers(struct timeval *raw, struct timeval *cooked, double dfreq, double doffset, diff --git a/local.h b/local.h index 62095100..aff9004f 100644 --- a/local.h +++ b/local.h @@ -92,6 +92,9 @@ extern void LCL_AddParameterChangeHandler(LCL_ParameterChangeHandler handler, vo /* Remove a handler */ extern void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler, void *anything); +/* Check if a handler is invoked first when dispatching */ +extern int LCL_IsFirstParameterChangeHandler(LCL_ParameterChangeHandler handler); + /* Function type for handlers to be called back when an indeterminate offset is introduced into the local time. This situation occurs when the frequency must be adjusted to effect a clock slew and diff --git a/sched.c b/sched.c index 81b58f71..16a451ab 100644 --- a/sched.c +++ b/sched.c @@ -514,6 +514,10 @@ handle_slew(struct timeval *raw, int i; if (change_type != LCL_ChangeAdjust) { + /* Make sure this handler is invoked first in order to not shift new timers + added from other handlers */ + assert(LCL_IsFirstParameterChangeHandler(handle_slew)); + /* If a step change occurs, just shift all raw time stamps by the offset */ for (ptr = timer_queue.next; ptr != &timer_queue; ptr = ptr->next) {