From 8d802e2acae057d5bf5d64982269394783248c34 Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 15 Sep 2021 10:57:18 +0200 Subject: [PATCH] Fix a data race in the simulate_rf global variable. --- srsue/src/main.cc | 4 ++-- srsue/src/stack/rrc/rrc.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 15a5a0c12..fa1f9825f 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -34,7 +34,7 @@ #include #include -extern bool simulate_rlf; +extern std::atomic simulate_rlf; using namespace std; using namespace srsue; @@ -639,7 +639,7 @@ static void* input_loop(void*) metrics_screen->toggle_print(do_metrics); } } else if (key == "rlf") { - simulate_rlf = true; + simulate_rlf.store(true, std::memory_order_relaxed); cout << "Sending Radio Link Failure" << endl; } else if (key == "q") { // let the signal handler do the job diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 03d1d6843..0ce979318 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -32,7 +32,7 @@ #include #include -bool simulate_rlf = false; +std::atomic simulate_rlf{false}; using namespace srsran; using namespace asn1::rrc; @@ -203,9 +203,9 @@ void rrc::run_tti() return; } - if (simulate_rlf) { + if (simulate_rlf.load(std::memory_order_relaxed)) { radio_link_failure_process(); - simulate_rlf = false; + simulate_rlf.store(false, std::memory_order_relaxed); } // Process pending PHY measurements in IDLE/CONNECTED @@ -2779,7 +2779,7 @@ void rrc::release_drb(uint32_t drb_id) */ uint32_t rrc::get_lcid_for_drb_id(const uint32_t& drb_id) { - uint32_t lcid = 0; + uint32_t lcid = 0; if (drbs.find(drb_id) != drbs.end()) { asn1::rrc::drb_to_add_mod_s drb_cnfg = drbs[drb_id]; if (drb_cnfg.lc_ch_id_present) {