From e8de85843d57eaf70163ada070b6bedc1b2d6d13 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Wed, 6 Apr 2016 11:57:28 +0200 Subject: [PATCH] IO: Avoid multiple event cycles in one loop cycle. Event cycle may took too much time and trigger next timer events, so avoid cycling between timer and event cycles inside the loop cycle. --- proto/bgp/bgp.c | 4 ++++ sysdep/unix/io.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 5841e5bd..b6751977 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -670,6 +670,10 @@ bgp_keepalive_timeout(timer *t) DBG("BGP: Keepalive timer\n"); bgp_schedule_packet(conn, PKT_KEEPALIVE); + + /* Kick TX a bit faster */ + if (ev_active(conn->tx_ev)) + ev_run(conn->tx_ev); } static void diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index a747580d..29795334 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -2050,12 +2050,13 @@ io_loop(void) for(;;) { events = ev_run_list(&global_event_list); + timers: update_times(); tout = tm_first_shot(); if (tout <= now) { tm_shot(); - continue; + goto timers; } poll_tout = (events ? 0 : MIN(tout - now, 3)) * 1000; /* Time in milliseconds */