From 64487ded7c95232201c4ee290f330d5d75237353 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 19 Oct 2020 11:43:02 +0200 Subject: [PATCH] timeout: don't warn "timestamp value too big" too often Fixes #3657 --- repos/base/src/lib/timeout/timer_connection.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/repos/base/src/lib/timeout/timer_connection.cc b/repos/base/src/lib/timeout/timer_connection.cc index 46e3082cd6..ea56ccafb5 100644 --- a/repos/base/src/lib/timeout/timer_connection.cc +++ b/repos/base/src/lib/timeout/timer_connection.cc @@ -46,10 +46,19 @@ uint64_t Timer::Connection::_ts_to_us_ratio(Timestamp ts, * often nor have much effect on the resulting factor. */ Timestamp const max_ts = ~(Timestamp)0ULL >> shift; - while (ts > max_ts) { - warning("timestamp value too big"); - ts >>= 1; - us >>= 1; + if (ts > max_ts) { + /* + * Reduce the number of warnings printed to not aggravate the problem + * even more. + */ + static unsigned nr_of_warnings { 0 }; + if (nr_of_warnings++ % 1000 == 0) { + warning("timestamp value too big"); + } + while (ts > max_ts) { + ts >>= 1; + us >>= 1; + } } if (!us) { us = 1; } if (!ts) { ts = 1; }