From 7e59c46309bae031e4ae18296f911063d08ded79 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 21 Feb 2025 08:29:03 -0400 Subject: [PATCH] MT#62181 wheeltimer: add logging Annotate timer operations with debug logging. These are taken from RegistrationTimer. Change-Id: Ic0eac4b1cc529f416340d74b7c69e162421812a7 --- core/sip/wheeltimer.cpp | 13 ++++++++++++- core/sip/wheeltimer.h | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/sip/wheeltimer.cpp b/core/sip/wheeltimer.cpp index 8fa8c5e1..11954447 100644 --- a/core/sip/wheeltimer.cpp +++ b/core/sip/wheeltimer.cpp @@ -116,6 +116,8 @@ void _wheeltimer::run() void _wheeltimer::process_current_timers(timer_list& list, std::unique_lock& lock) { + DBG("firing %zd timers\n", list.size()); + while (!list.empty()) { auto* t = list.front(); @@ -124,6 +126,7 @@ void _wheeltimer::process_current_timers(timer_list& list, std::unique_lockfire(); lock.lock(); @@ -170,6 +173,9 @@ void _wheeltimer::place_timer(timer* t, uint64_t us, uint64_t latest) break; // can't get much better } } + + DBG("found bucket %" PRIu64 " with least load %zd (between %" PRIu64 " and %" PRIu64 ")\n", + bucket, least, us, latest); } add_timer_to_bucket(t, bucket); @@ -178,11 +184,16 @@ void _wheeltimer::place_timer(timer* t, uint64_t us, uint64_t latest) void _wheeltimer::add_timer_to_bucket(timer* t, uint64_t bucket) { t->link(buckets[bucket]); + DBG("inserted timer [%p] in bucket %" PRIu64 " (now sized %zd)\n", + t, bucket, buckets[bucket].size()); } void _wheeltimer::delete_timer(timer* t) { - t->disarm(); + if (t->disarm()) + DBG("successfully removed timer [%p]\n", t); + else + DBG("timer [%p] not found for removing\n", t); delete t; } diff --git a/core/sip/wheeltimer.h b/core/sip/wheeltimer.h index d659fd12..91e28539 100644 --- a/core/sip/wheeltimer.h +++ b/core/sip/wheeltimer.h @@ -86,14 +86,17 @@ private: pos = list->begin(); } - void disarm() + bool disarm() { expires = 0; if (list) { list->erase(pos); list = NULL; + return true; } + + return false; } uint64_t expires; // absolute, microseconds, set after arming timer