Fix a data race during enb initialization.

The stack unique pointer in the enb class is written while the phy workers are calling enb::tti_clock() where it is read.
Avoid the read access until the whole class has been properly initialized.
master
faluco 3 years ago committed by faluco
parent 611255aa5f
commit feec3c5905

@ -153,8 +153,8 @@ private:
srslog::sink& log_sink;
srslog::basic_logger& enb_log;
all_args_t args = {};
bool started = false;
all_args_t args = {};
std::atomic<bool> started = {false};
phy_cfg_t phy_cfg = {};
rrc_cfg_t rrc_cfg = {};
@ -164,8 +164,8 @@ private:
x2_adapter x2;
std::unique_ptr<enb_stack_base> eutra_stack = nullptr;
std::unique_ptr<enb_stack_base> nr_stack = nullptr;
std::unique_ptr<srsran::radio_base> radio = nullptr;
std::unique_ptr<enb_phy_base> phy = nullptr;
std::unique_ptr<srsran::radio_base> radio = nullptr;
std::unique_ptr<enb_phy_base> phy = nullptr;
// System metrics processor.
srsran::sys_metrics_processor sys_proc;

@ -194,12 +194,15 @@ void enb::print_pool()
bool enb::get_metrics(enb_metrics_t* m)
{
if (!started) {
return false;
}
radio->get_metrics(&m->rf);
phy->get_metrics(m->phy);
if (eutra_stack) {
eutra_stack->get_metrics(&m->stack);
}
m->running = started;
m->running = true;
m->sys = sys_proc.get_metrics();
return true;
}
@ -231,6 +234,9 @@ std::string enb::get_build_string()
void enb::toggle_padding()
{
if (!started) {
return;
}
if (eutra_stack) {
eutra_stack->toggle_padding();
}
@ -238,6 +244,9 @@ void enb::toggle_padding()
void enb::tti_clock()
{
if (!started) {
return;
}
if (eutra_stack) {
eutra_stack->tti_clock();
}

Loading…
Cancel
Save