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

Fix the issue: multi kong woker processes will premature trigger other woker processes's event callback #18

Merged
merged 2 commits into from
Apr 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1267,12 +1267,6 @@ function _M.new(opts)
-- register for events, and directly after load initial target list
-- order is important!
do
self.ev_callback = function(data, event)
-- just a wrapper to be able to access `self` as a closure
return self:event_handler(event, data.ip, data.port, data.hostname)
end
worker_events.register_weak(self.ev_callback, self.EVENT_SOURCE)

-- Lock the list, in case it is being cleared by another worker
local ok, err = locking_target_list(self, function(target_list)

Expand All @@ -1296,6 +1290,12 @@ function _M.new(opts)
self:log(ERR, "Error loading initial target list: ", err)
end

self.ev_callback = function(data, event)
-- just a wrapper to be able to access `self` as a closure
return self:event_handler(event, data.ip, data.port, data.hostname)
end
worker_events.register_weak(self.ev_callback, self.EVENT_SOURCE)

-- handle events to sync up in case there was a change by another worker
worker_events:poll()
end
Expand Down