Fix data races in cell_list array members inside enb::phy_common.

master
faluco 3 years ago committed by Andre Puschmann
parent 7b0b76d58e
commit 83b9777220

@ -62,9 +62,9 @@ public:
// Common objects // Common objects
phy_args_t params = {}; phy_args_t params = {};
uint32_t get_nof_carriers_lte() { return static_cast<uint32_t>(cell_list_lte.size()); }; uint32_t get_nof_carriers_lte() { return static_cast<uint32_t>(cell_list_lte.size()); }
uint32_t get_nof_carriers_nr() { return static_cast<uint32_t>(cell_list_nr.size()); }; uint32_t get_nof_carriers_nr() { return static_cast<uint32_t>(cell_list_nr.size()); }
uint32_t get_nof_carriers() { return static_cast<uint32_t>(cell_list_lte.size() + cell_list_nr.size()); }; uint32_t get_nof_carriers() { return static_cast<uint32_t>(cell_list_lte.size() + cell_list_nr.size()); }
uint32_t get_nof_prb(uint32_t cc_idx) uint32_t get_nof_prb(uint32_t cc_idx)
{ {
uint32_t ret = 0; uint32_t ret = 0;
@ -84,7 +84,7 @@ public:
} }
} }
return ret; return ret;
}; }
uint32_t get_nof_ports(uint32_t cc_idx) uint32_t get_nof_ports(uint32_t cc_idx)
{ {
uint32_t ret = 0; uint32_t ret = 0;
@ -97,7 +97,7 @@ public:
} }
return ret; return ret;
}; }
uint32_t get_nof_rf_channels() uint32_t get_nof_rf_channels()
{ {
uint32_t count = 0; uint32_t count = 0;
@ -126,7 +126,7 @@ public:
} }
return ret; return ret;
}; }
double get_dl_freq_hz(uint32_t cc_idx) double get_dl_freq_hz(uint32_t cc_idx)
{ {
double ret = 0.0; double ret = 0.0;
@ -141,7 +141,7 @@ public:
} }
return ret; return ret;
}; }
uint32_t get_rf_port(uint32_t cc_idx) uint32_t get_rf_port(uint32_t cc_idx)
{ {
uint32_t ret = 0; uint32_t ret = 0;
@ -156,7 +156,7 @@ public:
} }
return ret; return ret;
}; }
srsran_cell_t get_cell(uint32_t cc_idx) srsran_cell_t get_cell(uint32_t cc_idx)
{ {
srsran_cell_t c = {}; srsran_cell_t c = {};
@ -164,7 +164,7 @@ public:
c = cell_list_lte[cc_idx].cell; c = cell_list_lte[cc_idx].cell;
} }
return c; return c;
}; }
void set_cell_gain(uint32_t cell_id, float gain_db) void set_cell_gain(uint32_t cell_id, float gain_db)
{ {
@ -174,6 +174,7 @@ public:
// Check if the lte cell was found; // Check if the lte cell was found;
if (it_lte != cell_list_lte.end()) { if (it_lte != cell_list_lte.end()) {
std::lock_guard<std::mutex> lock(cell_gain_mutex);
it_lte->gain_db = gain_db; it_lte->gain_db = gain_db;
return; return;
} }
@ -184,6 +185,7 @@ public:
// Check if the nr cell was found; // Check if the nr cell was found;
if (it_nr != cell_list_nr.end()) { if (it_nr != cell_list_nr.end()) {
std::lock_guard<std::mutex> lock(cell_gain_mutex);
it_nr->gain_db = gain_db; it_nr->gain_db = gain_db;
return; return;
} }
@ -193,6 +195,7 @@ public:
float get_cell_gain(uint32_t cc_idx) float get_cell_gain(uint32_t cc_idx)
{ {
std::lock_guard<std::mutex> lock(cell_gain_mutex);
if (cc_idx < cell_list_lte.size()) { if (cc_idx < cell_list_lte.size()) {
return cell_list_lte.at(cc_idx).gain_db; return cell_list_lte.at(cc_idx).gain_db;
} }
@ -235,6 +238,7 @@ private:
phy_cell_cfg_list_t cell_list_lte; phy_cell_cfg_list_t cell_list_lte;
phy_cell_cfg_list_nr_t cell_list_nr; phy_cell_cfg_list_nr_t cell_list_nr;
std::mutex cell_gain_mutex;
bool have_mtch_stop = false; bool have_mtch_stop = false;
pthread_mutex_t mtch_mutex = {}; pthread_mutex_t mtch_mutex = {};

Loading…
Cancel
Save