mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
pcall execute_module, #1331
This commit is contained in:
@@ -62,19 +62,24 @@ do
|
|||||||
context[co] = init_list
|
context[co] = init_list
|
||||||
|
|
||||||
-- We should call modfunc in lua, because modfunc may yield by calling M.require recursive.
|
-- We should call modfunc in lua, because modfunc may yield by calling M.require recursive.
|
||||||
local m = modfunc(name, filename)
|
local function execute_module()
|
||||||
|
local m = modfunc(name, filename)
|
||||||
|
|
||||||
for _, f in ipairs(init_list) do
|
for _, f in ipairs(init_list) do
|
||||||
f()
|
f()
|
||||||
|
end
|
||||||
|
|
||||||
|
if m == nil then
|
||||||
|
m = true
|
||||||
|
end
|
||||||
|
|
||||||
|
loaded[name] = m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ok, err = xpcall(execute_module, debug.traceback)
|
||||||
|
|
||||||
context[co] = old_init_list
|
context[co] = old_init_list
|
||||||
|
|
||||||
if m == nil then
|
|
||||||
m = true
|
|
||||||
end
|
|
||||||
|
|
||||||
package.loaded[name] = m
|
|
||||||
|
|
||||||
local waiting = #loading_queue
|
local waiting = #loading_queue
|
||||||
if waiting > 0 then
|
if waiting > 0 then
|
||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
@@ -84,7 +89,11 @@ do
|
|||||||
end
|
end
|
||||||
loading[name] = nil
|
loading[name] = nil
|
||||||
|
|
||||||
return m
|
if ok then
|
||||||
|
return loaded[name]
|
||||||
|
else
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user