Fix data races in proc_bsr_nr and proc_ra_nr.

master
faluco 3 years ago committed by faluco
parent 08e9b0b5c1
commit 3f0d4f0293

@ -60,6 +60,8 @@ void proc_bsr_nr::set_trigger(bsr_trigger_type_t new_trigger)
void proc_bsr_nr::reset() void proc_bsr_nr::reset()
{ {
std::lock_guard<std::mutex> lock(mutex);
timer_periodic.stop(); timer_periodic.stop();
timer_retx.stop(); timer_retx.stop();

@ -86,6 +86,7 @@ void proc_ra_nr::start_by_mac()
bool proc_ra_nr::is_rar_opportunity(uint32_t tti) bool proc_ra_nr::is_rar_opportunity(uint32_t tti)
{ {
std::lock_guard<std::mutex> lock(mutex);
// TODO replace second "&&"" by rar_timeout_timer.running if timer thread safe and delayed starting (tti+3) // 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 && 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)) { 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() uint16_t proc_ra_nr::get_rar_rnti()
{ {
std::lock_guard<std::mutex> lock(mutex);
if (rar_rnti == SRSRAN_INVALID_RNTI || state != WAITING_FOR_RESPONSE_RECEPTION) { 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"); logger.error("Requested ra rnti is invalid. Anyway we return an invalid ra rnti");
return SRSRAN_INVALID_RNTI; return SRSRAN_INVALID_RNTI;
@ -106,6 +108,7 @@ uint16_t proc_ra_nr::get_rar_rnti()
bool proc_ra_nr::has_rar_rnti() bool proc_ra_nr::has_rar_rnti()
{ {
std::lock_guard<std::mutex> lock(mutex);
if (rar_rnti != SRSRAN_INVALID_RNTI) { if (rar_rnti != SRSRAN_INVALID_RNTI) {
return true; return true;
} }

Loading…
Cancel
Save