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 1 commit
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 @@ -1295,6 +1289,12 @@ function _M.new(opts)
if not ok then
self:log(ERR, "Error loading initial target list: ", err)
end

self.ev_callback = function(data, event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the indentation on this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

-- 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()
Expand Down