fix ecore-glib reentrance
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 22 Feb 2010 20:09:03 +0000 (20:09 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 22 Feb 2010 20:09:03 +0000 (20:09 +0000)
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

index 8360220..4e66bd7 100644 (file)
@@ -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 {