[glib] Fix race in g_cancellable_cancel()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix race in g_cancellable_cancel()
- Date: Mon, 29 Mar 2010 18:01:03 +0000 (UTC)
commit e7763678b56e3be073cc55d707a6e92fc2055ee0
Author: Benjamin Otte <otte redhat com>
Date: Fri Mar 26 20:37:09 2010 +0100
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.
gio/gcancellable.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 2d600c9..32d01ae 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]