Skip to content

Commit

Permalink
fix: ctx being contaminated due to a new feature of openresty 1.19 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-chen authored Dec 24, 2020
1 parent 966d688 commit 5de9990
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apisix/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ function _M.http_ssl_phase()
if err then
core.log.error("failed to fetch ssl config: ", err)
end
-- clear the ctx of the ssl phase, avoid affecting other phases
ngx.ctx = nil
ngx_exit(-1)
end

-- clear the ctx of the ssl phase, avoid affecting other phases
ngx.ctx = nil
end


Expand Down Expand Up @@ -334,12 +339,9 @@ end

function _M.http_access_phase()
local ngx_ctx = ngx.ctx
local api_ctx = ngx_ctx.api_ctx

if not api_ctx then
api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
ngx_ctx.api_ctx = api_ctx
end
-- always fetch table from the table pool, we don't need a reused api_ctx
local api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
ngx_ctx.api_ctx = api_ctx

core.ctx.set_vars_meta(api_ctx)

Expand Down

0 comments on commit 5de9990

Please sign in to comment.