From 614b9d84234cf8c4ed37757baeba10d621ddd21b Mon Sep 17 00:00:00 2001 From: Fufu Fang Date: Sun, 24 Nov 2024 17:39:00 +0000 Subject: [PATCH] fix error message at destroying locks --- src/cache.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/cache.c b/src/cache.c index d061e1f..8d3c8ad 100644 --- a/src/cache.c +++ b/src/cache.c @@ -552,20 +552,30 @@ static Cache *Cache_alloc(void) */ static void Cache_free(Cache *cf) { - if (pthread_mutex_destroy(&cf->seek_lock)) { - lprintf(fatal, "could not destroy seek_lock: %s!\n", strerror(errno)); + int err_code = 0; + + err_code = pthread_mutex_destroy(&cf->seek_lock); + if (err_code) { + lprintf(fatal, "could not destroy seek_lock: %d, %s!\n", err_code, + strerror(err_code)); } - if (pthread_mutex_destroy(&cf->w_lock)) { - lprintf(fatal, "could not destroy w_lock: %s!\n", strerror(errno)); + err_code = pthread_mutex_destroy(&cf->w_lock); + if (err_code) { + lprintf(fatal, "could not destroy w_lock: %d, %s!\n", err_code, + strerror(err_code)); } - if (pthread_mutex_destroy(&cf->bgt_lock)) { - lprintf(fatal, "could not destroy bgt_lock: %s!\n", strerror(errno)); + err_code = pthread_mutex_destroy(&cf->bgt_lock); + if (err_code) { + lprintf(fatal, "could not destroy bgt_lock: %d, %s!\n", err_code, + strerror(err_code)); } - if (pthread_mutexattr_destroy(&cf->bgt_lock_attr)) { - lprintf(fatal, "could not destroy bgt_lock_attr: %s!\n", strerror(errno)); + err_code = pthread_mutexattr_destroy(&cf->bgt_lock_attr); + if (err_code) { + lprintf(fatal, "could not destroy bgt_lock_attr: %d, %s!\n", err_code, + strerror(err_code)); } if (cf->path) {