Skip to content

Commit 6d13fec

Browse files
juzipeeklocao
authored andcommitted
fix(targetlist) avoid self.targets being nil due to async behaviour (#44)
when two worker create `checker`, `worker-0` first created and add target success, then `worker-1` creating, when `worker-1` call `worker_events:poll()` in line 1408, raise crash. `self.targets` init with empty table avoid this.
1 parent 2a0c14f commit 6d13fec

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/resty/healthcheck.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ function _M.new(opts)
17601760
end
17611761

17621762
-- other properties
1763-
self.targets = nil -- list of targets, initially loaded, maintained by events
1763+
self.targets = {} -- list of targets, initially loaded, maintained by events
17641764
self.events = nil -- hash table with supported events (prevent magic strings)
17651765
self.ev_callback = nil -- callback closure per checker instance
17661766

0 commit comments

Comments
 (0)