From 3f0d4f0293d9d48d640534a0787db01d8148bbfa Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 27 Oct 2021 12:22:14 +0200 Subject: [PATCH] Fix data races in proc_bsr_nr and proc_ra_nr. --- srsue/src/stack/mac_nr/proc_bsr_nr.cc | 2 ++ srsue/src/stack/mac_nr/proc_ra_nr.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/srsue/src/stack/mac_nr/proc_bsr_nr.cc b/srsue/src/stack/mac_nr/proc_bsr_nr.cc index b06e0ca44..753ff8f38 100644 --- a/srsue/src/stack/mac_nr/proc_bsr_nr.cc +++ b/srsue/src/stack/mac_nr/proc_bsr_nr.cc @@ -60,6 +60,8 @@ void proc_bsr_nr::set_trigger(bsr_trigger_type_t new_trigger) void proc_bsr_nr::reset() { + std::lock_guard lock(mutex); + timer_periodic.stop(); timer_retx.stop(); diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 1c088c5f0..afef7bbf7 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -86,6 +86,7 @@ void proc_ra_nr::start_by_mac() bool proc_ra_nr::is_rar_opportunity(uint32_t tti) { + std::lock_guard lock(mutex); // TODO replace second "&&"" by rar_timeout_timer.running if timer thread safe and delayed starting (tti+3) if (state == WAITING_FOR_RESPONSE_RECEPTION && ra_window_start > 0 && ra_window_length > 0 && mac_nr::is_in_window(tti, &ra_window_start, &ra_window_length)) { @@ -97,6 +98,7 @@ bool proc_ra_nr::is_rar_opportunity(uint32_t tti) uint16_t proc_ra_nr::get_rar_rnti() { + std::lock_guard lock(mutex); if (rar_rnti == SRSRAN_INVALID_RNTI || state != WAITING_FOR_RESPONSE_RECEPTION) { logger.error("Requested ra rnti is invalid. Anyway we return an invalid ra rnti"); return SRSRAN_INVALID_RNTI; @@ -106,6 +108,7 @@ uint16_t proc_ra_nr::get_rar_rnti() bool proc_ra_nr::has_rar_rnti() { + std::lock_guard lock(mutex); if (rar_rnti != SRSRAN_INVALID_RNTI) { return true; }