Skip to content

Commit 614b9d8

Browse files
committed
fix error message at destroying locks
1 parent 0558a85 commit 614b9d8

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/cache.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,20 +552,30 @@ static Cache *Cache_alloc(void)
552552
*/
553553
static void Cache_free(Cache *cf)
554554
{
555-
if (pthread_mutex_destroy(&cf->seek_lock)) {
556-
lprintf(fatal, "could not destroy seek_lock: %s!\n", strerror(errno));
555+
int err_code = 0;
556+
557+
err_code = pthread_mutex_destroy(&cf->seek_lock);
558+
if (err_code) {
559+
lprintf(fatal, "could not destroy seek_lock: %d, %s!\n", err_code,
560+
strerror(err_code));
557561
}
558562

559-
if (pthread_mutex_destroy(&cf->w_lock)) {
560-
lprintf(fatal, "could not destroy w_lock: %s!\n", strerror(errno));
563+
err_code = pthread_mutex_destroy(&cf->w_lock);
564+
if (err_code) {
565+
lprintf(fatal, "could not destroy w_lock: %d, %s!\n", err_code,
566+
strerror(err_code));
561567
}
562568

563-
if (pthread_mutex_destroy(&cf->bgt_lock)) {
564-
lprintf(fatal, "could not destroy bgt_lock: %s!\n", strerror(errno));
569+
err_code = pthread_mutex_destroy(&cf->bgt_lock);
570+
if (err_code) {
571+
lprintf(fatal, "could not destroy bgt_lock: %d, %s!\n", err_code,
572+
strerror(err_code));
565573
}
566574

567-
if (pthread_mutexattr_destroy(&cf->bgt_lock_attr)) {
568-
lprintf(fatal, "could not destroy bgt_lock_attr: %s!\n", strerror(errno));
575+
err_code = pthread_mutexattr_destroy(&cf->bgt_lock_attr);
576+
if (err_code) {
577+
lprintf(fatal, "could not destroy bgt_lock_attr: %d, %s!\n", err_code,
578+
strerror(err_code));
569579
}
570580

571581
if (cf->path) {

0 commit comments

Comments
 (0)