glib:remove self-join deadlock 68/89768/1 submit/tizen/20160927.041657
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 27 Sep 2016 02:33:36 +0000 (11:33 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 27 Sep 2016 02:33:47 +0000 (11:33 +0900)
Change-Id: Ia9fffe62c90d596efe29929c50e835d4a93fac52
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
gio/gkdbus.c

index e2715c2..41435be 100755 (executable)
@@ -587,6 +587,16 @@ _g_kdbus_quit_loop (gpointer loop)
   return FALSE;
 }
 
+static gboolean
+_g_kdbus_thread_end (gpointer thread)
+{
+  GThread *gthread = (GThread *)thread;
+
+  g_thread_join (gthread);
+
+  return FALSE;
+}
+
 /*
  * _g_kdbus_close
  */
@@ -605,7 +615,11 @@ _g_kdbus_close (GKDBusWorker *worker)
 
   g_main_loop_unref (worker->loop);
 
-  g_thread_join (worker->thread);
+  if (g_thread_self() == worker->thread)
+    g_main_context_invoke (NULL, _g_kdbus_thread_end, worker->thread);
+  else
+    g_thread_join (worker->thread);
+
   worker->thread = NULL;
 
   close (worker->fd);
@@ -615,7 +629,6 @@ _g_kdbus_close (GKDBusWorker *worker)
   return TRUE;
 }
 
-
 /*
  * _g_kdbus_is_closed
  */