diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index a446f597f..39c34c8ee 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -171,6 +171,8 @@ private: mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {}; + bool initialized = false; + /* Class to process MAC PDUs from DEMUX unit */ class pdu_process : public thread { public: diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index 52ce67a07..002a9fcb9 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -88,14 +88,18 @@ bool mac::init(phy_interface_mac_lte* phy, rlc_interface_mac* rlc, rrc_interface reset(); + initialized = true; + return true; } void mac::stop() { - pdu_process_thread.stop(); - - run_tti(0); // make sure it's not locked after last TTI + if (initialized) { + pdu_process_thread.stop(); + run_tti(0); // make sure it's not locked after last TTI + initialized = false; + } } void mac::start_pcap(srslte::mac_pcap* pcap_) diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index dc347d7bd..10815da4a 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -130,14 +130,14 @@ void ue_stack_lte::stop() { if (running) { pending_tasks.push([this]() { stop_impl(); }); - running = false; - wait_thread_finish(); } } void ue_stack_lte::stop_impl() { + running = false; + usim->stop(); nas.stop(); rrc.stop();