[gjs] context: always set GC callback



commit 7ab5e0e4cc2ddb95f408316607ad96dfc94a3e7b
Author: Ray Strode <rstrode redhat com>
Date:   Tue Apr 2 16:31:14 2013 -0400

    context: always set GC callback
    
    Right now we only set the GC callback if gc-notifications are enabled.
    
    This commit makes us always set the callback as prep work toward fixing a GC
    deadlock.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670200

 gjs/context.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/gjs/context.c b/gjs/context.c
index fd122ee..a77c678 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -665,8 +665,7 @@ gjs_context_constructor (GType                  type,
 
     js_context->profiler = gjs_profiler_new(js_context->runtime);
 
-    if (js_context->gc_notifications_enabled)
-        JS_SetGCCallback(js_context->runtime, gjs_on_context_gc);
+    JS_SetGCCallback(js_context->runtime, gjs_on_context_gc);
 
     JS_EndRequest(js_context->context);
 
@@ -895,13 +894,20 @@ gjs_on_context_gc (JSRuntime *rt,
     JSContext *context = JS_GetRuntimePrivate(rt);
     GjsContext *gjs_context = JS_GetContextPrivate(context);
 
-    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);
+    switch (status) {
+        case JSGC_END:
+            if (gjs_context->gc_notifications_enabled) {
+                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);
+            }
+        break;
+
+        default:
+        break;
     }
-    
+
     return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]