From b8f94c7e5e3bc4fd7b7d694118ccda35bd446c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Tue, 9 Jan 2024 12:17:52 -0500 Subject: [PATCH] Eliminate LOR introduced in previous commit. Since lock_ssl_cert() is a reader lock, there shouldn't be a whole lot of contention on aquiring it anyway, and we can thundering herd our way out of it when it clears. --- src/sbbs3/ssl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sbbs3/ssl.c b/src/sbbs3/ssl.c index 1eafacdd43..e6b81825ee 100644 --- a/src/sbbs3/ssl.c +++ b/src/sbbs3/ssl.c @@ -558,6 +558,7 @@ int destroy_session(int (*lprintf)(int level, const char* fmt, ...), CRYPT_SESSI struct cert_list *psess = NULL; int ret = CRYPT_ERROR_NOTFOUND; + lock_ssl_cert(); pthread_mutex_lock(&ssl_cert_list_mutex); sess = sess_list; while (sess != NULL) { @@ -568,16 +569,13 @@ int destroy_session(int (*lprintf)(int level, const char* fmt, ...), CRYPT_SESSI else { psess->next = sess->next; } - lock_ssl_cert(); if (sess->epoch == cert_epoch) { - unlock_ssl_cert(lprintf); sess->sess = -1; sess->next = cert_list; cert_list = sess; ret = cryptDestroySession(csess); } else { - unlock_ssl_cert(lprintf); // TODO: Failure here isn't logged cryptDestroyContext(sess->cert); free(sess); @@ -589,6 +587,7 @@ int destroy_session(int (*lprintf)(int level, const char* fmt, ...), CRYPT_SESSI sess = sess->next; } pthread_mutex_unlock(&ssl_cert_list_mutex); + unlock_ssl_cert(lprintf); if (ret == CRYPT_ERROR_NOTFOUND) ret = cryptDestroySession(csess); return ret; -- GitLab