mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43: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:
@@ -18,6 +18,7 @@ local function monitor(name, obj, cobj)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
sd.update(obj, newobj)
|
sd.update(obj, newobj)
|
||||||
|
skynet.send(service, "lua", "confirm" , newobj)
|
||||||
end
|
end
|
||||||
if cache[name] == obj then
|
if cache[name] == obj then
|
||||||
cache[name] = nil
|
cache[name] = nil
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ function CMD.update(name, t, ...)
|
|||||||
if watch then
|
if watch then
|
||||||
sharedata.host.markdirty(oldcobj)
|
sharedata.host.markdirty(oldcobj)
|
||||||
for _,response in pairs(watch) do
|
for _,response in pairs(watch) do
|
||||||
|
sharedata.host.incref(newobj)
|
||||||
response(true, newobj)
|
response(true, newobj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -138,6 +139,7 @@ end
|
|||||||
function CMD.monitor(name, obj)
|
function CMD.monitor(name, obj)
|
||||||
local v = assert(pool[name])
|
local v = assert(pool[name])
|
||||||
if obj ~= v.obj then
|
if obj ~= v.obj then
|
||||||
|
sharedata.host.incref(v.obj)
|
||||||
return v.obj
|
return v.obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user