mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
skynet.wait中使用的session增加回绕判断 (#1931)
* skynet.wait中使用的session增加回绕判断 * 去除session判空 --------- Co-authored-by: mippo <hui.zeng@centurygame.com>
This commit is contained in:
@@ -70,7 +70,7 @@ local watching_session = {}
|
|||||||
local error_queue = {}
|
local error_queue = {}
|
||||||
local fork_queue = { h = 1, t = 0 }
|
local fork_queue = { h = 1, t = 0 }
|
||||||
|
|
||||||
local auxsend, auxtimeout
|
local auxsend, auxtimeout, auxwait
|
||||||
do ---- avoid session rewind conflict
|
do ---- avoid session rewind conflict
|
||||||
local csend = c.send
|
local csend = c.send
|
||||||
local cintcommand = c.intcommand
|
local cintcommand = c.intcommand
|
||||||
@@ -140,6 +140,12 @@ do ---- avoid session rewind conflict
|
|||||||
return session
|
return session
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function auxwait_checkconflict()
|
||||||
|
local session = c.genid()
|
||||||
|
checkconflict(session)
|
||||||
|
return session
|
||||||
|
end
|
||||||
|
|
||||||
local function auxsend_checkrewind(addr, proto, msg, sz)
|
local function auxsend_checkrewind(addr, proto, msg, sz)
|
||||||
local session = csend(addr, proto, nil, msg, sz)
|
local session = csend(addr, proto, nil, msg, sz)
|
||||||
if session and session > dangerzone_low and session <= dangerzone_up then
|
if session and session > dangerzone_low and session <= dangerzone_up then
|
||||||
@@ -158,15 +164,26 @@ do ---- avoid session rewind conflict
|
|||||||
return session
|
return session
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function auxwait_checkrewind()
|
||||||
|
local session = c.genid()
|
||||||
|
if session > dangerzone_low and session <= dangerzone_up then
|
||||||
|
-- enter dangerzone
|
||||||
|
set_checkconflict(session)
|
||||||
|
end
|
||||||
|
return session
|
||||||
|
end
|
||||||
|
|
||||||
set_checkrewind = function()
|
set_checkrewind = function()
|
||||||
auxsend = auxsend_checkrewind
|
auxsend = auxsend_checkrewind
|
||||||
auxtimeout = auxtimeout_checkrewind
|
auxtimeout = auxtimeout_checkrewind
|
||||||
|
auxwait = auxwait_checkrewind
|
||||||
end
|
end
|
||||||
|
|
||||||
set_checkconflict = function(session)
|
set_checkconflict = function(session)
|
||||||
reset_dangerzone(session)
|
reset_dangerzone(session)
|
||||||
auxsend = auxsend_checkconflict
|
auxsend = auxsend_checkconflict
|
||||||
auxtimeout = auxtimeout_checkconflict
|
auxtimeout = auxtimeout_checkconflict
|
||||||
|
auxwait = auxwait_checkconflict
|
||||||
end
|
end
|
||||||
|
|
||||||
-- in safezone at the beginning
|
-- in safezone at the beginning
|
||||||
@@ -516,7 +533,7 @@ function skynet.yield()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function skynet.wait(token)
|
function skynet.wait(token)
|
||||||
local session = c.genid()
|
local session = auxwait()
|
||||||
token = token or coroutine.running()
|
token = token or coroutine.running()
|
||||||
suspend_sleep(session, token)
|
suspend_sleep(session, token)
|
||||||
sleep_session[token] = nil
|
sleep_session[token] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user