[glib/glib-2-24] Fix race in g_cancellable_cancel()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-24] Fix race in g_cancellable_cancel()
- Date: Mon, 3 May 2010 00:58:32 +0000 (UTC)
commit e61a90b9eea2eac924f66c1d137381daff6cedfd
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.
(cherry picked from commit e7763678b56e3be073cc55d707a6e92fc2055ee0)
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]