From 4110d2795a9edd809021b6128c793b8f73d40675 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Wed, 17 Jun 2026 14:53:51 +0200 Subject: [PATCH] windows: Avoid unnecessarily locking the global thread lock when removing TLS Holding the lock could potentially cause a deadlock depending the behavior of the called cleanup functions. The TLS removal happens in the context of the respective thread, so no locking is necessary. Looks like removing these lines was missed when the referenced commit partly reverted 204098a75202 ("thread-value: Immediately cleanup all Windows TLS values on destroy"), which added the locking originally. Fixes: 23750961d5b9 ("thread-value: Defer cleanup handling to thread termination on Windows") --- src/libstrongswan/threading/windows/thread.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libstrongswan/threading/windows/thread.c b/src/libstrongswan/threading/windows/thread.c index cb1b0c54d..d2a1e83d1 100644 --- a/src/libstrongswan/threading/windows/thread.c +++ b/src/libstrongswan/threading/windows/thread.c @@ -238,9 +238,7 @@ void* thread_tls_remove(void *key) thread = get_current_thread(); old = set_leak_detective(FALSE); - threads_lock->lock(threads_lock); value = thread->tls->remove(thread->tls, key); - threads_lock->unlock(threads_lock); set_leak_detective(old); return value; @@ -274,7 +272,6 @@ static void docleanup(private_thread_t *this) set_leak_detective(FALSE); } - threads_lock->lock(threads_lock); enumerator = this->tls->create_enumerator(this->tls); while (enumerator->enumerate(enumerator, NULL, &tls)) { @@ -285,7 +282,6 @@ static void docleanup(private_thread_t *this) set_leak_detective(FALSE); } enumerator->destroy(enumerator); - threads_lock->unlock(threads_lock); set_leak_detective(old); }