From 2ef4882ca7d468582e58e90736c4762ce7313b0e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 30 Sep 2022 16:23:50 +0900 Subject: [PATCH] Changed the order of lock/unlock at buffer_clear. - The lock/unlock order of buffer->mutex and display->wl_event_mutex is important. display->mutex must surround buffer->mutex - Before applying this patch, deadlock issue may be occured in buffer_clear. Change-Id: I90d9b36874def4e4c7f0bd36742b3bbd00faab44 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index f6c0375..4434972 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2116,11 +2116,13 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) need_to_wait = (status < COMMITTED); if (need_to_wait) { - tpl_gmutex_unlock(&wl_egl_display->wl_event_mutex); + /* The lock/unlock order of buffer->mutex and display->wl_event_mutex + * is important. display->mutex must surround buffer->mutex */ + tpl_gmutex_unlock(&wl_egl_buffer->mutex); wait_result = tpl_gcond_timed_wait(&wl_egl_buffer->cond, - &wl_egl_buffer->mutex, - 200); /* 200ms */ - tpl_gmutex_lock(&wl_egl_display->wl_event_mutex); + &wl_egl_display->wl_event_mutex, + 200); /* 200ms */ + tpl_gmutex_lock(&wl_egl_buffer->mutex); if (wait_result == TPL_ERROR_TIME_OUT) TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", -- 2.7.4