summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2009-05-27 12:01:14 -0400
committerMatthias Clasen <mclasen@redhat.com>2009-05-29 01:18:56 -0400
commit1f32eb927e2b404d4a697fa55282425ccb4d1784 (patch)
tree4d637d009810f34e56fdef90389f9baf0bc3a572
parent91e8f21c938fa7d0388f59cd229427996c128b90 (diff)
downloadglib-1f32eb927e2b404d4a697fa55282425ccb4d1784.tar.gz
Fix a locking problem in g_main_context_iterate()
We failed to ensure that the context is locked on every exit of the function. This fixes bug 583324.
-rw-r--r--glib/gmain.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/glib/gmain.c b/glib/gmain.c
index 17866c7e3..331c0a86b 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -2382,33 +2382,30 @@ g_main_context_iterate (GMainContext *context,
gboolean some_ready;
gint nfds, allocated_nfds;
GPollFD *fds = NULL;
-
+
UNLOCK_CONTEXT (context);
#ifdef G_THREADS_ENABLED
if (!g_main_context_acquire (context))
{
gboolean got_ownership;
-
+
+ LOCK_CONTEXT (context);
+
g_return_val_if_fail (g_thread_supported (), FALSE);
if (!block)
return FALSE;
- LOCK_CONTEXT (context);
-
if (!context->cond)
context->cond = g_cond_new ();
-
+
got_ownership = g_main_context_wait (context,
context->cond,
g_static_mutex_get_mutex (&context->mutex));
if (!got_ownership)
- {
- UNLOCK_CONTEXT (context);
- return FALSE;
- }
+ return FALSE;
}
else
LOCK_CONTEXT (context);