From 412051106e2a89865bb1158f30609ce5bb98de6e Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Thu, 10 Oct 2024 15:45:21 +0100 Subject: [PATCH] Fix debug build when log_timestamp_ordering_grace_period is set to zero (#607) --- CHANGELOG.md | 2 ++ include/quill/backend/BackendWorker.h | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7cfb68f..c234e7d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,8 @@ used to create another `Logger` with similar configuration - Fixed a build issue when compiling with `-fno-rtti`. This ensures compatibility with projects that disable `RTTI` ([#604](https://github.com/odygrd/quill/issues/604)) +- Fixed an incorrectly triggered assertion in debug builds when `BackendOptions::log_timestamp_ordering_grace_period` is + set to 0 ([#605](https://github.com/odygrd/quill/issues/605)) ## v7.3.0 diff --git a/include/quill/backend/BackendWorker.h b/include/quill/backend/BackendWorker.h index a7b9c3ee..cb25cadf 100644 --- a/include/quill/backend/BackendWorker.h +++ b/include/quill/backend/BackendWorker.h @@ -517,13 +517,15 @@ class BackendWorker _rdtsc_clock.load(std::memory_order_relaxed)->time_since_epoch(transit_event->timestamp); } - // Check if strict log timestamp order is enabled and the clock source is not User. - if (transit_event->logger_base->clock_source != ClockSourceType::User) + // Check if strict log timestamp order is enabled and the clock source is not User + if ((transit_event->logger_base->clock_source != ClockSourceType::User) && + (ts_now != std::numeric_limits::max())) { - // We skip checking against `ts_now` for custom timestamps by the user + // We only check against `ts_now` for real timestamps, not custom timestamps by the user, and + // when the grace period is enabled #ifndef NDEBUG - // Check the timestmaps we are comparign have the same digits + // Check the timestamps we are comparing have the same digits auto count_digits = [](uint64_t number) { uint32_t digits = 0;