g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
ret = __create_resource(handle, type, volume, &resource);
- MM_RM_UNLOCK2_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
- handle->resources_lock, handles_lock, ret, "Resource cannot be created");
+ MM_RM_UNLOCK_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
+ handle->resources_lock, ret, "Resource cannot be created");
g_ptr_array_add(handle->resources, resource);
*resource_h = resource;
"resource manager #%"PRIu64, *resource_h, type, volume,
_mm_rm_hash64(handle->id));
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return ret;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
i = __get_resource_index(handle, resource);
- MM_RM_UNLOCK2_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
- handle->resources_lock, handles_lock,
+ MM_RM_UNLOCK_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
+ handle->resources_lock,
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Invalid resource handle");
if (new_volume == resource->volume) {
case MM_RESOURCE_MANAGER_RES_STATE_FOR_ACQUIRE:
if (add_volume > 0) {
ret = __check_resource(handle, resource->type, add_volume);
- MM_RM_UNLOCK2_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
- handle->resources_lock, handles_lock, ret, "Resource check failed");
+ MM_RM_UNLOCK_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
+ handle->resources_lock, ret, "Resource check failed");
}
resource->volume = new_volume;
break;
case MM_RESOURCE_MANAGER_RES_STATE_FOR_RELEASE:
case MM_RESOURCE_MANAGER_RES_STATE_ACQUIRED:
ret = __create_resource(handle, resource->type, add_volume, &tmp_resource);
- MM_RM_UNLOCK2_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
- handle->resources_lock, handles_lock, ret, "Resource cannot be created");
+ MM_RM_UNLOCK_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE,
+ handle->resources_lock, ret, "Resource cannot be created");
tmp_resource->volume = resource->volume;
tmp_resource->state = MM_RESOURCE_MANAGER_RES_STATE_FOR_RELEASE;
MM_RM_INFO("Resource %p is resized for acquire in resource manager #%"PRIu64,
resource_h, _mm_rm_hash64(handle->id));
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return ret;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
i = __get_resource_index(handle, resource);
- MM_RM_UNLOCK2_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
- handle->resources_lock, handles_lock,
+ MM_RM_UNLOCK_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
+ handle->resources_lock,
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Invalid resource handle");
MM_RM_INFO("Resource %p is marked for release in resource manager #%"PRIu64,
resource_h, _mm_rm_hash64(handle->id));
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return MM_RESOURCE_MANAGER_ERROR_NONE;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
for (i = 0; i < handle->resources->len; i++) {
if (!__mark_resource_for_release(handle->resources, i,
MM_RM_INFO("All resources are marked for release in resource manager #%"PRIu64,
_mm_rm_hash64(handle->id));
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return MM_RESOURCE_MANAGER_ERROR_NONE;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
i = __get_resource_index(handle, resource);
- MM_RM_UNLOCK2_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
- handle->resources_lock, handles_lock,
+ MM_RM_UNLOCK_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND,
+ handle->resources_lock,
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Invalid resource handle");
MM_RM_INFO("Info structure of resource %p in resource manager #%"PRIu64" is filled",
resource_h, _mm_rm_hash64(handle->id));
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return MM_RESOURCE_MANAGER_ERROR_NONE;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
ret = __dbus_commit(handle);
if (ret == MM_RESOURCE_MANAGER_ERROR_NONE)
else
MM_RM_ERROR("Dbus commit request failed");
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
return ret;
}
g_mutex_lock(&handles_lock);
MM_RESOURCE_MANAGER_CHECK(handle);
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
handle->status_cb.cb = cb;
handle->status_cb.user_data = user_data;
g_mutex_unlock(&handle->resources_lock);
- g_mutex_unlock(&handles_lock);
MM_RM_INFO("Status callback %p in resource manager #%"PRIu64" is set", cb,
_mm_rm_hash64(handle->id));
MM_RM_HASH64(handle_id);
if (handle_id == id) {
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
for (j = 0; j < handle->resources->len; j++) {
resource = (mm_resource_manager_res_s*)handle->resources->pdata[j];
if (resource->type == type && resource->volume == volume) {
g_mutex_unlock(&handle->resources_lock);
if (release_all) {
- if (_mm_resource_manager_mark_all_for_release(handle) ==
- MM_RESOURCE_MANAGER_ERROR_NONE &&
- _mm_resource_manager_commit(handle) ==
- MM_RESOURCE_MANAGER_ERROR_NONE) {
+ if (_mm_resource_manager_mark_all_for_release(handle) == MM_RESOURCE_MANAGER_ERROR_NONE
+ && _mm_resource_manager_commit(handle) == MM_RESOURCE_MANAGER_ERROR_NONE) {
MM_RM_DEBUG("All resources are released after release cb");
} else {
MM_RM_ERROR("Resources cannot be released after release cb");
}
}
+ } else {
+ g_mutex_unlock(&handles_lock);
}
}
mm_resource_manager_status_e status)
{
g_mutex_lock(&handle->resources_lock);
+ g_mutex_unlock(&handles_lock);
if (handle->status_cb.cb) {
((mm_resource_manager_status_cb)handle->status_cb.cb)(handle, status,
handle->status_cb.user_data);
gint arg_resource_type, gint arg_volume)
{
mm_resource_manager_s *handle;
+ gboolean unlock = TRUE;
int i;
g_mutex_lock(&handles_lock);
if (handle->dbus_proxy == object) {
__mm_resource_manager_release_callback(handle, arg_id,
arg_resource_type, arg_volume);
+ unlock = FALSE;
break;
}
}
- g_mutex_unlock(&handles_lock);
+
+ if (unlock)
+ g_mutex_unlock(&handles_lock);
}
static void __dbus_status_callback(MMResourceManager *object, gint arg_status)
{
mm_resource_manager_s *handle;
+ gboolean unlock = TRUE;
int i;
g_mutex_lock(&handles_lock);
handle = (mm_resource_manager_s*)handles->pdata[i];
if (handle->dbus_proxy == object) {
__mm_resource_manager_status_callback(handle, arg_status);
+ unlock = FALSE;
break;
}
}
- g_mutex_unlock(&handles_lock);
+
+ if (unlock)
+ g_mutex_unlock(&handles_lock);
}
static gpointer __dispatcher_thread(gpointer user_data)