From 394a065ea27f222e8a54f57ff3ca911fab9302d4 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 16 Oct 2020 11:49:28 +0800 Subject: [PATCH] move yield from suspend to pause, see #1248 --- lualib/skynet/socket.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lualib/skynet/socket.lua b/lualib/skynet/socket.lua index 3f99e9ef..330330e7 100644 --- a/lualib/skynet/socket.lua +++ b/lualib/skynet/socket.lua @@ -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)