Software /
code /
prosody
Changeset
7687:ae24deae6488
net.server_epoll: Separate ok from err branch more
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 07 Oct 2016 17:18:29 +0200 |
parents | 7686:8d6f367bed8c |
children | 7690:861a747e441b |
files | net/server_epoll.lua |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Fri Oct 07 16:52:18 2016 +0200 +++ b/net/server_epoll.lua Fri Oct 07 17:18:29 2016 +0200 @@ -290,24 +290,28 @@ -- Called when socket is readable function interface:onreadable() local data, err, partial = self.conn:receive(self._pattern); + if data then + self:on("incoming", data); + else + if partial then + self:on("incoming", partial, err); + end + if err == "wantread" then + self:setflags(true, nil); + elseif err == "wantwrite" then + self:setflags(nil, true); + elseif err ~= "timeout" then + self:on("disconnect", err); + self:destroy() + return; + end + end if self.conn:dirty() then self:setreadtimeout(false); self:pausefor(cfg.read_retry_delay); else self:setreadtimeout(); end - if data or partial then - self:on("incoming", data or partial, err); - end - if err == "wantread" then - self:setflags(true, nil); - elseif err == "wantwrite" then - self:setflags(nil, true); - elseif not data and err ~= "timeout" then - self:on("disconnect", err); - self:destroy() - return; - end end -- Called when socket is writable @@ -323,7 +327,8 @@ self:setwritetimeout(false); self:ondrain(); -- Be aware of writes in ondrain return; - elseif partial then + end + if partial then buffer[1] = data:sub(partial+1); for i = #buffer, 2, -1 do buffer[i] = nil; @@ -334,7 +339,7 @@ self:setflags(nil, true); elseif err == "wantread" then self:setflags(true, nil); - elseif err and err ~= "timeout" then + elseif err ~= "timeout" then self:on("disconnect", err); self:destroy(); end