tpl_wayland_egl_thread: Modified the gsource to validate before the event is processed. 63/135163/4
authorjoonbum.ko <joonbum.ko@samsung.com>
Wed, 24 May 2017 05:27:12 +0000 (14:27 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 22 Jun 2017 08:55:13 +0000 (08:55 +0000)
 - In a short period of time, gsource can be destroyed.
 - So added exception handling syntax to process event handling only when gsource is valid.

Change-Id: I719a7b988a73b44df846b2318b3e96544fb3dea5
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 1a0f67c..bfc87d2 100644 (file)
@@ -261,6 +261,11 @@ _twe_thread_wl_disp_check(GSource *source)
 {
        twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source;
 
+       if (g_source_is_destroyed(source)) {
+               TPL_ERR("display source(%p) already destroyed.", source);
+               return FALSE;
+       }
+
        if (disp_source->gfd.revents & G_IO_IN) {
                TPL_LOG_T("WL_EGL", "read_events| gsource(%p) wl_display(%p)",
                                  source, disp_source->disp);
@@ -282,6 +287,11 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer date)
 {
        twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source;
 
+       if (g_source_is_destroyed(source)) {
+               TPL_ERR("display source(%p) already destroyed.", source);
+               return G_SOURCE_REMOVE;
+       }
+
        if (disp_source->gfd.revents & G_IO_IN) {
                TPL_LOG_T("WL_EGL", "dispatch| gsource(%p) wl_display(%p)",
                                  disp_source, disp_source->disp);
@@ -935,6 +945,11 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer date)
        twe_wl_surf_source *wl_surf_source = (twe_wl_surf_source *)source;
        GIOCondition cond;
 
+       if (g_source_is_destroyed(source)) {
+               TPL_ERR("surface source(%p) already destroyed.", source);
+               return G_SOURCE_REMOVE;
+       }
+
        cond = g_source_query_unix_fd(source, wl_surf_source->tag);
 
        if (cond & G_IO_IN) {