From c55b2ece8f47107de4ec88e973e63d1f667ce430 Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 6 Aug 2024 10:38:18 +0200 Subject: [PATCH] threading/Manager: Switch inf bucket from infinity() to max() For uint64_t, std::numeric_limits::has_infinity is false and infinity() actually returns 0. Use uint64_t's max() instead. We could cast to double and use the double infinity, but this seems reasonable, too. This was found while trying to provoke some pending messages and being confused why all but the "inf" bucket increased. --- src/threading/Manager.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/threading/Manager.cc b/src/threading/Manager.cc index de6e7008b9..beafba7758 100644 --- a/src/threading/Manager.cc +++ b/src/threading/Manager.cc @@ -2,6 +2,8 @@ #include #include +#include +#include #include "zeek/Event.h" #include "zeek/IPAddr.h" @@ -22,8 +24,7 @@ void HeartbeatTimer::Dispatch(double t, bool is_expire) { } // namespace detail -static std::vector pending_bucket_brackets = {1, 10, 100, - 1000, 10000, std::numeric_limits::infinity()}; +static std::vector pending_bucket_brackets = {1, 10, 100, 1000, 10000, std::numeric_limits::max()}; Manager::Manager() { DBG_LOG(DBG_THREADING, "Creating thread manager ..."); @@ -130,7 +131,7 @@ void Manager::InitPostScript() { for ( auto upper_limit : pending_bucket_brackets ) { std::string upper_limit_str; - if ( upper_limit == std::numeric_limits::infinity() ) + if ( upper_limit == std::numeric_limits::max() ) upper_limit_str = "inf"; else upper_limit_str = std::to_string(upper_limit);