Skip to content

Commit

Permalink
avoid self.targets is nil.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
juzipeek committed May 8, 2020
1 parent 68f0cc6 commit d7f9e7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ function _M.new(opts)
assert(self.shm, ("no shm found by name '%s'"):format(opts.shm_name))

-- other properties
self.targets = nil -- list of targets, initially loaded, maintained by events
self.targets = {} -- list of targets, initially loaded, maintained by events
self.events = nil -- hash table with supported events (prevent magic strings)
self.stopping = true -- flag to indicate to timers to stop checking
self.timer_count = 0 -- number of running timers
Expand Down

0 comments on commit d7f9e7b

Please sign in to comment.