From 238437409d604e27c1dd8162578e4c4a9fa5acae Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 24 Jun 2021 12:01:12 +0900 Subject: [PATCH] tbm_bufmgr: lock the gLock before locking tbm_bufmgr_mutex The order of locking mutex makes deadlock. So this patch will start to fix. Change-Id: Ic7b866eb5b6826239e1b671c059d0393c47ac4f1 --- src/tbm_bufmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 6457f16..55f9243 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -364,22 +364,22 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr) { TBM_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr)); - _tbm_bufmgr_mutex_lock(); pthread_mutex_lock(&gLock); + _tbm_bufmgr_mutex_lock(); _tbm_set_last_result(TBM_ERROR_NONE); if (!gBufMgr) { TBM_ERR("gBufmgr already destroy: bufmgr:%p\n", bufmgr); - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); return; } bufmgr->ref_count--; if (bufmgr->ref_count > 0) { TBM_DBG("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr); - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); return; } @@ -415,8 +415,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr) free(bufmgr); gBufMgr = NULL; - pthread_mutex_unlock(&gLock); _tbm_bufmgr_mutex_unlock(); + pthread_mutex_unlock(&gLock); } unsigned int -- 2.7.4