Fix leak in core pool

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-01-16 11:53:54 +01:00
parent b9fce50783
commit 7352f3092d
4 changed files with 9 additions and 21 deletions

View File

@ -204,7 +204,7 @@ int ocf_dobj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
*
* @param[in] obj data object handle
*/
void ocf_data_obj_destroy(ocf_data_obj_t obj);
void ocf_dobj_destroy(ocf_data_obj_t obj);
/**
* @brief Get data object type

View File

@ -778,21 +778,16 @@ int ocf_mngt_core_pool_visit(ocf_ctx_t ctx,
int (*visitor)(ocf_uuid_t, void *), void *visitor_ctx);
/**
* @brief Remove core from pool
* @brief Remove data object from pool
*
* Important: This function destroys data object instance but doesn't close it,
* so it should be either moved or closed before calling this function.
*
* @param[in] ctx OCF context
* @param[in] obj Core data object
*/
void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_data_obj_t obj);
/**
* @brief Close and remove core from pool
*
* @param[in] ctx OCF context
* @param[in] obj Core data object
*/
void ocf_mngt_core_pool_close_and_remove(ocf_ctx_t ctx, ocf_data_obj_t obj);
/**
* @brief Deinit core pool
*

View File

@ -99,15 +99,7 @@ void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
ctx->core_pool.core_pool_count--;
list_del(&obj->core_pool_item);
env_mutex_unlock(&ctx->lock);
ocf_dobj_deinit(obj);
}
void ocf_mngt_core_pool_close_and_remove(ocf_ctx_t ctx, ocf_data_obj_t obj)
{
OCF_CHECK_NULL(ctx);
OCF_CHECK_NULL(obj);
ocf_dobj_close(obj);
ocf_mngt_core_pool_remove(ctx, obj);
ocf_dobj_destroy(obj);
}
void ocf_mngt_core_pool_deinit(ocf_ctx_t ctx)
@ -118,6 +110,7 @@ void ocf_mngt_core_pool_deinit(ocf_ctx_t ctx)
list_for_each_entry_safe(sobj, tobj, &ctx->core_pool.core_pool_head,
core_pool_item) {
ocf_mngt_core_pool_close_and_remove(ctx, sobj);
ocf_dobj_close(sobj);
ocf_mngt_core_pool_remove(ctx, sobj);
}
}

View File

@ -168,7 +168,7 @@ int ocf_dobj_create(ocf_data_obj_t *obj, ocf_data_obj_type_t type,
return 0;
}
void ocf_data_obj_destroy(ocf_data_obj_t obj)
void ocf_dobj_destroy(ocf_data_obj_t obj)
{
OCF_CHECK_NULL(obj);