Merge pull request #182 from mmichal10/fix-cache-completion-order

Fix order of operations in cache stop completion
This commit is contained in:
Adam Rutkowski 2019-06-10 05:19:01 -04:00 committed by GitHub
commit fb430c21e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);