Comparison

net/server_epoll.lua @ 9587:42eedef517dc

net.server_epoll: Reschedule delayed timers relative to current time This should normally never happen, but can be reproduced by suspending the process a while.
author Kim Alvefur <zash@zash.se>
date Sun, 28 Oct 2018 18:22:17 +0100
parent 9581:1be99aedb0b3
child 9594:dcf466e04f81
comparison
equal deleted inserted replaced
9586:44dbee2f173f 9587:42eedef517dc
104 end 104 end
105 break; 105 break;
106 end 106 end
107 local new_timeout = f(now); 107 local new_timeout = f(now);
108 if new_timeout then 108 if new_timeout then
109 -- Schedule for 'delay' from the time actually scheduled, 109 -- Schedule for 'delay' from the time actually scheduled, not from now,
110 -- not from now, in order to prevent timer drift. 110 -- in order to prevent timer drift, unless it already drifted way out of sync.
111 timer[1] = t + new_timeout; 111 if (t + new_timeout) > ( now - new_timeout ) then
112 timer[1] = t + new_timeout;
113 else
114 timer[1] = now + new_timeout;
115 end
112 resort_timers = true; 116 resort_timers = true;
113 else 117 else
114 t_remove(timers, i); 118 t_remove(timers, i);
115 end 119 end
116 end 120 end