fix crash of sharedata by incref before sharedated.monitor return cobj to client.

crash occr analise:
1.sharedated.update call many times in a short time(eg:3 times) to change a same name conf value to a->b->c->d.
2.sharedated sending 3 response  to monitoring clients。a->b and b->c and c->d.
3.if b is destroyed and it's memory is reallocated and rewrited when client process the first message a->b, client's call lbox will crash.

solution:
conf b must be keeped before message(a->b) is processed by inc it's ref.
Any return value from host to client must use incref before send to client.
This commit is contained in:
lwkienun
2019-06-15 12:11:37 +08:00
committed by 云风
parent 5a0f68999e
commit 8e2facbfb8
2 changed files with 3 additions and 0 deletions

View File

@@ -118,6 +118,7 @@ function CMD.update(name, t, ...)
if watch then
sharedata.host.markdirty(oldcobj)
for _,response in pairs(watch) do
sharedata.host.incref(newobj)
response(true, newobj)
end
end
@@ -138,6 +139,7 @@ end
function CMD.monitor(name, obj)
local v = assert(pool[name])
if obj ~= v.obj then
sharedata.host.incref(v.obj)
return v.obj
end