fix(proxy-wasm) do not accidentally reset filter list from FFI call #423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling
proxy_wasm.set_property
from Lua, we want apwctx
to be able to store a property. But we need to do that beforeproxy_wasm.start
, sopwctx->ready
didn't have a chance to get initialized yet.Passing
NULL, 0
tofilter_ids
andnfilters
when obtaining thepwctx
from theset_property
FFI call caused thepwctx
to get initialized with an empty filter list, defeating the configuration previously set up byproxy_wasm.attach
.In this fix, we make the
NULL
value offilter_ids
to mean "please don't do thepwctx->ready
initialization". The other use ofngx_proxy_wasm_ctx
inngx_wasm_ops.c
always passes a non-NULL value (even when the filter list is empty), because theelts
pointer is allocated onngx_array_init
.This issue caused an integration failure in Kong Gateway. This PR includes a regression test for our test suite, which reproduces the sequence observed in the Gateway; the test fails without the fix added to
ngx_proxy_wasm.c
and passes with the fix.