mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
windows XP threads: fix hilariously obvious race
I tried to do a double-checked lock without the double check. Rodrigo Rivas Costa caught the problem and suggested the (obviously correct) fix. https://bugzilla.gnome.org/show_bug.cgi?id=666296
This commit is contained in:
parent
fcc9902e98
commit
11015f1652
@ -611,6 +611,10 @@ g_thread_xp_get_srwlock (GThreadSRWLock * volatile *lock)
|
|||||||
{
|
{
|
||||||
EnterCriticalSection (&g_thread_xp_lock);
|
EnterCriticalSection (&g_thread_xp_lock);
|
||||||
|
|
||||||
|
/* Check again */
|
||||||
|
result = *lock;
|
||||||
|
if (result == NULL)
|
||||||
|
{
|
||||||
result = malloc (sizeof (GThreadSRWLock));
|
result = malloc (sizeof (GThreadSRWLock));
|
||||||
|
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
@ -620,6 +624,7 @@ g_thread_xp_get_srwlock (GThreadSRWLock * volatile *lock)
|
|||||||
result->writer_locked = FALSE;
|
result->writer_locked = FALSE;
|
||||||
result->ever_shared = FALSE;
|
result->ever_shared = FALSE;
|
||||||
*lock = result;
|
*lock = result;
|
||||||
|
}
|
||||||
|
|
||||||
LeaveCriticalSection (&g_thread_xp_lock);
|
LeaveCriticalSection (&g_thread_xp_lock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user