mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
queryname并发导致消息乱序
当有1个以上的co进入queryname,后面的协程有在第1个以后某个的co先执行(第一个已经返回),导致cluster消息乱序
This commit is contained in:
@@ -11,14 +11,29 @@ fd = tonumber(fd)
|
|||||||
|
|
||||||
local large_request = {}
|
local large_request = {}
|
||||||
local register_name = {}
|
local register_name = {}
|
||||||
|
local inquery_name = {}
|
||||||
|
|
||||||
setmetatable(register_name, { __index =
|
setmetatable(register_name, { __index =
|
||||||
function(self, name)
|
function(self, name)
|
||||||
local addr = skynet.call(clusterd, "lua", "queryname", name:sub(2)) -- name must be '@xxxx'
|
local waitco = inquery_name[name]
|
||||||
if addr then
|
if waitco then
|
||||||
self[name] = addr
|
local co=coroutine.runnging()
|
||||||
|
table.insert(waitco, co)
|
||||||
|
skynet.wait(co)
|
||||||
|
return rawget(self, name)
|
||||||
|
else
|
||||||
|
waitco = {}
|
||||||
|
inquery_name[name] = waitco
|
||||||
|
local addr = skynet.call(clusterd, "lua", "queryname", name:sub(2)) -- name must be '@xxxx'
|
||||||
|
if addr then
|
||||||
|
self[name] = addr
|
||||||
|
end
|
||||||
|
inquery_name[name] = nil
|
||||||
|
for _, co in ipairs(waitco) do
|
||||||
|
skynet.wakeup(co)
|
||||||
|
end
|
||||||
|
return addr
|
||||||
end
|
end
|
||||||
return addr
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user