Fix data race in ue mac metrics.

master
faluco 3 years ago committed by faluco
parent 7dae4a491e
commit f96ee097b4

@ -146,7 +146,10 @@ void mac::reconfiguration(const uint32_t& cc_idx, const bool& enable)
// Implement Section 5.9 // Implement Section 5.9
void mac::reset() void mac::reset()
{ {
bzero(&metrics, sizeof(mac_metrics_t)); {
std::lock_guard<std::mutex> lock(metrics_mutex);
bzero(&metrics, sizeof(mac_metrics_t));
}
Info("Resetting MAC"); Info("Resetting MAC");
@ -201,6 +204,7 @@ void mac::run_tti(const uint32_t tti)
ra_procedure.update_rar_window(ra_window); ra_procedure.update_rar_window(ra_window);
// Count TTI for metrics // Count TTI for metrics
std::lock_guard<std::mutex> lock(metrics_mutex);
for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) { for (uint32_t i = 0; i < SRSRAN_MAX_CARRIERS; i++) {
metrics[i].nof_tti++; 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); pcap->write_dl_mch(mch_payload_buffer, len, true, phy_h->get_current_tti(), 0);
} }
std::lock_guard<std::mutex> lock(metrics_mutex);
metrics[0].rx_brate += len * 8; metrics[0].rx_brate += len * 8;
} else { } else {
std::lock_guard<std::mutex> lock(metrics_mutex);
metrics[0].rx_errors++; metrics[0].rx_errors++;
} }
std::lock_guard<std::mutex> lock(metrics_mutex);
metrics[0].rx_pkts++; metrics[0].rx_pkts++;
} }

Loading…
Cancel
Save