projects
/
platform
/
core
/
uifw
/
libtbm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tbm_bufmgr: lock the gLock before locking tbm_bufmgr_mutex
[platform/core/uifw/libtbm.git]
/
src
/
tbm_bufmgr.c
diff --git
a/src/tbm_bufmgr.c
b/src/tbm_bufmgr.c
index
ee9f004
..
55f9243
100644
(file)
--- 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_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
- _tbm_bufmgr_mutex_lock();
pthread_mutex_lock(&gLock);
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);
_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();
_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);
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();
_tbm_bufmgr_mutex_unlock();
+ pthread_mutex_unlock(&gLock);
return;
}
return;
}
@@
-415,8
+415,8
@@
tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
free(bufmgr);
gBufMgr = NULL;
free(bufmgr);
gBufMgr = NULL;
- pthread_mutex_unlock(&gLock);
_tbm_bufmgr_mutex_unlock();
_tbm_bufmgr_mutex_unlock();
+ pthread_mutex_unlock(&gLock);
}
unsigned int
}
unsigned int
@@
-863,10
+863,15
@@
tbm_bufmgr_internal_find_bo(tbm_bufmgr bufmgr, tbm_bo bo)
}
tbm_bo
}
tbm_bo
-tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags
, tbm_error_e *error
)
+tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags)
{
{
+ tbm_error_e error = TBM_ERROR_NONE;
tbm_bo bo;
tbm_bo bo;
- tbm_bo_data *bo_data;
+
+ _tbm_bufmgr_mutex_lock();
+
+ TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
+ TBM_BUFMGR_RETURN_VAL_IF_FAIL(size > 0, NULL);
_tbm_bufmgr_check_bo_cnt(bufmgr);
_tbm_bufmgr_check_bo_cnt(bufmgr);
@@
-874,24
+879,38
@@
tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags, tbm_error_e
if (!bo) {
/* LCOV_EXCL_START */
TBM_ERR("memory allocationc failed.");
if (!bo) {
/* LCOV_EXCL_START */
TBM_ERR("memory allocationc failed.");
-
*
error = TBM_ERROR_OUT_OF_MEMORY;
-
return NULL
;
+ error = TBM_ERROR_OUT_OF_MEMORY;
+
goto failed
;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
}
- bo
_data = tbm_module_alloc_bo_data(bufmgr->module, bo, size, flags,
error);
- if (!bo_data) {
+ bo
->bo_data = tbm_module_alloc_bo_data(bufmgr->module, bo, size, flags, &
error);
+ if (!bo
->bo
_data) {
/* LCOV_EXCL_START */
/* LCOV_EXCL_START */
- TBM_ERR("tbm_module_alloc_bo_data failed. size:%d flags:%s error:%d", size, _tbm_flag_to_str(flags),
*
error);
+ TBM_ERR("tbm_module_alloc_bo_data failed. size:%d flags:%s error:%d", size, _tbm_flag_to_str(flags), error);
free(bo);
free(bo);
- return NULL;
+ _tbm_set_last_result(error);
+ _tbm_bufmgr_mutex_unlock();
+ goto failed;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
}
- bo->bo_data = bo_data;
_tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
_tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
+ TBM_TRACE_BO("bo(%p) size(%d) refcnt(%d), flag(%s)", bo, size, bo->ref_cnt, _tbm_flag_to_str(bo->flags));
+
+ _tbm_set_last_result(TBM_ERROR_NONE);
+ _tbm_bufmgr_mutex_unlock();
+
return bo;
return bo;
+
+/* LCOV_EXCL_START */
+failed:
+ _tbm_set_last_result(error);
+ _tbm_bufmgr_mutex_unlock();
+
+ return NULL;
+/* LCOV_EXCL_STOP */
}
}
@@
-904,7
+923,6
@@
tbm_bufmgr_internal_alloc_bo_with_format(tbm_bufmgr bufmgr, int format, int bo_i
tbm_bo bo = NULL;
_tbm_bufmgr_mutex_lock();
tbm_bo bo = NULL;
_tbm_bufmgr_mutex_lock();
- _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
@@
-914,17
+932,17
@@
tbm_bufmgr_internal_alloc_bo_with_format(tbm_bufmgr bufmgr, int format, int bo_i
if (!bo) {
/* LCOV_EXCL_START */
TBM_ERR("memory allocationc failed.");
if (!bo) {
/* LCOV_EXCL_START */
TBM_ERR("memory allocationc failed.");
- _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
+ *error = TBM_ERROR_OUT_OF_MEMORY;
+ goto failed;
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_STOP */
- goto fail;
}
bo->bo_data = tbm_module_alloc_bo_data_with_format(bufmgr->module, format, bo_idx, width, height, bpp, flags, error);
if (!bo->bo_data) {
/* LCOV_EXCL_START */
}
bo->bo_data = tbm_module_alloc_bo_data_with_format(bufmgr->module, format, bo_idx, width, height, bpp, flags, error);
if (!bo->bo_data) {
/* LCOV_EXCL_START */
- _tbm_set_last_result(*error);
+ free(bo);
+ goto failed;
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_STOP */
- goto fail;
}
_tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
}
_tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
@@
-933,12
+951,12
@@
tbm_bufmgr_internal_alloc_bo_with_format(tbm_bufmgr bufmgr, int format, int bo_i
return bo;
return bo;
-fail:
- if (bo)
- free(bo);
+/* LCOV_EXCL_START */
+failed:
_tbm_bufmgr_mutex_unlock();
return NULL;
_tbm_bufmgr_mutex_unlock();
return NULL;
+/* LCOV_EXCL_STOP */
}
tbm_bo
}
tbm_bo