diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.c b/src/common/proxy_wasm/ngx_proxy_wasm.c index cdb526f34..76506e42c 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm.c +++ b/src/common/proxy_wasm/ngx_proxy_wasm.c @@ -181,21 +181,22 @@ ngx_proxy_wasm_start(ngx_cycle_t *cycle) ngx_proxy_wasm_ctx_t * -ngx_proxy_wasm_ctx_alloc(ngx_pool_t *pool) +ngx_proxy_wasm_ctx_alloc(ngx_log_t *log) { + ngx_pool_t *pool; ngx_proxy_wasm_ctx_t *pwctx; - pwctx = ngx_pcalloc(pool, sizeof(ngx_proxy_wasm_ctx_t)); - if (pwctx == NULL) { + pool = ngx_create_pool(512, log); + if (pool == NULL) { return NULL; } - pwctx->pool = ngx_create_pool(512, pool->log); - if (pwctx->pool == NULL) { + pwctx = ngx_pcalloc(pool, sizeof(ngx_proxy_wasm_ctx_t)); + if (pwctx == NULL) { return NULL; } - pwctx->parent_pool = pool; + pwctx->pool = pool; ngx_rbtree_init(&pwctx->host_props_tree, &pwctx->host_props_sentinel, ngx_str_rbtree_insert_value); @@ -399,8 +400,6 @@ ngx_proxy_wasm_ctx_destroy(ngx_proxy_wasm_ctx_t *pwctx) #endif ngx_destroy_pool(pwctx->pool); - - ngx_pfree(pwctx->parent_pool, pwctx); } diff --git a/src/common/proxy_wasm/ngx_proxy_wasm.h b/src/common/proxy_wasm/ngx_proxy_wasm.h index 6dbce7237..8e362d5f1 100644 --- a/src/common/proxy_wasm/ngx_proxy_wasm.h +++ b/src/common/proxy_wasm/ngx_proxy_wasm.h @@ -380,7 +380,7 @@ ngx_int_t ngx_proxy_wasm_start(ngx_cycle_t *cycle); /* stream context */ -ngx_proxy_wasm_ctx_t *ngx_proxy_wasm_ctx_alloc(ngx_pool_t *pool); +ngx_proxy_wasm_ctx_t *ngx_proxy_wasm_ctx_alloc(ngx_log_t *log); ngx_proxy_wasm_ctx_t *ngx_proxy_wasm_ctx(ngx_uint_t *filter_ids, size_t nfilters, ngx_uint_t isolation, ngx_proxy_wasm_subsystem_t *subsys, void *data); diff --git a/src/http/proxy_wasm/ngx_http_proxy_wasm.c b/src/http/proxy_wasm/ngx_http_proxy_wasm.c index 92cea0bc4..7acca3ddc 100644 --- a/src/http/proxy_wasm/ngx_http_proxy_wasm.c +++ b/src/http/proxy_wasm/ngx_http_proxy_wasm.c @@ -346,6 +346,7 @@ ngx_http_proxy_wasm_ecode(ngx_proxy_wasm_err_e ecode) } +#if 0 static void ngx_http_proxy_wasm_ctx_cleanup_handler(void *data) { @@ -353,6 +354,7 @@ ngx_http_proxy_wasm_ctx_cleanup_handler(void *data) ngx_proxy_wasm_ctx_destroy(pwctx); } +#endif static ngx_proxy_wasm_ctx_t * @@ -362,15 +364,21 @@ ngx_http_proxy_wasm_ctx(void *data) ngx_http_wasm_req_ctx_t *rctx = data; ngx_http_request_t *r = rctx->r; ngx_http_wasm_loc_conf_t *loc; +#if 0 ngx_pool_cleanup_t *cln; +#endif loc = ngx_http_get_module_loc_conf(r, ngx_http_wasm_module); pwctx = (ngx_proxy_wasm_ctx_t *) rctx->data; if (pwctx == NULL) { +#if 0 pwctx = ngx_proxy_wasm_ctx_alloc(r == r->main ? r->connection->pool : r->pool); +#else + pwctx = ngx_proxy_wasm_ctx_alloc(r->connection->log); +#endif if (pwctx == NULL) { return NULL; } @@ -385,6 +393,7 @@ ngx_http_proxy_wasm_ctx(void *data) /* for on_request_body retrieval */ rctx->data = pwctx; +#if 0 if (rctx->fake_request) { cln = ngx_pool_cleanup_add(pwctx->parent_pool, 0); if (cln == NULL) { @@ -394,6 +403,7 @@ ngx_http_proxy_wasm_ctx(void *data) cln->handler = ngx_http_proxy_wasm_ctx_cleanup_handler; cln->data = pwctx; } +#endif } return pwctx;