bugfix: error in forked coroutine. and add skynet.term()

This commit is contained in:
Cloud Wu
2014-09-25 17:36:38 +08:00
parent 320a608c36
commit ce6efc535c
2 changed files with 16 additions and 6 deletions

View File

@@ -143,13 +143,15 @@ end
function suspend(co, result, command, param, size)
if not result then
local session = session_coroutine_id[co]
local addr = session_coroutine_address[co]
if session ~= 0 then
-- only call response error
c.send(addr, skynet.PTYPE_ERROR, session, "")
if session then -- coroutine may fork by others (session is nil)
local addr = session_coroutine_address[co]
if session ~= 0 then
-- only call response error
c.send(addr, skynet.PTYPE_ERROR, session, "")
end
session_coroutine_id[co] = nil
session_coroutine_address[co] = nil
end
session_coroutine_id[co] = nil
session_coroutine_address[co] = nil
error(debug.traceback(co,tostring(command)))
end
if command == "CALL" then
@@ -696,6 +698,10 @@ function skynet.task(ret)
return t
end
function skynet.term(service)
return _error_dispatch(0, service)
end
-- Inject internal debug framework
local debug = require "skynet.debug"
debug(skynet, dispatch_message)

View File

@@ -54,6 +54,10 @@ function dbgcmd.RUN(source, filename)
skynet.ret(skynet.pack(table.concat(output, "\n")))
end
function dbgcmd.TERM(service)
skynet.term(service)
end
local function _debug_dispatch(session, address, cmd, ...)
local f = dbgcmd[cmd]
assert(f, cmd)