move yield from suspend to pause, see
@@ -37,13 +37,13 @@ local function pause_socket(s, size)
end
driver.pause(s.id)
s.pause = true
+ skynet.yield() -- there are subsequent socket messages in mqueue, maybe.
end
local function suspend(s)
assert(not s.co)
s.co = coroutine.running()
if s.pause then
- skynet.yield() -- there are subsequent socket messages in mqueue, maybe.
skynet.error(string.format("Resume socket (%d)", s.id))
driver.start(s.id)
skynet.wait(s.co)
@@ -75,10 +75,10 @@ socket_message[1] = function(id, size, data)
-- read size
if sz >= rr then
s.read_required = nil
- wakeup(s)
if sz > BUFFER_LIMIT then
pause_socket(s, sz)
end
+ wakeup(s)
end
else
if s.buffer_limit and sz > s.buffer_limit then
@@ -90,10 +90,10 @@ socket_message[1] = function(id, size, data)
-- read line
if driver.readline(s.buffer,nil,rr) then
s.read_required = nil
- wakeup(s)
if sz > BUFFER_LIMIT then
pause_socket(s, sz)
end
+ wakeup(s)
end
elseif sz > BUFFER_LIMIT and not s.pause then
pause_socket(s, sz)
