aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-10-07 17:18:29 +0200
committerKim Alvefur <zash@zash.se>2016-10-07 17:18:29 +0200
commit15c519eb2fa4ab7a704f2f3817c41233e78c7624 (patch)
tree4fce544e19e3ea082219dad361a1769abf40e900 /net/server_epoll.lua
parent67c41ef89e175c064eca7d7518779aefed31c187 (diff)
downloadprosody-15c519eb2fa4ab7a704f2f3817c41233e78c7624.tar.gz
prosody-15c519eb2fa4ab7a704f2f3817c41233e78c7624.zip
net.server_epoll: Separate ok from err branch more
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua33
1 files changed, 19 insertions, 14 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 9ef14a78..a9896923 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -290,24 +290,28 @@ end
-- 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 @@ function interface:onwriteable()
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 @@ function interface:onwriteable()
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