Fix data races in proc_bsr_nr and proc_ra_nr.

This commit is contained in:
faluco 2021-10-27 12:22:14 +02:00 committed by faluco
parent 08e9b0b5c1
commit 3f0d4f0293
2 changed files with 5 additions and 0 deletions

View File

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

View File

@ -86,6 +86,7 @@ void proc_ra_nr::start_by_mac()
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)
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<std::mutex> 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<std::mutex> lock(mutex);
if (rar_rnti != SRSRAN_INVALID_RNTI) {
return true;
}