Fixed the deadlock issue 35/175435/1
authorInHong Han <inhong1.han@samsung.com>
Mon, 9 Apr 2018 10:52:31 +0000 (19:52 +0900)
committerInHong Han <inhong1.han@samsung.com>
Tue, 10 Apr 2018 07:42:44 +0000 (16:42 +0900)
The wl_display_roundtrip() uses the default queue of display.
Calling wl_display_roundtrip() from other thread may cause deadlock issue
because the done event has not been delivered.

Change-Id: I0991e431d100d027680dbf2234fad77a1702d903

ism/extras/wayland_immodule/wayland_imcontext.c

index ac6df2d..97a0f6b 100644 (file)
@@ -3332,9 +3332,11 @@ wayland_im_context_filter_event(Ecore_IMF_Context    *ctx,
             struct wl_display *display = NULL;
             if (wl2_display)
                 display = ecore_wl2_display_get(wl2_display);
+            struct wl_event_queue *queue = wl_display_create_queue(display);
 
-            if (display) {
-                while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND && _focused_ctx == ctx && wl_display_roundtrip(display) != -1) {
+            if (display && queue) {
+                while (ecore_time_get() - start_time < WAIT_FOR_FILTER_DONE_SECOND && _focused_ctx == ctx && wl_display_roundtrip_queue(display, queue) != -1) {
+                    wl_display_dispatch_pending(display);
                     if (imcontext->last_key_event_filter.serial == serial) {
                         ret = imcontext->last_key_event_filter.state;
                         break;
@@ -3342,6 +3344,9 @@ wayland_im_context_filter_event(Ecore_IMF_Context    *ctx,
                         break;
                 }
             }
+
+            if (queue)
+                wl_event_queue_destroy(queue);
             LOGD ("elapsed : %.3f ms, serial (last, require) : (%d, %d)", (ecore_time_get() - start_time)*1000, imcontext->last_key_event_filter.serial, serial);
         } while (0);