Skip to content

Commit 715589a

Browse files
fix(proxy-wasm) pass VM config size to 'on_vm_start'
Fix #654 Co-Authored-By: dev-null-undefined <[email protected]>
1 parent 67a4fca commit 715589a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/common/proxy_wasm/ngx_proxy_wasm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,8 @@ ngx_proxy_wasm_create_context(ngx_proxy_wasm_filter_t *filter,
12131213
rc = ngx_wavm_instance_call_funcref(ictx->instance,
12141214
filter->proxy_on_vm_start,
12151215
&rets,
1216-
rexec->id, rexec->root_id);
1216+
rexec->id,
1217+
filter->module->config.len);
12171218
if (rc != NGX_OK || !rets->data[0].of.i32) {
12181219
ecode = NGX_PROXY_WASM_ERR_VM_START_FAILED;
12191220
goto error;

t/03-proxy_wasm/001-on_root_phases.t

+24-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ run_tests();
99

1010
__DATA__
1111
12-
=== TEST 1: proxy_wasm - on_vm_start
12+
=== TEST 1: proxy_wasm - on_vm_start without configuration
1313
--- wasm_modules: on_phases
1414
--- config
1515
location /t {
@@ -25,7 +25,28 @@ qr/\[info\] .*? on_vm_start, config_size: 0/
2525
2626
2727
28-
=== TEST 2: proxy_wasm - on_configure without configuration
28+
=== TEST 2: proxy_wasm - on_vm_start with configuration
29+
--- main_config eval
30+
qq{
31+
wasm {
32+
module on_phases $ENV{TEST_NGINX_CRATES_DIR}/on_phases.wasm 'foo=bar';
33+
}
34+
}
35+
--- config
36+
location /t {
37+
proxy_wasm on_phases;
38+
return 200;
39+
}
40+
--- response_body
41+
--- error_log eval
42+
qr/\[info\] .*? on_vm_start, config_size: 7/
43+
--- no_error_log
44+
[error]
45+
[crit]
46+
47+
48+
49+
=== TEST 3: proxy_wasm - on_configure without configuration
2950
--- wasm_modules: on_phases
3051
--- config
3152
location /t {
@@ -41,7 +62,7 @@ qr/\[info\] .*? on_configure, config_size: 0/
4162
4263
4364
44-
=== TEST 3: proxy_wasm - on_configure with configuration
65+
=== TEST 4: proxy_wasm - on_configure with configuration
4566
--- wasm_modules: on_phases
4667
--- config
4768
location /t {

0 commit comments

Comments
 (0)