Commit d7a633bf authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Fix timers when polling loop gets delayed

Past due timers should be brought forward to restore interval.

PUBLISHED_FROM=dbe1b8b98804cf8de81e1dbe814222422363278f
parent 0ea3cdd2
......@@ -14850,7 +14850,7 @@ time_t mg_lwip_if_poll(struct mg_iface *iface, int timeout_ms) {
uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
struct mg_connection *nc;
double now = mg_time();
double now;
double min_timer = 0;
int num_timers = 0;
mg_ev_mgr_lwip_process_signals(mgr);
......@@ -14876,7 +14876,10 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
}
}
uint32_t timeout_ms = ~0;
now = mg_time();
if (num_timers > 0) {
/* If we have a timer that is past due, do a poll ASAP. */
if (min_timer < now) return 0;
double timer_timeout_ms = (min_timer - now) * 1000 + 1 /* rounding */;
if (timer_timeout_ms < timeout_ms) {
timeout_ms = timer_timeout_ms;
......
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