Skip to content

Commit

Permalink
fix(proxy-wasm) pass VM config size to 'on_vm_start'
Browse files Browse the repository at this point in the history
Fix #654

Co-Authored-By: dev-null-undefined <50732964+dev-null-undefined@users.noreply.github.com>
  • Loading branch information
thibaultcha and dev-null-undefined committed Jan 2, 2025
1 parent 67a4fca commit 715589a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/common/proxy_wasm/ngx_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,8 @@ ngx_proxy_wasm_create_context(ngx_proxy_wasm_filter_t *filter,
rc = ngx_wavm_instance_call_funcref(ictx->instance,
filter->proxy_on_vm_start,
&rets,
rexec->id, rexec->root_id);
rexec->id,
filter->module->config.len);
if (rc != NGX_OK || !rets->data[0].of.i32) {
ecode = NGX_PROXY_WASM_ERR_VM_START_FAILED;
goto error;
Expand Down
27 changes: 24 additions & 3 deletions t/03-proxy_wasm/001-on_root_phases.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ run_tests();

__DATA__

=== TEST 1: proxy_wasm - on_vm_start
=== TEST 1: proxy_wasm - on_vm_start without configuration
--- wasm_modules: on_phases
--- config
location /t {
Expand All @@ -25,7 +25,28 @@ qr/\[info\] .*? on_vm_start, config_size: 0/



=== TEST 2: proxy_wasm - on_configure without configuration
=== TEST 2: proxy_wasm - on_vm_start with configuration
--- main_config eval
qq{
wasm {
module on_phases $ENV{TEST_NGINX_CRATES_DIR}/on_phases.wasm 'foo=bar';
}
}
--- config
location /t {
proxy_wasm on_phases;
return 200;
}
--- response_body
--- error_log eval
qr/\[info\] .*? on_vm_start, config_size: 7/
--- no_error_log
[error]
[crit]



=== TEST 3: proxy_wasm - on_configure without configuration
--- wasm_modules: on_phases
--- config
location /t {
Expand All @@ -41,7 +62,7 @@ qr/\[info\] .*? on_configure, config_size: 0/



=== TEST 3: proxy_wasm - on_configure with configuration
=== TEST 4: proxy_wasm - on_configure with configuration
--- wasm_modules: on_phases
--- config
location /t {
Expand Down

0 comments on commit 715589a

Please sign in to comment.