Commit 9b268b6c authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Fix timer handling

ev_timer_time may remain the same for legit reason, so to prevent looping, instead, reset it before invoking the handler.
To let user know what the initial setting was, pass it as the argument instead of current time (which is kind of pointless).

PUBLISHED_FROM=fa328009f097f9b49b5b0dd13a38ee6d6e6518de
parent 3b3ac48e
......@@ -2270,14 +2270,8 @@ MG_INTERNAL void mg_call(struct mg_connection *nc,
void mg_if_timer(struct mg_connection *c, double now) {
if (c->ev_timer_time > 0 && now >= c->ev_timer_time) {
double old_value = c->ev_timer_time;
mg_call(c, NULL, c->user_data, MG_EV_TIMER, &now);
/*
* To prevent timer firing all the time, reset the timer after delivery.
* However, in case user sets it to new value, do not reset.
*/
if (c->ev_timer_time == old_value) {
c->ev_timer_time = 0;
}
c->ev_timer_time = 0;
mg_call(c, NULL, c->user_data, MG_EV_TIMER, &old_value);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment