This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 5de9990  fix: ctx being contaminated due to a new feature of openresty 
1.19 (#3105)
5de9990 is described below

commit 5de99904467db5b71e8df4c1f22444eb9d4223b7
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Thu Dec 24 14:35:41 2020 +0800

    fix: ctx being contaminated due to a new feature of openresty 1.19 (#3105)
    
    Fix #3079
---
 apisix/init.lua | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index 01dc772..38f5f75 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -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
 
 
@@ -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)
 

Reply via email to