Software /
code /
prosody
Comparison
net/server_epoll.lua @ 7560:785fa1138293
net.server_epoll: Continue reading after a slight delay if there is buffered data after a read
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Aug 2016 01:13:26 +0200 |
parent | 7559:b1b27dedf4cf |
child | 7563:71dc0d89a9b8 |
comparison
equal
deleted
inserted
replaced
7559:b1b27dedf4cf | 7560:785fa1138293 |
---|---|
26 local cfg = { | 26 local cfg = { |
27 read_timeout = 900; | 27 read_timeout = 900; |
28 write_timeout = 7; | 28 write_timeout = 7; |
29 tcp_backlog = 128; | 29 tcp_backlog = 128; |
30 accept_retry_interval = 10; | 30 accept_retry_interval = 10; |
31 read_retry_delay = 1e-06; | |
31 }; | 32 }; |
32 | 33 |
33 local fds = createtable(10, 0); -- FD -> conn | 34 local fds = createtable(10, 0); -- FD -> conn |
34 local timers = {}; | 35 local timers = {}; |
35 | 36 |
234 self.listeners.ondisconnect(self, err); | 235 self.listeners.ondisconnect(self, err); |
235 self:destroy() | 236 self:destroy() |
236 return; | 237 return; |
237 end | 238 end |
238 self:setreadtimeout(); | 239 self:setreadtimeout(); |
240 if self.conn:dirty() then | |
241 self:pausefor(cfg.read_retry_delay); | |
242 end | |
239 end | 243 end |
240 | 244 |
241 function interface:onwriteable() | 245 function interface:onwriteable() |
242 local buffer = self.writebuffer; | 246 local buffer = self.writebuffer; |
243 local data = t_concat(buffer); | 247 local data = t_concat(buffer); |
418 if t == false then return; end | 422 if t == false then return; end |
419 self:setflags(false); | 423 self:setflags(false); |
420 self._pausefor = addtimer(t, function () | 424 self._pausefor = addtimer(t, function () |
421 self._pausefor = nil; | 425 self._pausefor = nil; |
422 self:setflags(true); | 426 self:setflags(true); |
427 if self.conn:dirty() then | |
428 self:onreadable(); | |
429 end | |
423 end); | 430 end); |
424 end | 431 end |
425 | 432 |
426 function interface:onconnect() | 433 function interface:onconnect() |
427 self.onwriteable = nil; | 434 self.onwriteable = nil; |