Software /
code /
prosody
Diff
net/server_epoll.lua @ 7606:f40f1d9b7872
net.server_epoll: Set timers before calling onincoming, fixes traceback if connection is closed before onincoming returns
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Aug 2016 17:41:00 +0200 |
parent | 7604:36408ef6c8c9 |
child | 7623:a1c040a5754f |
line wrap: on
line diff
--- a/net/server_epoll.lua Thu Aug 18 17:36:46 2016 +0200 +++ b/net/server_epoll.lua Thu Aug 18 17:41:00 2016 +0200 @@ -268,6 +268,12 @@ -- Called when socket is readable function interface:onreadable() local data, err, partial = self.conn:receive(self._pattern); + 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 @@ -280,12 +286,6 @@ self:destroy() return; end - if self.conn:dirty() then - self:setreadtimeout(false); - self:pausefor(cfg.read_retry_delay); - else - self:setreadtimeout(); - end end -- Called when socket is writable