From 4ef1ac264922c26232f75f3eec1abf52f4d3ff12 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 30 Aug 2021 15:03:51 +0200 Subject: [PATCH] gw: (re-)use class mutex when updating the DL/UL metrics --- srsue/src/stack/upper/gw.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index af75a7438..2df179468 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -88,6 +88,8 @@ void gw::stop() void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti) { + std::lock_guard lock(gw_mutex); + std::chrono::duration secs = std::chrono::high_resolution_clock::now() - metrics_tp; double dl_tput_mbps_real_time = (dl_tput_bytes * 8 / (double)1e6) / secs.count(); @@ -115,7 +117,10 @@ void gw::get_metrics(gw_metrics_t& m, const uint32_t nof_tti) void gw::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.info(pdu->msg, pdu->N_bytes, "RX PDU. Stack latency: %ld us", pdu->get_latency_us().count()); - dl_tput_bytes += pdu->N_bytes; + { + std::unique_lock lock(gw_mutex); + dl_tput_bytes += pdu->N_bytes; + } if (!if_up) { logger.warning("TUN/TAP not up - dropping gw RX message"); } else if (pdu->N_bytes < 20) { @@ -143,7 +148,10 @@ void gw::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) "RX MCH PDU (%d B). Stack latency: %ld us", pdu->N_bytes, pdu->get_latency_us().count()); - dl_tput_bytes += pdu->N_bytes; + { + std::unique_lock lock(gw_mutex); + dl_tput_bytes += pdu->N_bytes; + } // Hack to drop initial 2 bytes pdu->msg += 2;