diff --git a/lib/isc/include/isc/timer.h b/lib/isc/include/isc/timer.h index 45bc317bbb..0c0cf1a8d6 100644 --- a/lib/isc/include/isc/timer.h +++ b/lib/isc/include/isc/timer.h @@ -140,10 +140,12 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type, * interval. */ +void +isc_timer_async_destroy(isc_timer_t **timerp); void isc_timer_destroy(isc_timer_t **timerp); /*%< - * Destroy the timer *timerp. + * Destroy (asynchronously) the timer *timerp. * * Requires: * diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 46c2d4b99c..600380997e 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -225,3 +225,16 @@ void isc_timer_destroy(isc_timer_t **timerp) { isc__timer_detach(timerp); } + +void +isc_timer_async_destroy(isc_timer_t **timerp) { + isc_timer_t *timer = NULL; + + REQUIRE(timerp != NULL && VALID_TIMER(*timerp)); + + timer = *timerp; + *timerp = NULL; + + isc_timer_stop(timer); + isc_async_run(timer->loop, isc__timer_destroy, timer); +}