mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
bugfix: sharedata can be update more than once
This commit is contained in:
@@ -747,9 +747,6 @@ lupdate(lua_State *L) {
|
|||||||
luaL_checktype(L, 3, LUA_TTABLE);
|
luaL_checktype(L, 3, LUA_TTABLE);
|
||||||
struct ctrl * c= lua_touserdata(L, 1);
|
struct ctrl * c= lua_touserdata(L, 1);
|
||||||
struct table *n = lua_touserdata(L, 2);
|
struct table *n = lua_touserdata(L, 2);
|
||||||
if (c->update) {
|
|
||||||
return luaL_error(L, "can't update more than once");
|
|
||||||
}
|
|
||||||
if (c->root == n) {
|
if (c->root == n) {
|
||||||
return luaL_error(L, "You should update a new object");
|
return luaL_error(L, "You should update a new object");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,15 +59,15 @@ function meta:__index(key)
|
|||||||
local newobj, newtbl = needupdate(self.__gcobj)
|
local newobj, newtbl = needupdate(self.__gcobj)
|
||||||
if newobj then
|
if newobj then
|
||||||
local newgcobj = newtbl.__gcobj
|
local newgcobj = newtbl.__gcobj
|
||||||
-- todo: update
|
|
||||||
local root = findroot(self)
|
local root = findroot(self)
|
||||||
update(root, newobj, newgcobj)
|
update(root, newobj, newgcobj)
|
||||||
if obj == self.__obj then
|
if obj == self.__obj then
|
||||||
error ("The key [" .. genkey(self) .. "] doesn't exist after update")
|
error ("The key [" .. genkey(self) .. "] doesn't exist after update")
|
||||||
end
|
end
|
||||||
|
obj = self.__obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local v = index(self.__obj, key)
|
local v = index(obj, key)
|
||||||
if type(v) == "userdata" then
|
if type(v) == "userdata" then
|
||||||
local r = setmetatable({
|
local r = setmetatable({
|
||||||
__obj = v,
|
__obj = v,
|
||||||
@@ -127,7 +127,7 @@ end
|
|||||||
|
|
||||||
function conf.update(self, pointer)
|
function conf.update(self, pointer)
|
||||||
local cobj = self.__obj
|
local cobj = self.__obj
|
||||||
assert(isdirty(cobj), "Obly dirty object can be update")
|
assert(isdirty(cobj), "Only dirty object can be update")
|
||||||
core.update(self.__gcobj, pointer, { __gcobj = core.box(pointer) })
|
core.update(self.__gcobj, pointer, { __gcobj = core.box(pointer) })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user