diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.c b/src/common/proxy_wasm/ngx_proxy_wasm.c index bb5fd60d0..16aca5bd1 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm.c +++ b/src/common/proxy_wasm/ngx_proxy_wasm.c @@ -310,7 +310,9 @@ ngx_proxy_wasm_ctx_destroy(ngx_proxy_wasm_ctx_t *pwctx) dd("enter (pwctx: %p)", pwctx); - if (pwctx->isolation == NGX_PROXY_WASM_ISOLATION_STREAM && pwctx->ready) { + if (pwctx->ready + && pwctx->isolation == NGX_PROXY_WASM_ISOLATION_STREAM) + { ngx_proxy_wasm_store_destroy(&pwctx->store); } @@ -336,9 +338,9 @@ ngx_proxy_wasm_ctx_destroy(ngx_proxy_wasm_ctx_t *pwctx) if (pwctx->isolation == NGX_PROXY_WASM_ISOLATION_NONE) { /* sweep if an instance has trapped */ ngx_proxy_wasm_store_sweep(pwexec->ictx->store); - } - if (pwctx->isolation == NGX_PROXY_WASM_ISOLATION_FILTER) { + } else if (pwctx->isolation == NGX_PROXY_WASM_ISOLATION_FILTER) { + /* destroy filter context store */ ngx_proxy_wasm_store_destroy(pwexec->store); } } @@ -1089,9 +1091,7 @@ ngx_proxy_wasm_create_context(ngx_proxy_wasm_filter_t *filter, if (id && (in == NULL || in->root_id != NGX_PROXY_WASM_ROOT_CTX_ID)) { pwexec = ngx_proxy_wasm_lookup_ctx(ictx, id); - - dd("pwexec for id %ld: %p", id, pwexec); - + dd("pwexec for id %ld: %p (in: %p)", id, pwexec, in); if (pwexec == NULL) { if (in == NULL) { @@ -1664,7 +1664,7 @@ static void ngx_proxy_wasm_instance_invalidate(ngx_proxy_wasm_instance_t *ictx) { ngx_rbtree_node_t **root, **sentinel, *s, *n; - ngx_proxy_wasm_exec_t *pwexec = NULL; + ngx_proxy_wasm_exec_t *pwexec; dd("enter (ictx: %p)", ictx); @@ -1676,7 +1676,7 @@ ngx_proxy_wasm_instance_invalidate(ngx_proxy_wasm_instance_t *ictx) while (*root != *sentinel) { n = ngx_rbtree_min(*root, *sentinel); -#if 0 +#if (NGX_DEBUG) pwexec = ngx_rbtree_data(n, ngx_proxy_wasm_exec_t, node); dd("invalidate root ctx #%ld instance (pwexec: %p)", @@ -1684,7 +1684,6 @@ ngx_proxy_wasm_instance_invalidate(ngx_proxy_wasm_instance_t *ictx) #endif ngx_rbtree_delete(&ictx->root_ctxs, n); - #if 0 destroy_pwexec(pwexec); #endif @@ -1734,10 +1733,8 @@ ngx_proxy_wasm_instance_destroy(ngx_proxy_wasm_instance_t *ictx) rexec = ngx_rbtree_data(n, ngx_proxy_wasm_exec_t, node); rexec->ictx = NULL; - rexec->started = 0; ngx_rbtree_delete(&ictx->root_ctxs, n); - #if 0 destroy_pwexec(rexec); #endif @@ -1754,7 +1751,6 @@ ngx_proxy_wasm_instance_destroy(ngx_proxy_wasm_instance_t *ictx) ngx_wasm_assert(rexec->ev == NULL); rexec->ictx = NULL; - rexec->started = 0; ngx_rbtree_delete(&ictx->tree_ctxs, n); }