[gjs/gnome-3-8] context: lock access to GC idle
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-8] context: lock access to GC idle
- Date: Fri, 5 Apr 2013 22:57:48 +0000 (UTC)
commit 24da262909eadd8a0e2ee6eeb5b51d8b17ed9440
Author: Ray Strode <rstrode redhat com>
Date: Thu Apr 4 17:08:36 2013 -0400
context: lock access to GC idle
There's a small race where the GC notification idle id might get
zeroed before the idle runs, if the GC callback is run from a
non-main thread.
That means there's the potential for the GC notification idle to
get dispatched after the context is finalized.
This commit fixes that by protecting access to the idle id with
a lock.
https://bugzilla.gnome.org/show_bug.cgi?id=670200
(cherry picked from commit d112a7166ae0b60f5f1bf7d7f4b853fda2a6d211)
gjs/context.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gjs/context.c b/gjs/context.c
index cedce2c..a392645 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -98,6 +98,7 @@ enum {
};
+static GMutex gc_idle_lock;
static GMutex contexts_lock;
static GList *all_contexts = NULL;
@@ -878,8 +879,10 @@ gjs_context_idle_emit_gc (gpointer data)
{
GjsContext *gjs_context = data;
+ g_mutex_lock(&gc_idle_lock);
gjs_context->idle_emit_gc_id = 0;
-
+ g_mutex_unlock(&gc_idle_lock);
+
g_signal_emit (gjs_context, signals[SIGNAL_GC], 0);
return FALSE;
@@ -892,8 +895,10 @@ gjs_on_context_gc (JSContext *cx,
GjsContext *gjs_context = JS_GetContextPrivate(cx);
if (status == JSGC_END) {
+ g_mutex_lock(&gc_idle_lock);
if (gjs_context->idle_emit_gc_id == 0)
gjs_context->idle_emit_gc_id = g_idle_add (gjs_context_idle_emit_gc, gjs_context);
+ g_mutex_unlock(&gc_idle_lock);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]