diff --git a/srsue/hdr/stack/mac/mac.h b/srsue/hdr/stack/mac/mac.h index 044e5a478..66bd0c0ca 100644 --- a/srsue/hdr/stack/mac/mac.h +++ b/srsue/hdr/stack/mac/mac.h @@ -158,7 +158,7 @@ private: mac_metrics_t metrics[SRSRAN_MAX_CARRIERS] = {}; - bool initialized = false; + std::atomic initialized = {false}; const uint8_t PCELL_CC_IDX = 0; }; diff --git a/srsue/src/stack/mac/mac.cc b/srsue/src/stack/mac/mac.cc index dcd504949..ecd283490 100644 --- a/srsue/src/stack/mac/mac.cc +++ b/srsue/src/stack/mac/mac.cc @@ -473,11 +473,11 @@ void mac::process_pdus() // dispatch work to stack thread auto ret = stack_task_dispatch_queue.try_push([this]() { bool have_data = true; - while (initialized and have_data) { + while (initialized.load(std::memory_order_relaxed) and have_data) { have_data = demux_unit.process_pdus(); } }); - if (ret.is_error()) { + if (ret.is_error() && initialized.load(std::memory_order_relaxed)) { Warning("Failed to dispatch mac::%s task to stack thread", __func__); } }