From 747f9676a61c97a3a4e1bdb27bd7df8f2298a320 Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 3 Apr 2024 12:39:29 +0300 Subject: [PATCH] tpws: resolver_deinit clear list --- tpws/resolver.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tpws/resolver.c b/tpws/resolver.c index 885e563..5faffd9 100644 --- a/tpws/resolver.c +++ b/tpws/resolver.c @@ -38,6 +38,19 @@ static t_resolver resolver = { .bInit = false }; #define rlist_lock pthread_mutex_lock(&resolver.resolve_list_lock) #define rlist_unlock pthread_mutex_unlock(&resolver.resolve_list_lock) +static void resolver_clear_list(void) +{ + struct resolve_item *ri; + + for (;;) + { + ri = TAILQ_FIRST(&resolver.resolve_list); + if (!ri) break; + TAILQ_REMOVE(&resolver.resolve_list, ri, next); + free(ri); + } +} + int resolver_thread_count(void) { return resolver.bInit ? resolver.threads : 0; @@ -187,6 +200,7 @@ ex1: pthread_mutex_destroy(&resolver.resolve_list_lock); return false; } + void resolver_deinit(void) { if (resolver.bInit) @@ -211,6 +225,8 @@ void resolver_deinit(void) sem_destroy(resolver.sem); #endif + resolver_clear_list(); + memset(&resolver,0,sizeof(resolver)); } }