Initialize wl_egl_buffer->waiting_source in mutex protection. 71/267971/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 14 Dec 2021 04:35:06 +0000 (13:35 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 14 Dec 2021 04:35:09 +0000 (13:35 +0900)
 - the buffer_clear() of the main thread could occur thread conflict.
 - the pointer wl_egl_buffer->waiting_source must be protected.

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

index 6fcce36..1a96557 100755 (executable)
@@ -2731,6 +2731,15 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
 
        tpl_gmutex_lock(&wl_egl_buffer->mutex);
        wl_egl_buffer->status = WAITING_VBLANK;
+
+       TPL_DEBUG("[FINALIZE] wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)",
+                         wl_egl_buffer, wl_egl_buffer->waiting_source,
+                         wl_egl_buffer->acquire_fence_fd);
+
+       close(wl_egl_buffer->acquire_fence_fd);
+       wl_egl_buffer->acquire_fence_fd = -1;
+       wl_egl_buffer->waiting_source = NULL;
+
        tpl_gmutex_unlock(&wl_egl_buffer->mutex);
 
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
@@ -2749,16 +2758,7 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
 static void
 __thread_func_waiting_source_finalize(tpl_gsource *gsource)
 {
-       tpl_wl_egl_buffer_t *wl_egl_buffer      =
-               (tpl_wl_egl_buffer_t *)tpl_gsource_get_data(gsource);
-
-       TPL_DEBUG("[FINALIZE] wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)",
-                         wl_egl_buffer, wl_egl_buffer->waiting_source,
-                         wl_egl_buffer->acquire_fence_fd);
-
-       close(wl_egl_buffer->acquire_fence_fd);
-       wl_egl_buffer->acquire_fence_fd = -1;
-       wl_egl_buffer->waiting_source = NULL;
+       TPL_IGNORE(gsource);
 }
 
 static tpl_gsource_functions buffer_funcs = {