mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
1. snax hotfix recursively patch func
2. load hotfix source with _ENV instead of empty table
This commit is contained in:
@@ -68,9 +68,9 @@ local function find_func(funcs, group , name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local dummy_env = {}
|
local dummy_env = {}
|
||||||
|
for k,v in pairs(_ENV) do dummy_env[k] = v end
|
||||||
|
|
||||||
local function patch_func(funcs, global, group, name, f)
|
local function _patch(global, f)
|
||||||
local desc = assert(find_func(funcs, group, name) , string.format("Patch mismatch %s.%s", group, name))
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while true do
|
while true do
|
||||||
local name, value = debug.getupvalue(f, i)
|
local name, value = debug.getupvalue(f, i)
|
||||||
@@ -81,9 +81,18 @@ local function patch_func(funcs, global, group, name, f)
|
|||||||
if old_uv then
|
if old_uv then
|
||||||
debug.upvaluejoin(f, i, old_uv.func, old_uv.index)
|
debug.upvaluejoin(f, i, old_uv.func, old_uv.index)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if type(value) == "function" then
|
||||||
|
_patch(global, value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function patch_func(funcs, global, group, name, f)
|
||||||
|
local desc = assert(find_func(funcs, group, name) , string.format("Patch mismatch %s.%s", group, name))
|
||||||
|
_patch(global, f)
|
||||||
desc[4] = f
|
desc[4] = f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user