tpl_wayland_egl_thread:Added mutex lock to ensure thread safety 04/201504/1 accepted/tizen/5.0/unified/20190319.051325 submit/tizen_5.0/20190318.044201
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 15 Mar 2019 04:48:57 +0000 (13:48 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 15 Mar 2019 04:49:04 +0000 (13:49 +0900)
 - Previously it was unnecessary, but the vulnerability was discovered
  with the addition of can_dequeue_timeout and force_flush.

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

index 1b7cb84..7ae4966 100644 (file)
@@ -1633,6 +1633,7 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error,
 
        surf_source->vblank_done = TPL_TRUE;
 
+       g_mutex_lock(&surf_source->surf_mutex);
        if (!disp_source->is_vulkan_dpy) {
                if (surf_source->vblank_waiting_buffers) {
                        tbm_surface_h tbm_surface = NULL;
@@ -1643,7 +1644,6 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error,
                                _twe_thread_wl_surface_commit(surf_source, tbm_surface);
                }
        } else {
-               g_mutex_lock(&surf_source->surf_mutex);
                switch (surf_source->swapchain_properties.present_mode) {
                case TPL_DISPLAY_PRESENT_MODE_MAILBOX:
                        if (surf_source->draw_done_buffer) {
@@ -1666,8 +1666,8 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error,
 
                        break;
                }
-               g_mutex_unlock(&surf_source->surf_mutex);
        }
+       g_mutex_unlock(&surf_source->surf_mutex);
 }
 
 static tdm_client_vblank*
@@ -3184,6 +3184,7 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface)
                return TPL_ERROR_INVALID_OPERATION;
        }
 
+       g_mutex_lock(&surf_source->surf_mutex);
        if (surf_source->committed_buffers) {
                while (!__tpl_list_is_empty(surf_source->committed_buffers)) {
                                tbm_surface_h tbm_surface =
@@ -3198,6 +3199,7 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface)
                                                tbm_surface, tsq_err);
                }
        }
+       g_mutex_unlock(&surf_source->surf_mutex);
 
        TPL_LOG_T(BACKEND,
                          "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)",