Fix race in g_cancellable_cancel()

We need to check priv->cancelled after taking the lock. Previously we
only checked it just before taking the lock, which left a small chance
for a race.
This commit is contained in:
Benjamin Otte 2010-03-26 20:37:09 +01:00 committed by Ryan Lortie
parent 5527a2ac2c
commit e7763678b5

View File

@ -622,6 +622,11 @@ g_cancellable_cancel (GCancellable *cancellable)
priv = cancellable->priv;
G_LOCK(cancellable);
if (priv->cancelled)
{
G_UNLOCK (cancellable);
return;
}
priv->cancelled = TRUE;
priv->cancelled_running = TRUE;