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.
This commit is contained in:
Matthias Clasen 2009-05-27 12:01:14 -04:00
parent 209a662c2f
commit 00151ec0e1

View File

@ -2382,33 +2382,30 @@ g_main_context_iterate (GMainContext *context,
gboolean some_ready; gboolean some_ready;
gint nfds, allocated_nfds; gint nfds, allocated_nfds;
GPollFD *fds = NULL; GPollFD *fds = NULL;
UNLOCK_CONTEXT (context); UNLOCK_CONTEXT (context);
#ifdef G_THREADS_ENABLED #ifdef G_THREADS_ENABLED
if (!g_main_context_acquire (context)) if (!g_main_context_acquire (context))
{ {
gboolean got_ownership; gboolean got_ownership;
LOCK_CONTEXT (context);
g_return_val_if_fail (g_thread_supported (), FALSE); g_return_val_if_fail (g_thread_supported (), FALSE);
if (!block) if (!block)
return FALSE; return FALSE;
LOCK_CONTEXT (context);
if (!context->cond) if (!context->cond)
context->cond = g_cond_new (); context->cond = g_cond_new ();
got_ownership = g_main_context_wait (context, got_ownership = g_main_context_wait (context,
context->cond, context->cond,
g_static_mutex_get_mutex (&context->mutex)); g_static_mutex_get_mutex (&context->mutex));
if (!got_ownership) if (!got_ownership)
{ return FALSE;
UNLOCK_CONTEXT (context);
return FALSE;
}
} }
else else
LOCK_CONTEXT (context); LOCK_CONTEXT (context);