Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport -> release/3.6.x] fix(wasm): do not call attach() on re-entrancy #12452

Merged
merged 1 commit into from Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/kong/wasm-attach.yml
@@ -0,0 +1,5 @@
message: >
**proxy-wasm**: Fixed "previous plan already attached" error thrown when a
filter triggers re-entrancy of the access handler.
type: bugfix
scope: Core
25 changes: 15 additions & 10 deletions kong/runloop/wasm.lua
Expand Up @@ -922,17 +922,22 @@ function _M.attach(ctx)

ctx.ran_wasm = true

local ok, err = proxy_wasm.attach(chain.c_plan)
if not ok then
log(CRIT, "failed attaching ", chain.label, " filter chain to request: ", err)
return kong.response.error(500)
end
local ok, err
if not ctx.wasm_attached then
ctx.wasm_attached = true

ok, err = proxy_wasm.set_host_properties_handlers(properties.get,
properties.set)
if not ok then
log(CRIT, "failed setting host property handlers: ", err)
return kong.response.error(500)
ok, err = proxy_wasm.attach(chain.c_plan)
if not ok then
log(CRIT, "failed attaching ", chain.label, " filter chain to request: ", err)
return kong.response.error(500)
end

ok, err = proxy_wasm.set_host_properties_handlers(properties.get,
properties.set)
if not ok then
log(CRIT, "failed setting host property handlers: ", err)
return kong.response.error(500)
end
end

jit.off(proxy_wasm.start)
Expand Down