Skip to content

Commit

Permalink
fix(targetlist) avoid self.targets being nil due to async behaviour (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
juzipeek committed Sep 20, 2020
1 parent 52a010c commit 0a115e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)
* feature: added a status version field [#54](https://github.com/Kong/lua-resty-healthcheck/pull/54)
* feature: add headers for probe request [#54](https://github.com/Kong/lua-resty-healthcheck/pull/54)
* fix: exit early when reloading during a probe [#47](https://github.com/Kong/lua-resty-healthcheck/pull/47)
* fix: prevent target-list from being nil, due to async behaviour [#44](https://github.com/Kong/lua-resty-healthcheck/pull/44)

### 1.3.0 (17-Jun-2020)

Expand Down
2 changes: 1 addition & 1 deletion lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ function _M.new(opts)
end

-- 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 0a115e1

Please sign in to comment.