From 4e6f25806e3c9fa4753ce959ef990167796acd32 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 14 May 2026 15:55:33 +0200 Subject: Tests and fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libtest/libtest_fd_tracking.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libtest/libtest_fd_tracking.c') diff --git a/libtest/libtest_fd_tracking.c b/libtest/libtest_fd_tracking.c index d3c766c..25cea8f 100644 --- a/libtest/libtest_fd_tracking.c +++ b/libtest/libtest_fd_tracking.c @@ -11,6 +11,9 @@ struct fd { static size_t nopened = 0u; static struct fd *opened = NULL; +static atomic_flag spinlock = ATOMIC_FLAG_INIT; +static int tracking_state = -1; + static int cmp_fd(const void *av, const void *bv) @@ -60,6 +63,14 @@ libtest_fd_tracking(int action) int accept_memleak = libtest_malloc_accept_leakage; size_t i, j; char *path; + int old_tracking_state; + + SPINLOCK(spinlock); + old_tracking_state = tracking_state; + tracking_state = action; + SPINUNLOCK(spinlock); + if (old_tracking_state == action) + return 1; /* so libtest doesn't complain about us not zeroing before freeing, * and so it will not report memory leaks in fprintf from our -- cgit v1.2.3-70-g09d2