From: Joonbum Ko Date: Wed, 5 Oct 2022 01:57:23 +0000 (+0900) Subject: Add null checking before calling tpl_gsource_destroy. X-Git-Tag: accepted/tizen/unified/20221006.151841~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F282514%2F1;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Add null checking before calling tpl_gsource_destroy. Change-Id: I431f21b80215abeafc5ab6daa45778f617cc661a Signed-off-by: Joonbum Ko --- diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 487cf63..fb9286f 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -1035,19 +1035,21 @@ __tpl_wl_egl_display_fini(tpl_display_t *display) tpl_gmutex_unlock(&wl_egl_display->tdm.tdm_mutex); } - /* This is a protection to prevent problems that arise in unexpected situations - * that g_cond_wait cannot work normally. - * When calling tpl_gsource_destroy() with destroy_in_thread is TPL_TRUE, - * caller should use tpl_gcond_wait() in the loop with checking finalized flag - * */ - tpl_gmutex_lock(&wl_egl_display->disp_mutex); - // Send destroy mesage to thread - tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE); - while (wl_egl_display->disp_source && !wl_egl_display->gsource_finalized) { - tpl_gcond_wait(&wl_egl_display->disp_cond, &wl_egl_display->disp_mutex); + if (wl_egl_display->disp_source) { + tpl_gmutex_lock(&wl_egl_display->disp_mutex); + // Send destroy mesage to thread + tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE); + /* This is a protection to prevent problems that arise in unexpected situations + * that g_cond_wait cannot work normally. + * When calling tpl_gsource_destroy() with destroy_in_thread is TPL_TRUE, + * caller should use tpl_gcond_wait() in the loop with checking finalized flag + * */ + while (!wl_egl_display->gsource_finalized) { + tpl_gcond_wait(&wl_egl_display->disp_cond, &wl_egl_display->disp_mutex); + } + wl_egl_display->disp_source = NULL; + tpl_gmutex_unlock(&wl_egl_display->disp_mutex); } - wl_egl_display->disp_source = NULL; - tpl_gmutex_unlock(&wl_egl_display->disp_mutex); if (wl_egl_display->thread) { tpl_gthread_destroy(wl_egl_display->thread); @@ -2198,19 +2200,21 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface) _tpl_wl_egl_surface_buffer_clear(wl_egl_surface); - /* This is a protection to prevent problems that arise in unexpected situations - * that g_cond_wait cannot work normally. - * When calling tpl_gsource_destroy() with destroy_in_thread is TPL_TRUE, - * caller should use tpl_gcond_wait() in the loop with checking finalized flag - * */ - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - // Send destroy mesage to thread - tpl_gsource_destroy(wl_egl_surface->surf_source, TPL_TRUE); - while (wl_egl_surface->surf_source && !wl_egl_surface->gsource_finalized) { - tpl_gcond_wait(&wl_egl_surface->surf_cond, &wl_egl_surface->surf_mutex); + if (wl_egl_surface->surf_source) { + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + // Send destroy mesage to thread + tpl_gsource_destroy(wl_egl_surface->surf_source, TPL_TRUE); + /* This is a protection to prevent problems that arise in unexpected situations + * that g_cond_wait cannot work normally. + * When calling tpl_gsource_destroy() with destroy_in_thread is TPL_TRUE, + * caller should use tpl_gcond_wait() in the loop with checking finalized flag + * */ + while (!wl_egl_surface->gsource_finalized) { + tpl_gcond_wait(&wl_egl_surface->surf_cond, &wl_egl_surface->surf_mutex); + } + wl_egl_surface->surf_source = NULL; + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); } - wl_egl_surface->surf_source = NULL; - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); _print_buffer_lists(wl_egl_surface);