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");