mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
to-be-closed (#1261)
This commit is contained in:
@@ -14,12 +14,20 @@ local tunpack = table.unpack
|
||||
local traceback = debug.traceback
|
||||
|
||||
local cresume = coroutine.resume
|
||||
local coroutine_close = coroutine.close
|
||||
local running_thread = nil
|
||||
local init_thread = nil
|
||||
|
||||
local function coroutine_ret(co, ok, ...)
|
||||
if not ok then
|
||||
coroutine_close(co)
|
||||
end
|
||||
return ok, ...
|
||||
end
|
||||
|
||||
local function coroutine_resume(co, ...)
|
||||
running_thread = co
|
||||
return cresume(co, ...)
|
||||
return coroutine_ret(co, cresume(co, ...))
|
||||
end
|
||||
local coroutine_yield = coroutine.yield
|
||||
local coroutine_create = coroutine.create
|
||||
@@ -329,6 +337,7 @@ function suspend(co, result, command)
|
||||
if command == "SUSPEND" then
|
||||
return dispatch_wakeup()
|
||||
elseif command == "QUIT" then
|
||||
coroutine_close(co)
|
||||
-- service exit
|
||||
return
|
||||
elseif command == "USER" then
|
||||
@@ -523,6 +532,11 @@ function skynet.exit()
|
||||
c.send(address, skynet.PTYPE_ERROR, session, "")
|
||||
end
|
||||
end
|
||||
for session, co in pairs(session_id_coroutine) do
|
||||
if type(co) == "thread" then
|
||||
coroutine_close(co)
|
||||
end
|
||||
end
|
||||
for resp in pairs(unresponse) do
|
||||
resp(false)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user