diff --git a/srsue/hdr/stack/mac_nr/proc_ra_nr.h b/srsue/hdr/stack/mac_nr/proc_ra_nr.h index d3e2a02b0..3658c0c59 100644 --- a/srsue/hdr/stack/mac_nr/proc_ra_nr.h +++ b/srsue/hdr/stack/mac_nr/proc_ra_nr.h @@ -64,6 +64,7 @@ private: int ra_window_length = -1, ra_window_start = -1; uint16_t rar_rnti = SRSRAN_INVALID_RNTI; uint16_t temp_crnti = SRSRAN_INVALID_RNTI; + std::mutex mutex; srsran::rach_nr_cfg_t rach_cfg = {}; bool configured = false; diff --git a/srsue/src/stack/mac_nr/proc_ra_nr.cc b/srsue/src/stack/mac_nr/proc_ra_nr.cc index 402bec56b..745216473 100644 --- a/srsue/src/stack/mac_nr/proc_ra_nr.cc +++ b/srsue/src/stack/mac_nr/proc_ra_nr.cc @@ -114,11 +114,13 @@ bool proc_ra_nr::has_rar_rnti() bool proc_ra_nr::has_temp_crnti() { + std::lock_guard lock(mutex); return temp_crnti != SRSRAN_INVALID_RNTI; } uint16_t proc_ra_nr::get_temp_crnti() { + std::lock_guard lock(mutex); return temp_crnti; } @@ -180,6 +182,7 @@ void proc_ra_nr::ra_preamble_transmission() // 5.1.4 Random Access Preamble transmission void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb) { + std::lock_guard lock(mutex); if (state != WAITING_FOR_RESPONSE_RECEPTION) { logger.warning( "Wrong state for ra reponse reception %s (expected state %s)", @@ -265,6 +268,7 @@ void proc_ra_nr::ra_contention_resolution(uint64_t rx_contention_id) void proc_ra_nr::ra_completion() { + std::lock_guard lock(mutex); if (state != WAITING_FOR_COMPLETION) { logger.warning("Wrong state for ra completion by phy %s (expected state %s)", srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), @@ -279,6 +283,7 @@ void proc_ra_nr::ra_completion() void proc_ra_nr::ra_error() { + std::lock_guard lock(mutex); temp_crnti = SRSRAN_INVALID_RNTI; preamble_transmission_counter++; contention_resolution_timer.stop();