From 21fc9d52b1304fd818e0d1d782bd1cfdc49f91e1 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Wed, 21 Jan 2026 08:48:36 -0600 Subject: [PATCH 1/2] Added code to DataWriterModule.cpp to finish reading trigger records from the input queue before stopping. --- plugins/DataWriterModule.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/DataWriterModule.cpp b/plugins/DataWriterModule.cpp index 96b3912..871bb2e 100644 --- a/plugins/DataWriterModule.cpp +++ b/plugins/DataWriterModule.cpp @@ -404,11 +404,18 @@ DataWriterModule::receive_trigger_record(std::unique_ptr& running_flag) { - while (running_flag.load()) { + // 21-Jan-2026, KAB: we want this code to drain all pending TriggerRecords from + // the input queue at end-run time. So, we include a condition that there have + // been 5 or more consecutive timeouts when trying to read from the queue before + // we exit the loop (after running_flag has been set to false). + int consecutive_timeout_count = 0; + while (running_flag.load() || consecutive_timeout_count < 5) { try { std::unique_ptr tr = m_tr_receiver->receive(std::chrono::milliseconds(10)); receive_trigger_record(tr); + consecutive_timeout_count = 0; } catch (const iomanager::TimeoutExpired& excpt) { + ++consecutive_timeout_count; } catch (const ers::Issue& excpt) { ers::warning(excpt); } From 1b66ceba82c4ab285498cd43bb205c2012a82c46 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Tue, 27 Jan 2026 08:46:35 -0600 Subject: [PATCH 2/2] Converted the draining of the input queue in DataWriterModule::do_work to use the new receiver data_pending() method. --- plugins/DataWriterModule.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/DataWriterModule.cpp b/plugins/DataWriterModule.cpp index 871bb2e..09c6f3a 100644 --- a/plugins/DataWriterModule.cpp +++ b/plugins/DataWriterModule.cpp @@ -404,18 +404,14 @@ DataWriterModule::receive_trigger_record(std::unique_ptr& running_flag) { - // 21-Jan-2026, KAB: we want this code to drain all pending TriggerRecords from - // the input queue at end-run time. So, we include a condition that there have - // been 5 or more consecutive timeouts when trying to read from the queue before - // we exit the loop (after running_flag has been set to false). - int consecutive_timeout_count = 0; - while (running_flag.load() || consecutive_timeout_count < 5) { + // 27-Jan-2026, KAB: we want this code to drain all pending TriggerRecords from + // the input queue at end-run time. So, we check if there is data in the queue + // and continue the while loop if there is any. + while (running_flag.load() || m_tr_receiver->data_pending()) { try { std::unique_ptr tr = m_tr_receiver->receive(std::chrono::milliseconds(10)); receive_trigger_record(tr); - consecutive_timeout_count = 0; } catch (const iomanager::TimeoutExpired& excpt) { - ++consecutive_timeout_count; } catch (const ers::Issue& excpt) { ers::warning(excpt); }