diff options
author | David Zeuthen <zeuthen@gmail.com> | 2013-01-09 14:22:20 -0500 |
---|---|---|
committer | David Zeuthen <zeuthen@gmail.com> | 2013-01-09 14:33:52 -0500 |
commit | 85ae5715fc05579f6c1b5424bb5ebbb183265eae (patch) | |
tree | c51495cfc46a3b4c683b2b3746d82fc03ba434b4 /src | |
parent | d6de13e12379826af8ca9355a32da48707b9831f (diff) | |
download | polkit-85ae5715fc05579f6c1b5424bb5ebbb183265eae.tar.gz |
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@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/polkitbackend/polkitbackendjsauthority.c | 9 |
1 files changed, 5 insertions, 4 deletions
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); |