Comparison

net/server_epoll.lua @ 10491:6f7a77aff9d5

net.server_epoll: Change timer rescheduling method to match util.timer Relative to current time instead of absolute time, in preparation for switching to monotonic time.
author Kim Alvefur <zash@zash.se>
date Sun, 08 Dec 2019 14:20:56 +0100
parent 10490:c9cff02c0528
child 10492:8e1d9bba9244
comparison
equal deleted inserted replaced
10490:c9cff02c0528 10491:6f7a77aff9d5
84 t[2] = noop; 84 t[2] = noop;
85 timers:remove(t.id); 85 timers:remove(t.id);
86 end 86 end
87 87
88 local function reschedule(t, time) 88 local function reschedule(t, time)
89 time = gettime() + time;
89 t[1] = time; 90 t[1] = time;
90 timers:reprioritize(t.id, time); 91 timers:reprioritize(t.id, time);
91 end 92 end
92 93
93 -- Add relative timer 94 -- Add relative timer
251 end 252 end
252 return 253 return
253 end 254 end
254 t = t or cfg.read_timeout; 255 t = t or cfg.read_timeout;
255 if self._readtimeout then 256 if self._readtimeout then
256 self._readtimeout:reschedule(gettime() + t); 257 self._readtimeout:reschedule(t);
257 else 258 else
258 self._readtimeout = addtimer(t, function () 259 self._readtimeout = addtimer(t, function ()
259 if self:on("readtimeout") then 260 if self:on("readtimeout") then
260 self:debug("Read timeout handled"); 261 self:debug("Read timeout handled");
261 return cfg.read_timeout; 262 return cfg.read_timeout;
277 end 278 end
278 return 279 return
279 end 280 end
280 t = t or cfg.send_timeout; 281 t = t or cfg.send_timeout;
281 if self._writetimeout then 282 if self._writetimeout then
282 self._writetimeout:reschedule(gettime() + t); 283 self._writetimeout:reschedule(t);
283 else 284 else
284 self._writetimeout = addtimer(t, function () 285 self._writetimeout = addtimer(t, function ()
285 self:debug("Write timeout"); 286 self:debug("Write timeout");
286 self:on("disconnect", "write timeout"); 287 self:on("disconnect", "write timeout");
287 self:destroy(); 288 self:destroy();