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 authored and AlinsRan committed Jun 1, 2023
1 parent 94524e1 commit b6ce75d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions 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 @@ -1414,7 +1414,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
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)
* fix: properly log line numbers by using tail calls [#29](https://github.com/Kong/lua-resty-healthcheck/pull/29)
* fix: when not providing a hostname, use IP [#48](https://github.com/Kong/lua-resty-healthcheck/pull/48)
* fix: makefile; make install
* 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

0 comments on commit b6ce75d

Please sign in to comment.