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 72960d7
Show file tree
Hide file tree
Showing 3 changed files with 14 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
6 changes: 6 additions & 0 deletions src/http/proxy_wasm/ngx_http_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,13 @@ ngx_http_proxy_wasm_ctx(void *data)

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 +389,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 +399,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 72960d7

Please sign in to comment.