Commit ae79d25d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: implement variable cleanup more similar to POSIX...

...and less prone to deadlocks. This restarts until all keys are NULL,
in case cleaning up reset one key back to a non-NULL value.
There is still a slight difference with POSIX still. POSIX will restarts
only after all destructors have been invoked, not after the first one.
parent ca960c2e
......@@ -517,13 +517,19 @@ static void vlc_threadvar_cleanup (void)
{
vlc_threadvar_t key;
retry:
/* TODO: use RW lock or something similar */
vlc_mutex_lock (&super_mutex);
for (key = vlc_threadvar_last; key != NULL; key = key->prev)
{
void *value = vlc_threadvar_get (key);
if (value != NULL)
{
vlc_mutex_unlock (&super_mutex);
vlc_threadvar_set (key, NULL);
key->destroy (value);
goto retry;
}
}
vlc_mutex_unlock (&super_mutex);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment