From dfd16718fe0dab4b99ae9d7eeafc6d5fb591bcb5 Mon Sep 17 00:00:00 2001 From: faluco Date: Fri, 29 Oct 2021 10:56:22 +0200 Subject: [PATCH] Fix data race in proc_sr_nr. --- srsue/src/stack/mac_nr/proc_sr_nr.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/srsue/src/stack/mac_nr/proc_sr_nr.cc b/srsue/src/stack/mac_nr/proc_sr_nr.cc index a5fc7a513..b9a104117 100644 --- a/srsue/src/stack/mac_nr/proc_sr_nr.cc +++ b/srsue/src/stack/mac_nr/proc_sr_nr.cc @@ -45,8 +45,11 @@ void proc_sr_nr::reset_nolock() int32_t proc_sr_nr::set_config(const srsran::sr_cfg_nr_t& cfg_) { - // disable by default - cfg.enabled = false; + { + std::lock_guard lock(mutex); + // disable by default + cfg.enabled = false; + } if (cfg_.num_items != 1) { logger.error("Only one SR config supported. Disabling SR."); @@ -69,8 +72,11 @@ int32_t proc_sr_nr::set_config(const srsran::sr_cfg_nr_t& cfg_) logger.info("SR: Disabling procedure"); } - // store config - cfg = cfg_; + { + std::lock_guard lock(mutex); + // store config + cfg = cfg_; + } return SRSRAN_SUCCESS; }