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

Fix logic.

We don't need an explicit barrier when setting initialized from
vlc_mutex_init(). The caller shall synchronize memory after
vlc_mutex_init() from any thread calling vlc_mutex_lock() anyway,
since locking an unitialized non-static mutex is undefined.
parent f10b7234
...@@ -205,6 +205,7 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex ) ...@@ -205,6 +205,7 @@ int vlc_mutex_init( vlc_mutex_t *p_mutex )
/* This creates a recursive mutex. This is OK as fast mutexes have /* This creates a recursive mutex. This is OK as fast mutexes have
* no defined behavior in case of recursive locking. */ * no defined behavior in case of recursive locking. */
InitializeCriticalSection (&p_mutex->mutex); InitializeCriticalSection (&p_mutex->mutex);
p_mutex->initialized = 1;
return 0; return 0;
#endif #endif
...@@ -231,8 +232,7 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex ) ...@@ -231,8 +232,7 @@ int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
#elif defined( WIN32 ) #elif defined( WIN32 )
InitializeCriticalSection( &p_mutex->mutex ); InitializeCriticalSection( &p_mutex->mutex );
InterlockedIncrement (&p_mutex->initialized); p_mutex->initialized = 1;
barrier ();
return 0; return 0;
#endif #endif
...@@ -252,7 +252,7 @@ void vlc_mutex_destroy (vlc_mutex_t *p_mutex) ...@@ -252,7 +252,7 @@ void vlc_mutex_destroy (vlc_mutex_t *p_mutex)
VLC_THREAD_ASSERT ("destroying mutex"); VLC_THREAD_ASSERT ("destroying mutex");
#elif defined( WIN32 ) #elif defined( WIN32 )
InterlockedDecrement (&p_mutex->initialized); assert (p_mutex->initialized);
DeleteCriticalSection (&p_mutex->mutex); DeleteCriticalSection (&p_mutex->mutex);
#endif #endif
......
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