Skip to content

Commit

Permalink
fix error message at destroying locks
Browse files Browse the repository at this point in the history
  • Loading branch information
fangfufu committed Nov 24, 2024
1 parent 0558a85 commit 614b9d8
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 614b9d8

Please sign in to comment.