[vlc-commits] commit: Win32: implement variable cleanup more similar to POSIX... ( =?UTF-8?Q?R=C3=A9mi=20Denis=2DCourmont=20?=)
git at videolan.org
git at videolan.org
Tue Nov 23 22:46:43 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 23 23:36:17 2010 +0200| [ae79d25dac4e2067530dd375369ddc08c39900ed] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ae79d25dac4e2067530dd375369ddc08c39900ed
---
src/win32/thread.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 8552ea7..9bcc645 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -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);
}
More information about the vlc-commits
mailing list