diff --git a/service/clusterd.lua b/service/clusterd.lua index 5a151f93..274e9a9e 100644 --- a/service/clusterd.lua +++ b/service/clusterd.lua @@ -61,6 +61,9 @@ local function open_channel(t, key) skynet.wakeup(co) end assert(succ, err) + if node_address[key] ~= address then + return open_channel(t,key) + end return c end @@ -76,6 +79,7 @@ local function loadconfig(tmp) assert(load(source, "@"..config_name, "t", tmp))() end end + local reload = {} for name,address in pairs(tmp) do if name:sub(1,2) == "__" then name = name:sub(3) @@ -87,6 +91,7 @@ local function loadconfig(tmp) -- address changed if rawget(node_channel, name) then node_channel[name] = nil -- reset connection + table.insert(reload, name) end node_address[name] = address end @@ -105,6 +110,10 @@ local function loadconfig(tmp) end end end + for _, name in ipairs(reload) do + -- open_channel would block + skynet.fork(open_channel, node_channel, name) + end end function command.reload(source, config)