wl_egl: make sure the destruction of gsource is complete 78/319878/2
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 1 Nov 2024 05:49:27 +0000 (14:49 +0900)
committerTaeHyeon Jeong <thyeon.jeong@samsung.com>
Tue, 5 Nov 2024 08:05:09 +0000 (17:05 +0900)
 - In case of wayland protocol error, gsource is deleted but
  there is a problem where display_fini stops at cond_wait
  because disp_source is not initialized to null in finalize.

Change-Id: I0a1fd4c850da5d843dd674d54364936e749b6950
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 03b1cd66d3f2ec7e534545bdf6673a8e730039b6..b4886ff0d9e36f9a1623cb1ccf722a3d2df87143 100755 (executable)
@@ -530,8 +530,6 @@ __thread_func_tdm_dispatch(tpl_gsource *gsource, uint64_t message)
 
                tpl_gsource_destroy(gsource, TPL_FALSE);
 
-               wl_egl_display->tdm.tdm_source = NULL;
-
                return TPL_FALSE;
        }
 
@@ -561,12 +559,12 @@ __thread_func_tdm_finalize(tpl_gsource *gsource)
                tdm_client_destroy(wl_egl_display->tdm.tdm_client);
                wl_egl_display->tdm.tdm_client = NULL;
                wl_egl_display->tdm.tdm_display_fd = -1;
-               wl_egl_display->tdm.tdm_source = NULL;
        }
 
        wl_egl_display->use_wait_vblank = TPL_FALSE;
        wl_egl_display->tdm.tdm_initialized = TPL_FALSE;
        wl_egl_display->tdm.gsource_finalized = TPL_TRUE;
+       wl_egl_display->tdm.tdm_source = NULL;
 
        tpl_gcond_signal(&wl_egl_display->tdm.tdm_cond);
        tpl_gmutex_unlock(&wl_egl_display->tdm.tdm_mutex);
@@ -876,7 +874,6 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display)
        wl_event_queue_destroy(wl_egl_display->ev_queue);
 
        wl_egl_display->ev_queue = NULL;
-       wl_egl_display->wl_initialized = TPL_FALSE;
 
        TPL_INFO("[DISPLAY_FINI]", "wl_egl_display(%p) wl_display(%p)",
                         wl_egl_display, wl_egl_display->wl_display);
@@ -1004,7 +1001,9 @@ __thread_func_disp_finalize(tpl_gsource *gsource)
        if (wl_egl_display->wl_initialized)
                _thread_wl_display_fini(wl_egl_display);
 
+       wl_egl_display->wl_initialized = TPL_FALSE;
        wl_egl_display->gsource_finalized = TPL_TRUE;
+       wl_egl_display->disp_source = NULL;
 
        tpl_gcond_signal(&wl_egl_display->disp_cond);
        tpl_gmutex_unlock(&wl_egl_display->disp_mutex);
@@ -1197,7 +1196,6 @@ __tpl_wl_egl_display_fini(tpl_display_t *display)
                        while (!wl_egl_display->tdm.gsource_finalized) {
                                tpl_gcond_wait(&wl_egl_display->tdm.tdm_cond, &wl_egl_display->tdm.tdm_mutex);
                        }
-                       wl_egl_display->tdm.tdm_source = NULL;
                        tpl_gmutex_unlock(&wl_egl_display->tdm.tdm_mutex);
                }
 
@@ -1213,7 +1211,6 @@ __tpl_wl_egl_display_fini(tpl_display_t *display)
                        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);
                }
 
@@ -1880,6 +1877,7 @@ __thread_func_surf_finalize(tpl_gsource *gsource)
        _thread_wl_egl_surface_fini(wl_egl_surface);
 
        wl_egl_surface->gsource_finalized = TPL_TRUE;
+       wl_egl_surface->surf_source = NULL;
 
        tpl_gcond_signal(&wl_egl_surface->surf_cond);
        tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
@@ -2500,7 +2498,6 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface)
                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);