From 9ba0860c701850a04154b4f9799f391f9d388fa3 Mon Sep 17 00:00:00 2001 From: hong Date: Wed, 17 Apr 2019 11:18:51 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:cluster=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=E6=97=B6=E5=80=99=E6=9C=89=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E6=B6=88=E6=81=AF=E4=B9=B1=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lualib/skynet/cluster.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lualib/skynet/cluster.lua b/lualib/skynet/cluster.lua index c1633d3e..926d387f 100644 --- a/lualib/skynet/cluster.lua +++ b/lualib/skynet/cluster.lua @@ -3,11 +3,26 @@ local skynet = require "skynet" local clusterd local cluster = {} local sender = {} +local inquery_name = {} local function get_sender(t, node) - local c = skynet.call(clusterd, "lua", "sender", node) - t[node] = c - return c + local waitco = inquery_name[node] + if waitco then + local co=coroutine.running() + table.insert(waitco, co) + skynet.wait(co) + return rawget(t, node) + else + waitco = {} + inquery_name[node] = waitco + local c = skynet.call(clusterd, "lua", "sender", node) + inquery_name[node] = nil + t[node] = c + for _, co in ipairs(waitco) do + skynet.wakeup(co) + end + return c + end end setmetatable(sender, { __index = get_sender } )