PolicyKit: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Wed Jan 9 11:34:35 PST 2013


 src/polkitbackend/polkitbackendjsauthority.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 85ae5715fc05579f6c1b5424bb5ebbb183265eae
Author: David Zeuthen <zeuthen at gmail.com>
Date:   Wed Jan 9 14:22:20 2013 -0500

    Use mutex and condition variables properly
    
    This was pointed out in bug 57325.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=57325
    
    Signed-off-by: David Zeuthen <zeuthen at gmail.com>

diff --git a/src/polkitbackend/polkitbackendjsauthority.c b/src/polkitbackend/polkitbackendjsauthority.c
index e4aa46b..28361c3 100644
--- a/src/polkitbackend/polkitbackendjsauthority.c
+++ b/src/polkitbackend/polkitbackendjsauthority.c
@@ -622,9 +622,10 @@ polkit_backend_js_authority_constructed (GObject *object)
                                                          authority);
 
   /* wait for runaway_killer_thread to set up its GMainContext */
-  g_cond_wait (&authority->priv->rkt_init_cond, &authority->priv->rkt_init_mutex);
+  g_mutex_lock (&authority->priv->rkt_init_mutex);
+  while (authority->priv->rkt_context == NULL)
+    g_cond_wait (&authority->priv->rkt_init_cond, &authority->priv->rkt_init_mutex);
   g_mutex_unlock (&authority->priv->rkt_init_mutex);
-  g_assert (authority->priv->rkt_context != NULL);
 
   setup_file_monitors (authority);
   load_scripts (authority);
@@ -1011,13 +1012,13 @@ runaway_killer_thread_func (gpointer user_data)
 {
   PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (user_data);
 
+  g_mutex_lock (&authority->priv->rkt_init_mutex);
+
   authority->priv->rkt_context = g_main_context_new ();
   authority->priv->rkt_loop = g_main_loop_new (authority->priv->rkt_context, FALSE);
-
   g_main_context_push_thread_default (authority->priv->rkt_context);
 
   /* Signal the main thread that we're done constructing */
-  g_mutex_lock (&authority->priv->rkt_init_mutex);
   g_cond_signal (&authority->priv->rkt_init_cond);
   g_mutex_unlock (&authority->priv->rkt_init_mutex);
 


More information about the hal-commit mailing list