Skip to content

Commit

Permalink
fix(core): always pass ngx.ctx to log_init_worker_errors
Browse files Browse the repository at this point in the history
Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle committed Oct 7, 2024
1 parent 11405e5 commit 467a6e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
Fix to always pass `ngx.ctx` to log init worker errors as otherwise it may runtime crash.
type: bugfix
scope: Core
16 changes: 10 additions & 6 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1952,10 +1952,12 @@ end
Kong.status_header_filter = Kong.admin_header_filter


function Kong.serve_cluster_listener(options)
log_init_worker_errors()
function Kong.serve_cluster_listener()
local ctx = ngx.ctx

log_init_worker_errors(ctx)

ngx.ctx.KONG_PHASE = PHASES.cluster_listener
ctx.KONG_PHASE = PHASES.cluster_listener

return kong.clustering:handle_cp_websocket()
end
Expand All @@ -1966,10 +1968,12 @@ function Kong.stream_api()
end


function Kong.serve_cluster_rpc_listener(options)
log_init_worker_errors()
function Kong.serve_cluster_rpc_listener()
local ctx = ngx.ctx

log_init_worker_errors(ctx)

ngx.ctx.KONG_PHASE = PHASES.cluster_listener
ctx.KONG_PHASE = PHASES.cluster_listener

return kong.rpc:handle_websocket()
end
Expand Down

0 comments on commit 467a6e4

Please sign in to comment.