devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3ebdfd8779d53c032649f52a69f0bc5b77999861

commit 3ebdfd8779d53c032649f52a69f0bc5b77999861
Author: Boram Park <boram1288.p...@samsung.com>
Date:   Wed Sep 23 09:22:29 2015 -0400

    ecore_wl: abort if wl_display_dispatch returns negative value
    
    Summary:
    If the connection between server and client has problems, 
wl_display_dispatch
    an return negative value. i.e. when enlightenment has been killed 
accidently.
    In this case, app can enter into infinite loop.
    
    Signed-off-by: Boram Park <boram1288.p...@samsung.com>
    
    Reviewers: stefan_schmidt, zmike, gwanglim, raster, devilhorns
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D3077
---
 src/lib/ecore_wayland/ecore_wl.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index 13758c6..b9ad854 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -121,8 +121,18 @@ _ecore_wl_init_callback(void *data, struct wl_callback 
*callback, uint32_t seria
 static void
 _ecore_wl_init_wait(void)
 {
+   int ret;
    while (!_ecore_wl_disp->init_done)
-     wl_display_dispatch(_ecore_wl_disp->wl.display);
+     {
+        ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
+        if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
+          {
+             /* raise exit signal */
+             ERR("Wayland socket error: %s", strerror(errno));
+             abort();
+             break;
+          }
+     }
 }
 
 EAPI int
@@ -262,10 +272,20 @@ ecore_wl_flush(void)
 EAPI void
 ecore_wl_sync(void)
 {
+   int ret;
    if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
    _ecore_wl_sync_wait(_ecore_wl_disp);
    while (_ecore_wl_disp->sync_ref_count > 0)
-     wl_display_dispatch(_ecore_wl_disp->wl.display);
+     {
+        ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
+        if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
+          {
+             /* raise exit signal */
+             ERR("Wayland socket error: %s", strerror(errno));
+             abort();
+             break;
+          }
+     }
 }
 
 EAPI struct wl_shm *
@@ -407,9 +427,18 @@ ecore_wl_dpi_get(void)
 EAPI void
 ecore_wl_display_iterate(void)
 {
+   int ret;
    if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
    if (!_ecore_wl_server_mode)
-     wl_display_dispatch(_ecore_wl_disp->wl.display);
+     {
+        ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
+        if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
+          {
+             /* raise exit signal */
+             ERR("Wayland socket error: %s", strerror(errno));
+             abort();
+          }
+     }
 }
 
 /* @since 1.8 */

-- 


Reply via email to