ecore_wl2: correct cb_pre_handle_data and cb_awake callbacks 67/196667/1
authorSung-Jin Park <sj76.park@samsung.com>
Thu, 3 Jan 2019 08:45:37 +0000 (17:45 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 3 Jan 2019 09:05:22 +0000 (18:05 +0900)
Fix : cb_pre_handle_data()
When there are any events remain in wayland event list, they
are going to be dispatched through wl_display_dispatch_pending().
By the way, if there is any error set in last_error in ewd->wl.display,
wl_display_dispatch_pending() will be failed and we must return directly
, unless ewd->prepare_read will be set true, wl_display_read_events()
will be called in _ecore_wl_cb_awake(). Calling wl_display_read_events()
without wl_display_prepare_read() will cause a deadlock in multi-threaded
wayland client.

Fix : cb_awake()
When there is an error on wayland display socket fd, _ecore_wl_cb_wake()
will also be called. Now when a error comes to _ecore_wl_cb_awake(),
it'll cause to call wl_display_read_events()/wl_display_cancel_events().
Calling those APIs will cause a deadlock in multi-threaded wayland clients.
Thus, we must return directly.

Change-Id: I6165989104038ff3b8435d18891dea3f7f979ac6
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/lib/ecore_wl2/ecore_wl2_display.c

index 72b134b..ccbecb4 100644 (file)
@@ -1078,7 +1078,7 @@ _ecore_wl_cb_pre_handle_data(void *data, Ecore_Fd_Handler *hdl EINA_UNUSED)
         if (ret < 0)
           {
              ERR("Wayland Display Dispatch Pending Failed");
-             break;
+             return;
           }
      }
 
@@ -1099,6 +1099,13 @@ _ecore_wl_cb_awake(void *data)
 
    ewd->prepare_read = EINA_FALSE;
 
+   if (ecore_main_fd_handler_active_get(ewd->fd_hdl, ECORE_FD_ERROR))
+     {
+        ERR("[ecore_wl_cb_awake] Received error on wayland display fd");
+        wl_display_cancel_read(ewd->wl.display);
+        return;
+     }
+
    if (ecore_main_fd_handler_active_get(ewd->fd_hdl, ECORE_FD_READ))
      wl_display_read_events(ewd->wl.display);
    else