diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 9d1e95a1d1..873ebd197d 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -152,3 +152,13 @@ isc_timer_destroy(isc_timer_t **timerp); * *\li *timerp is NULL. */ + +bool +isc_timer_running(isc_timer_t *timer); +/*%< + * Return true if the timer has been started. + * + * Requires: + * + *\li 'timer' is a valid timer* + */ diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 4d30409084..bfd3377f4c 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -196,3 +197,10 @@ isc_timer_async_destroy(isc_timer_t **timerp) { isc_timer_stop(timer); isc_async_run(timer->loop, timer_destroy, timer); } + +bool +isc_timer_running(isc_timer_t *timer) { + REQUIRE(VALID_TIMER(timer)); + + return atomic_load_acquire(&timer->running); +}