From f96ee097b4422e7068834cc93356d980bca80d22 Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 15 Sep 2021 13:32:30 +0200 Subject: [PATCH] Fix data race in ue mac metrics. --- srsue/src/stack/mac/mac.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index 0cfe6b663..e15d3d116 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -146,7 +146,10 @@ void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable) // Implement Section 5.9 void mac::reset() { - bzero(&metrics, sizeof(mac_metrics_t)); + { + std::lock_guard lock(metrics_mutex); + bzero(&metrics, sizeof(mac_metrics_t)); + } Info("Resetting MAC"); @@ -201,6 +204,7 @@ void mac::run_tti(const uint32_t tti) ra_procedure.update_rar_window(ra_window); // Count TTI for metrics + std::lock_guard lock(metrics_mutex); for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { metrics[i].nof_tti++; } @@ -346,10 +350,13 @@ void mac::mch_decoded(uint32_t len, bool crc) pcap->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti(), 0); } + std::lock_guard lock(metrics_mutex); metrics[0].rx_brate += len * 8; } else { + std::lock_guard lock(metrics_mutex); metrics[0].rx_errors++; } + std::lock_guard lock(metrics_mutex); metrics[0].rx_pkts++; }