If skynet.wakeup a skynet.call, raise an error

This commit is contained in:
Cloud Wu
2015-05-12 22:53:03 +08:00
parent 9452169f0a
commit d92adda2c9

View File

@@ -128,7 +128,7 @@ local function dispatch_wakeup()
local session = sleep_session[co] local session = sleep_session[co]
if session then if session then
session_id_coroutine[session] = "BREAK" session_id_coroutine[session] = "BREAK"
return suspend(co, coroutine.resume(co, true, "BREAK")) return suspend(co, coroutine.resume(co, false, "BREAK"))
end end
end end
end end
@@ -265,9 +265,13 @@ function skynet.sleep(ti)
session = tonumber(session) session = tonumber(session)
local succ, ret = coroutine_yield("SLEEP", session) local succ, ret = coroutine_yield("SLEEP", session)
sleep_session[coroutine.running()] = nil sleep_session[coroutine.running()] = nil
assert(succ, ret) if succ then
return
end
if ret == "BREAK" then if ret == "BREAK" then
return "BREAK" return "BREAK"
else
error(ret)
end end
end end
@@ -277,7 +281,7 @@ end
function skynet.wait() function skynet.wait()
local session = c.genid() local session = c.genid()
coroutine_yield("SLEEP", session) local ret, msg = coroutine_yield("SLEEP", session)
local co = coroutine.running() local co = coroutine.running()
sleep_session[co] = nil sleep_session[co] = nil
session_id_coroutine[session] = nil session_id_coroutine[session] = nil