From 186c78f56a7d7763e1ab5f0fb50f2afe14d2698c Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 13 Oct 2026 19:57:15 +0200 Subject: [PATCH] receiver: allow 30 s instead of 10 s for the image pusher to return its buffers after END After the END message the receiver waits for every image buffer the pusher still holds (for ZeroMQ: zero-copy messages freed once libzmq has transmitted them) before calling Finalize(); on expiry the collection fails with "Send commands not finalized". The limit was a 10 s literal repeated in the FPGA and Lite receivers; it is now one constant, SendFinalizeTimeout, in the JFJochReceiver base class. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3 --- receiver/JFJochReceiver.h | 3 +++ receiver/JFJochReceiverFPGA.cpp | 7 ++++--- receiver/JFJochReceiverLite.cpp | 7 ++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/receiver/JFJochReceiver.h b/receiver/JFJochReceiver.h index 3bd7a16d8..d65f6235c 100644 --- a/receiver/JFJochReceiver.h +++ b/receiver/JFJochReceiver.h @@ -46,6 +46,9 @@ protected: std::chrono::time_point start_time; std::chrono::time_point end_time; + // After END, how long the image pusher may take to return every image buffer it still holds + constexpr static auto SendFinalizeTimeout = std::chrono::seconds(30); + int64_t max_image_number_sent = 0; std::mutex max_image_number_sent_mutex; void UpdateMaxImageSent(int64_t image_number); diff --git a/receiver/JFJochReceiverFPGA.cpp b/receiver/JFJochReceiverFPGA.cpp index 3e914d5d1..4e2c775e7 100644 --- a/receiver/JFJochReceiverFPGA.cpp +++ b/receiver/JFJochReceiverFPGA.cpp @@ -615,9 +615,10 @@ void JFJochReceiverFPGA::FinalizeMeasurement() { logger.Info("Devices stopped"); - if (!image_buffer.CheckIfBufferReturned(std::chrono::seconds(10))) { - logger.Error("Send commands not finalized in 10 seconds"); - throw JFJochException(JFJochExceptionCategory::ZeroMQ, "Send commands not finalized in 10 seconds"); + if (!image_buffer.CheckIfBufferReturned(SendFinalizeTimeout)) { + logger.Error("Send commands not finalized in {} seconds", SendFinalizeTimeout.count()); + throw JFJochException(JFJochExceptionCategory::ZeroMQ, "Send commands not finalized in " + + std::to_string(SendFinalizeTimeout.count()) + " seconds"); } logger.Info("Receiving data done"); diff --git a/receiver/JFJochReceiverLite.cpp b/receiver/JFJochReceiverLite.cpp index a84a8487a..25c5f738b 100644 --- a/receiver/JFJochReceiverLite.cpp +++ b/receiver/JFJochReceiverLite.cpp @@ -185,9 +185,10 @@ void JFJochReceiverLite::MeasurementThread() { // Send end message out SendEndMessage(); - if (!image_buffer.CheckIfBufferReturned(std::chrono::seconds(10))) { - logger.Error("Send commands not finalized in 10 seconds"); - throw JFJochException(JFJochExceptionCategory::ZeroMQ, "Send commands not finalized in 10 seconds"); + if (!image_buffer.CheckIfBufferReturned(SendFinalizeTimeout)) { + logger.Error("Send commands not finalized in {} seconds", SendFinalizeTimeout.count()); + throw JFJochException(JFJochExceptionCategory::ZeroMQ, "Send commands not finalized in " + + std::to_string(SendFinalizeTimeout.count()) + " seconds"); } logger.Info("All images sent through ZeroMQ");