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

@ -154,7 +154,7 @@ private:
srslog::basic_logger& enb_log; srslog::basic_logger& enb_log;
all_args_t args = {}; all_args_t args = {};
bool started = false; std::atomic<bool> started = {false};
phy_cfg_t phy_cfg = {}; phy_cfg_t phy_cfg = {};
rrc_cfg_t rrc_cfg = {}; rrc_cfg_t rrc_cfg = {};

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

Loading…
Cancel
Save