From f2851b037e84e745e597bfd29b6d12152e9f7b79 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 6 Feb 2020 15:41:50 +0100 Subject: [PATCH] Fix concurrency issue in set_crnti() --- srsue/hdr/phy/phy_common.h | 1 + srsue/src/phy/phy_common.cc | 2 ++ srsue/src/phy/sf_worker.cc | 3 +++ 3 files changed, 6 insertions(+) diff --git a/srsue/hdr/phy/phy_common.h b/srsue/hdr/phy/phy_common.h index 09f97402e..b838380d5 100644 --- a/srsue/hdr/phy/phy_common.h +++ b/srsue/hdr/phy/phy_common.h @@ -214,6 +214,7 @@ private: received_ack_t pending_dl_ack[TTIMOD_SZ][SRSLTE_MAX_CARRIERS] = {}; uint32_t pending_dl_dai[TTIMOD_SZ][SRSLTE_MAX_CARRIERS] = {}; std::mutex pending_dl_ack_mutex; + std::mutex pending_dl_grant_mutex; // Cross-carried grants scheduled from PCell typedef struct { diff --git a/srsue/src/phy/phy_common.cc b/srsue/src/phy/phy_common.cc index e37aa4840..cc827cf4e 100644 --- a/srsue/src/phy/phy_common.cc +++ b/srsue/src/phy/phy_common.cc @@ -428,6 +428,7 @@ void phy_common::set_dl_pending_grant(uint32_t tti, uint32_t grant_cc_idx, const srslte_dci_dl_t* dl_dci) { + std::lock_guard lock(pending_dl_grant_mutex); if (!pending_dl_grant[tti % FDD_HARQ_DELAY_MS][cc_idx].enable) { pending_dl_grant[tti % FDD_HARQ_DELAY_MS][cc_idx].dl_dci = *dl_dci; pending_dl_grant[tti % FDD_HARQ_DELAY_MS][cc_idx].grant_cc_idx = grant_cc_idx; @@ -439,6 +440,7 @@ void phy_common::set_dl_pending_grant(uint32_t tti, bool phy_common::get_dl_pending_grant(uint32_t tti, uint32_t cc_idx, uint32_t* grant_cc_idx, srslte_dci_dl_t* dl_dci) { + std::lock_guard lock(pending_dl_grant_mutex); if (pending_dl_grant[tti % FDD_HARQ_DELAY_MS][cc_idx].enable) { // Read grant if (dl_dci) { diff --git a/srsue/src/phy/sf_worker.cc b/srsue/src/phy/sf_worker.cc index 27a6f5838..465787805 100644 --- a/srsue/src/phy/sf_worker.cc +++ b/srsue/src/phy/sf_worker.cc @@ -149,6 +149,7 @@ void sf_worker::set_cfo(const uint32_t& cc_idx, float cfo) void sf_worker::set_crnti(uint16_t rnti) { + std::lock_guard lock(mutex); for (auto& cc_worker : cc_workers) { cc_worker->set_crnti(rnti); } @@ -156,6 +157,7 @@ void sf_worker::set_crnti(uint16_t rnti) void sf_worker::set_tdd_config(srslte_tdd_config_t config) { + std::lock_guard lock(mutex); for (auto& cc_worker : cc_workers) { cc_worker->set_tdd_config(config); } @@ -164,6 +166,7 @@ void sf_worker::set_tdd_config(srslte_tdd_config_t config) void sf_worker::enable_pregen_signals(bool enabled) { + std::lock_guard lock(mutex); for (auto& cc_worker : cc_workers) { cc_worker->enable_pregen_signals(enabled); }