From 36267c04c6444015d83e56ce3c8f5b0d788f9b42 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Tue, 6 Jul 2021 21:12:59 +0100 Subject: [PATCH] add explicit checks to free and destroy mutexes --- src/memory/free_store_contents.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/memory/free_store_contents.c b/src/memory/free_store_contents.c index 2f8101565..e38b6216c 100644 --- a/src/memory/free_store_contents.c +++ b/src/memory/free_store_contents.c @@ -17,6 +17,8 @@ void free_store_contents(struct store_t * RESTRICT const store) if(store) { + + #ifdef NUCSYN nucsyn_free_store_contents(store); #endif @@ -85,5 +87,34 @@ void free_store_contents(struct store_t * RESTRICT const store) #endif free_pulsator_store(store); + + +#ifdef __HAVE_LIBPTHREAD__ + /* + * Make mutexes for later locking + */ + pthread_mutex_unlock(&store->lock); + if(pthread_mutex_destroy(&store->lock) != 0) + { + fprintf(stderr, + "\n store->lock mutex destroy failed\n"); + } + pthread_mutex_unlock(&store->derivative_map_lock); + if(pthread_mutex_destroy(&store->derivative_map_lock) != 0) + { + fprintf(stderr, + "\n store->derivative_map_lock mutex destroy failed\n"); + } +#ifdef MINT + pthread_mutex_unlock(&store->MINT_load_lock); + if(pthread_mutex_destroy(&store->MINT_load_lock) != 0) + { + fprintf(stderr, + "\n store->MINT_load_lock mutex destroy failed\n"); + } +#endif//MINT + +#endif//__HAVE_LIBPTHREAD__ + } } -- GitLab