]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix the task unit test
authorAram Sargsyan <aram@isc.org>
Tue, 1 Apr 2025 10:46:05 +0000 (10:46 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 10 Apr 2025 19:42:20 +0000 (19:42 +0000)
The timers can be destroyed while the timer actions are still running,
and when the action calls isc_event_free() it can assert, because it's
trying to access the destroyed timer object.

Before destroying the timers, first disable them, then wait 2 seconds
of grace period before destroying them.

tests/isc/task_test.c

index cda67fcb1f8169ad49c3058c50ef1f527a25e3a1..2d5d0d0a8c0453acde0d380c06fe9fc2e5658c8e 100644 (file)
@@ -571,7 +571,17 @@ ISC_RUN_TEST_IMPL(basic) {
 
        atomic_store(&done, true);
 
+       /* Let everything run for 10 seconds. */
        sleep(10);
+
+       /*
+        * Disable the timers, let all the already dispatched events to
+        * complete, and then destroy the timers.
+        */
+       (void)isc_timer_reset(ti1, isc_timertype_inactive, NULL, NULL, true);
+       (void)isc_timer_reset(ti2, isc_timertype_inactive, NULL, NULL, true);
+       (void)isc_timer_reset(ti3, isc_timertype_inactive, NULL, NULL, true);
+       sleep(4);
        isc_timer_destroy(&ti1);
        isc_timer_destroy(&ti2);
        LOCK(&lock);