diff --git a/srsenb/hdr/stack/gnb_stack_nr.h b/srsenb/hdr/stack/gnb_stack_nr.h index 83fe9317f..2161b8ca9 100644 --- a/srsenb/hdr/stack/gnb_stack_nr.h +++ b/srsenb/hdr/stack/gnb_stack_nr.h @@ -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; diff --git a/srsenb/src/stack/gnb_stack_nr.cc b/srsenb/src/stack/gnb_stack_nr.cc index 417f936a9..da21498fd 100644 --- a/srsenb/src/stack/gnb_stack_nr.cc +++ b/srsenb/src/stack/gnb_stack_nr.cc @@ -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