From 120ad5c72f025cee0f2a5343e423f9052752c8ed Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 21 Oct 2021 16:35:07 +0200 Subject: [PATCH] ue: store new EARFCN in the foreground of cell_select to avoid race conditions with the other cmd_worker --- srsue/hdr/phy/phy.h | 3 +++ srsue/src/phy/phy.cc | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index 2f00f9fdf..391e3d5b0 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -190,6 +190,9 @@ private: // Tracks the current selected cell (last call to cell_select) srsran_cell_t selected_cell = {}; + // Tracks the current selected EARFCN (last call to cell_select) + uint32_t selected_earfcn = 0; + static void set_default_args(phy_args_t& args); bool check_args(const phy_args_t& args); }; diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 7f6b9b72b..a71c39aca 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -244,8 +244,7 @@ void phy::set_cells_to_meas(uint32_t earfcn, const std::set& pci) // measurements to avoid a concurrency issue cmd_worker.add_cmd([this, earfcn, pci]() { // Check if the EARFCN matches with serving cell - uint32_t pcell_earfcn = 0; - sfsync.get_current_cell(nullptr, &pcell_earfcn); + uint32_t pcell_earfcn = selected_earfcn; bool available = (pcell_earfcn == earfcn); // Find if there is secondary serving cell configured with the specified EARFCN @@ -303,6 +302,10 @@ bool phy::cell_select(phy_cell_t cell) // Indicate workers that cell selection is in progress common.cell_is_selecting = true; + // Update EARCN before starting the background task to make sure is taken into account when finding carriers to + // measure inter-frequency neighbours (see set_cells_to_meas) + selected_earfcn = cell.earfcn; + cmd_worker_cell.add_cmd([this, cell]() { // Wait SYNC transitions to IDLE sfsync.wait_idle();