From e4becbae7c9f69ab4f0b932044f6a5b04921cf43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Sat, 20 Jan 2024 13:33:10 -0500 Subject: [PATCH] Add an ignored version of rwlock_destroy() for use when it there's really no useful way to recover from failure. --- src/sbbs3/ssl.c | 14 +++++++------- src/xpdev/rwlockwrap.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/sbbs3/ssl.c b/src/sbbs3/ssl.c index 29bc640921..9a1adba125 100644 --- a/src/sbbs3/ssl.c +++ b/src/sbbs3/ssl.c @@ -270,25 +270,25 @@ static void internal_do_cryptInit(void) if (!rwlock_init(&cert_epoch_lock)) return; if (!rwlock_init(&tls_cert_file_date_lock)) { - rwlock_destroy(&cert_epoch_lock); + rwlock_destroy_ign(&cert_epoch_lock); return; } if (pthread_mutex_init(&ssl_cert_list_mutex, NULL) != 0) { - rwlock_destroy(&tls_cert_file_date_lock); - rwlock_destroy(&cert_epoch_lock); + rwlock_destroy_ign(&tls_cert_file_date_lock); + rwlock_destroy_ign(&cert_epoch_lock); return; } if (pthread_mutex_init(&ssl_sess_list_mutex, NULL) != 0) { pthread_mutex_destroy(&ssl_cert_list_mutex); - rwlock_destroy(&tls_cert_file_date_lock); - rwlock_destroy(&cert_epoch_lock); + rwlock_destroy_ign(&tls_cert_file_date_lock); + rwlock_destroy_ign(&cert_epoch_lock); return; } if (pthread_mutex_init(&get_ssl_cert_mutex, NULL) != 0) { pthread_mutex_destroy(&ssl_sess_list_mutex); pthread_mutex_destroy(&ssl_cert_list_mutex); - rwlock_destroy(&tls_cert_file_date_lock); - rwlock_destroy(&cert_epoch_lock); + rwlock_destroy_ign(&tls_cert_file_date_lock); + rwlock_destroy_ign(&cert_epoch_lock); return; } diff --git a/src/xpdev/rwlockwrap.h b/src/xpdev/rwlockwrap.h index eb077a2717..bdfd4c58d7 100644 --- a/src/xpdev/rwlockwrap.h +++ b/src/xpdev/rwlockwrap.h @@ -13,6 +13,7 @@ typedef pthread_rwlock_t rwlock_t; #define rwlock_trywrlock(lock) (pthread_rwlock_trywrlock(lock) == 0) #define rwlock_unlock(lock) (pthread_rwlock_unlock(lock) == 0) #define rwlock_destroy(lock) (pthread_rwlock_destroy(lock) == 0) +#define rwlock_destroy_ign(lock) ((void)pthread_rwlock_destroy(lock)) #elif defined(_WIN32) -- GitLab