From aedd863e6f66fd446227e9b107bc9c1970092634 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Mon, 12 Oct 2026 13:36:04 +0300 Subject: timers: drop retired surface timer ids yasl_surface_del_timer zeroed its entry and kept it. A one-shot surface timer that fired stayed in the surface's id list until the surface was destroyed. A client that re-arms a one-shot timer, such as a cursor blink, grew the list without bound, and each delete scanned all of it. Delete now removes the entry. Before the list grows, add drops the ids that the loop has retired. The list holds only armed timers. Delete now returns false for a timer that already retired, as yasl_loop_del_timer does. Co-Authored-By: Claude Opus 5.5 --- tests/common/test_timers.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/common/test_timers.c') diff --git a/tests/common/test_timers.c b/tests/common/test_timers.c index d02bfe9..4e95c5a 100644 --- a/tests/common/test_timers.c +++ b/tests/common/test_timers.c @@ -264,6 +264,17 @@ static void test_surface_timers(void) yasl_display_dispatch(d, 10); assert(sctx.count == count_before); + /* A fired one-shot surface timer is retired, as a loop timer is. Many + * of them stay retired after the surface's id list compacts. */ + for (int i = 0; i < 64; i++) { + struct test_ctx octx = {0}; + octx.id = yasl_surface_add_timer(s, 1000000ull, oneshot_cb, &octx); + assert(octx.id > 0); + while (octx.count == 0) + yasl_display_dispatch(d, 50); + assert(!yasl_surface_del_timer(s, octx.id)); + } + /* Surface timer auto-cleanup on surface destruction */ struct test_ctx sctx2 = {0}; sctx2.id = yasl_surface_add_timer(s, 2000000ull, surface_timer_repeat_cb, &sctx2); -- cgit v1.2.3