From d7f9e7b21584a642d5d381ac58488120ce9ed0d7 Mon Sep 17 00:00:00 2001 From: zhoujie Date: Fri, 8 May 2020 15:02:02 +0800 Subject: [PATCH] avoid `self.targets` is nil. 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. --- lib/resty/healthcheck.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/resty/healthcheck.lua b/lib/resty/healthcheck.lua index 739301b1..b04b63ef 100644 --- a/lib/resty/healthcheck.lua +++ b/lib/resty/healthcheck.lua @@ -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