From 91bef1160c0da469170f5798816b69e531e977a8 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Thu, 5 Oct 2023 11:10:11 -0700 Subject: [PATCH] wip --- src/common/proxy_wasm/ngx_proxy_wasm.c | 20 ++++++++------------ t/03-proxy_wasm/003-on_tick.t | 6 +++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.c b/src/common/proxy_wasm/ngx_proxy_wasm.c index bb5fd60d0..cdb526f34 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 (DDEBUG) 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); } diff --git a/t/03-proxy_wasm/003-on_tick.t b/t/03-proxy_wasm/003-on_tick.t index e4b6268e5..beb207a28 100644 --- a/t/03-proxy_wasm/003-on_tick.t +++ b/t/03-proxy_wasm/003-on_tick.t @@ -166,14 +166,14 @@ Should not prevent http context/instance from starting return 200; } --- response_body ---- grep_error_log eval: qr/\[(info|crit)].*?on_tick.*/ +--- grep_error_log eval: qr/(\[crit\]|\[info].*?on_tick).*/ --- grep_error_log_out eval qr/.*? \[info\] .*? on_tick 200.* -\[crit\] .*? panicked at 'on_tick trap'.* +\[crit\] .*? panicked at.* .*? \[info\] .*? on_tick 200.* -\[crit\] .*? panicked at 'on_tick trap'.*/ +\[crit\] .*? panicked at.*/ --- error_log filter 1/1 resuming "on_request_headers" step filter 1/1 resuming "on_response_headers" step