Fix race condition when destroying the gnb stack class.

The gnb stack class could be destroyed concurrently while still running its task scheduler thread.
master
faluco 3 years ago committed by Andre Puschmann
parent 28bbaa7816
commit aa0c936f50

@ -106,6 +106,7 @@ public:
private:
void run_thread() final;
void tti_clock_impl();
void stop_impl();
// args
gnb_stack_args_t args = {};
@ -121,7 +122,7 @@ private:
static const int STACK_MAIN_THREAD_PRIO = 4;
srsran::task_scheduler task_sched;
srsran::task_multiqueue::queue_handle sync_task_queue, ue_task_queue, gtpu_task_queue, mac_task_queue,
metrics_task_queue;
metrics_task_queue, gnb_task_queue;
// metrics waiting condition
std::mutex metrics_mutex;

@ -35,6 +35,7 @@ gnb_stack_nr::gnb_stack_nr(srslog::sink& log_sink) :
gtpu_task_queue = task_sched.make_task_queue();
mac_task_queue = task_sched.make_task_queue();
metrics_task_queue = task_sched.make_task_queue();
gnb_task_queue = task_sched.make_task_queue();
}
gnb_stack_nr::~gnb_stack_nr()
@ -97,15 +98,23 @@ int gnb_stack_nr::init(const gnb_stack_args_t& args_,
void gnb_stack_nr::stop()
{
if (running) {
rrc.stop();
pdcp.stop();
mac.stop();
srsran::get_background_workers().stop();
running = false;
gnb_task_queue.push([this]() { stop_impl(); });
wait_thread_finish();
}
}
void gnb_stack_nr::stop_impl()
{
rrc.stop();
pdcp.stop();
mac.stop();
task_sched.stop();
srsran::get_background_workers().stop();
running = false;
}
bool gnb_stack_nr::switch_on()
{
// Nothing to be done here

Loading…
Cancel
Save