Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
7605:2481ebc7f715 | 7606:f40f1d9b7872 |
---|---|
266 end | 266 end |
267 | 267 |
268 -- Called when socket is readable | 268 -- Called when socket is readable |
269 function interface:onreadable() | 269 function interface:onreadable() |
270 local data, err, partial = self.conn:receive(self._pattern); | 270 local data, err, partial = self.conn:receive(self._pattern); |
271 if self.conn:dirty() then | |
272 self:setreadtimeout(false); | |
273 self:pausefor(cfg.read_retry_delay); | |
274 else | |
275 self:setreadtimeout(); | |
276 end | |
271 if data or partial then | 277 if data or partial then |
272 self:on("incoming", data or partial, err); | 278 self:on("incoming", data or partial, err); |
273 end | 279 end |
274 if err == "wantread" then | 280 if err == "wantread" then |
275 self:setflags(true, nil); | 281 self:setflags(true, nil); |
277 self:setflags(nil, true); | 283 self:setflags(nil, true); |
278 elseif not data and err ~= "timeout" then | 284 elseif not data and err ~= "timeout" then |
279 self:on("disconnect", err); | 285 self:on("disconnect", err); |
280 self:destroy() | 286 self:destroy() |
281 return; | 287 return; |
282 end | |
283 if self.conn:dirty() then | |
284 self:setreadtimeout(false); | |
285 self:pausefor(cfg.read_retry_delay); | |
286 else | |
287 self:setreadtimeout(); | |
288 end | 288 end |
289 end | 289 end |
290 | 290 |
291 -- Called when socket is writable | 291 -- Called when socket is writable |
292 function interface:onwriteable() | 292 function interface:onwriteable() |