From c7b15f1f5acf096cd2e6d97b6754d39248a0ac2b Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 5 Apr 2024 16:44:04 +0000 Subject: [PATCH] Expose internal timer_purge() as isc_timer_purge() This function is used in a unit test to check for data races. --- lib/isc/include/isc/timer.h | 15 +++++++++++++++ lib/isc/timer.c | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 815cf42dbe..77b7507031 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -224,6 +224,21 @@ isc_timer_touch(isc_timer_t *timer); *\li Unexpected error */ +void +isc_timer_purge(isc_timer_t *timer); +/*%< + * Purge timer. + * + * Requires: + * + *\li 'timer' points to a valid timer. + * + * Ensures: + * + *\li Any events already posted by the timer are purged. + * + */ + void isc_timer_destroy(isc_timer_t **timerp); /*%< diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 40ae929ce8..e4a1c4b2cc 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -469,6 +469,15 @@ isc_timer_touch(isc_timer_t *timer) { return (result); } +void +isc_timer_purge(isc_timer_t *timer) { + REQUIRE(VALID_TIMER(timer)); + + LOCK(&timer->lock); + timer_purge(timer); + UNLOCK(&timer->lock); +} + void isc_timer_destroy(isc_timer_t **timerp) { isc_timer_t *timer = NULL;