From c019008383a439b5e5cf46dc71f902f335a0a9df Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 1 Feb 2022 14:53:38 +0100 Subject: [PATCH] IO loop duration fixup --- lib/timer.h | 1 + sysdep/unix/io-loop.c | 4 ++-- sysdep/unix/io.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/timer.h b/lib/timer.h index 04544ace..161e39d3 100644 --- a/lib/timer.h +++ b/lib/timer.h @@ -55,6 +55,7 @@ static inline timer *timers_first(struct timeloop *loop) #define current_time() atomic_load_explicit(&last_time, memory_order_acquire) #define current_real_time() atomic_load_explicit(&real_time, memory_order_acquire) +#define current_time_update() ({ times_update(); current_time(); }) //#define now (current_time() TO_S) //#define now_real (current_real_time() TO_S) diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index 5ab93b31..9b107a1a 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -558,7 +558,7 @@ birdloop_main(void *arg) if (loop->poll_changed) sockets_prepare(loop); - btime duration = current_time() - loop_begin; + btime duration = current_time_update() - loop_begin; if (duration > config->watchdog_warning) log(L_WARN "I/O loop cycle took %d ms", (int) (duration TO_MS)); @@ -578,7 +578,7 @@ birdloop_main(void *arg) if (loop->stopped && !loop->links) break; - loop_begin = current_time(); + loop_begin = current_time_update(); if (rv) sockets_fire(loop); diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index fa836f28..e3e388af 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -2100,8 +2100,7 @@ static btime loop_time; static void io_update_time(void) { - times_update(); - last_io_time = current_time(); + last_io_time = current_time_update(); if (event_open) {