mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user