Skip to content

Commit

Permalink
wip 2
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Oct 31, 2023
1 parent 91bef11 commit 4482745
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/common/proxy_wasm/ngx_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/common/proxy_wasm/ngx_proxy_wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/http/proxy_wasm/ngx_http_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,15 @@ ngx_http_proxy_wasm_ecode(ngx_proxy_wasm_err_e ecode)
}


#if 0
static void
ngx_http_proxy_wasm_ctx_cleanup_handler(void *data)
{
ngx_proxy_wasm_ctx_t *pwctx = data;

ngx_proxy_wasm_ctx_destroy(pwctx);
}
#endif


static ngx_proxy_wasm_ctx_t *
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 4482745

Please sign in to comment.