mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
Bugfix: mc.close may reference an invalid pointer. See pr #220
This commit is contained in:
@@ -68,18 +68,20 @@ end
|
||||
local function publish(c , source, pack, size)
|
||||
local group = channel[c]
|
||||
if group == nil then
|
||||
-- dead channel, delete the pack
|
||||
mc.bind(pack, 1)
|
||||
-- dead channel, delete the pack. mc.bind returns the pointer in pack
|
||||
local pack = mc.bind(pack, 1)
|
||||
mc.close(pack)
|
||||
return
|
||||
end
|
||||
mc.bind(pack, channel_n[c])
|
||||
local msg = skynet.tostring(pack, size)
|
||||
for k in pairs(group) do
|
||||
-- the msg is a pointer to the real message, publish pointer in local is ok.
|
||||
skynet.redirect(k, source, "multicast", c , msg)
|
||||
end
|
||||
local remote = channel_remote[c]
|
||||
if remote then
|
||||
-- remote publish should unpack the pack, because we should not publish the pointer out.
|
||||
local _, msg, sz = mc.unpack(pack, size)
|
||||
local msg = skynet.tostring(msg,sz)
|
||||
for node in pairs(remote) do
|
||||
|
||||
Reference in New Issue
Block a user