From 8796d3d59aedaf6cf5c36c3c40f3234108b12a6e Mon Sep 17 00:00:00 2001 From: barbieri Date: Mon, 22 Feb 2010 20:09:03 +0000 Subject: [PATCH] fix ecore-glib reentrance if using ecore_main_loop_begin() multiple times (reentrant/recursive) with glib doing threads, then it would deadlock since the same thread would get the lock it already have. multiple ecore_main_loop_begin() is required to implement WebKit's alert/confirm/prompt dialogs since there is no async reply with callbacks, rather one must return the value. By: Lucas de Marchi git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@46361 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore/ecore_glib.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/ecore/ecore_glib.c b/src/lib/ecore/ecore_glib.c index 8360220..4e66bd7 100644 --- a/src/lib/ecore/ecore_glib.c +++ b/src/lib/ecore/ecore_glib.c @@ -167,14 +167,11 @@ _ecore_glib_select__locked(GMainContext *ctx, int ecore_fds, fd_set *rfds, fd_se static int _ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *ecore_timeout) { - static GStaticMutex lock = G_STATIC_MUTEX_INIT; - static GMutex *mutex = NULL; + GStaticMutex lock = G_STATIC_MUTEX_INIT; + GMutex *mutex = g_static_mutex_get_mutex(&lock); GMainContext *ctx = g_main_context_default(); int ret; - if (!mutex) - mutex = g_static_mutex_get_mutex(&lock); - if (g_main_context_acquire(ctx)) g_mutex_lock(mutex); else { -- 2.7.4