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 204098a752 ("thread-value: Immediately cleanup all
Windows TLS values on destroy"), which added the locking originally.

Fixes: 23750961d5 ("thread-value: Defer cleanup handling to thread termination on Windows")
This commit is contained in:
Tobias Brunner
2026-07-23 10:26:08 +02:00
parent 097c7a1e0a
commit 4110d2795a
@@ -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);
}