From 66f6c11561acaa0bac95c9b52d6bd6d8d46d0e57 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 19 Jan 2022 13:12:36 +0100 Subject: [PATCH] Fix concurrent issues in dummy radio used in nr_phy_test --- lib/include/srsran/radio/radio_dummy.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/include/srsran/radio/radio_dummy.h b/lib/include/srsran/radio/radio_dummy.h index 4d947a41b..36e42070b 100644 --- a/lib/include/srsran/radio/radio_dummy.h +++ b/lib/include/srsran/radio/radio_dummy.h @@ -45,7 +45,7 @@ private: std::vector rx_ring_buffers; std::vector tx_ring_buffers; std::mutex tx_mutex; - double srate_hz = 0.0f; + std::atomic srate_hz = {0.0f}; std::atomic rx_gain = {1.0f}; std::atomic tx_gain = {1.0f}; cf_t* temp_buffer = nullptr; @@ -211,9 +211,12 @@ public: uint64_t tx_time_n = srsran_timestamp_uint64(&tx_time.get(0), srate_hz); // Check if the transmission is in the past - if (tx_time_n < tx_timestamp) { - logger.error("Error transmission in the past for %d samples", (int)(tx_timestamp - tx_time_n)); - return false; + { + std::lock_guard lock(tx_mutex); + if (tx_time_n < tx_timestamp) { + logger.error("Error transmission in the past for %d samples", (int)(tx_timestamp - tx_time_n)); + return false; + } } // Advance TX to timestamp