cloudwu / skynet

A lightweight online game framework

Repository from Github https://github.comcloudwu/skynetRepository from Github https://github.comcloudwu/skynet

引用计数问题

susahdh opened this issue · comments

function CMD.update(name, t, ...)
local v = pool[name]
local watch, oldcobj
if v then
watch = v.watch
oldcobj = v.obj
objmap[oldcobj] = true
sharedata.host.decref(oldcobj)
pool[name] = nil
pool_count[name] = nil
end
CMD.new(name, t, ...)
local newobj = pool[name].obj
if watch then
sharedata.host.markdirty(oldcobj)
for _,response in pairs(watch) do
sharedata.host.incref(newobj)
response(true, newobj) --如果response的对象退出了 newobj的引用计数会有问题
end
end
collect1min() -- collect in 1 min
end

commented

你需要自行正确处理服务退出流程。这里假定使用 sharedatad 的服务都不退出,或在退出前妥善完成了它们的任务。