Fix order of operations in cache stop completion

Prevent metadata updater being freed by pyocf before it's deinitialized by ocf.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-06-05 05:30:57 -04:00
parent 75ec3c7db4
commit be64173066

View File

@ -1942,6 +1942,9 @@ static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline,
struct ocf_mngt_cache_stop_context *context = priv; struct ocf_mngt_cache_stop_context *context = priv;
ocf_cache_t cache = context->cache; ocf_cache_t cache = context->cache;
ocf_ctx_t ctx = context->ctx; ocf_ctx_t ctx = context->ctx;
int pipeline_error;
ocf_mngt_cache_stop_end_t pipeline_cmpl;
void *completion_priv;
if (!error) { if (!error) {
env_mutex_lock(&ctx->lock); env_mutex_lock(&ctx->lock);
@ -1972,11 +1975,20 @@ static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline,
context->cache_name); context->cache_name);
} }
context->cmpl(cache, context->priv, /*
error ?: context->cache_write_error); * FIXME: Destroying pipeline before completing management operation is a
* temporary workaround for insufficient object lifetime management in pyocf
* Context must not be referenced after destroying pipeline as this is
* typically freed upon pipeline destroy.
*/
pipeline_error = error ?: context->cache_write_error;
pipeline_cmpl = context->cmpl;
completion_priv = context->priv;
ocf_pipeline_destroy(context->pipeline); ocf_pipeline_destroy(context->pipeline);
pipeline_cmpl(cache, completion_priv, pipeline_error);
if (!error) { if (!error) {
/* Finally release cache instance */ /* Finally release cache instance */
ocf_mngt_cache_put(cache); ocf_mngt_cache_put(cache);