From 98a50b75977347edcebfb105e9e965f0fe2d6f54 Mon Sep 17 00:00:00 2001 From: Eric Wild Date: Wed, 20 Mar 2024 19:39:05 +0100 Subject: [PATCH] ms: fix shutdown issues Queues got stuck when killing mobile during a transfer Change-Id: I02e668a55dece96e421c82706b76bbb411ea6712 --- Transceiver52M/ms/itrq.h | 2 +- Transceiver52M/ms/ms_rx_lower.cpp | 4 +++- Transceiver52M/ms/ms_trxcon_if.h | 4 ++-- Transceiver52M/ms/ms_upper.cpp | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Transceiver52M/ms/itrq.h b/Transceiver52M/ms/itrq.h index 69ff5152..3ce67000 100644 --- a/Transceiver52M/ms/itrq.h +++ b/Transceiver52M/ms/itrq.h @@ -34,7 +34,7 @@ class spsc_cond_timeout_detail { std::condition_variable cond_r, cond_w; std::mutex lr, lw; std::atomic_int r_flag, w_flag; - const int timeout_ms = 200; + const int timeout_ms = 600; public: explicit spsc_cond_timeout_detail() : r_flag(0), w_flag(0) diff --git a/Transceiver52M/ms/ms_rx_lower.cpp b/Transceiver52M/ms/ms_rx_lower.cpp index b169dd82..3527a8ba 100644 --- a/Transceiver52M/ms/ms_rx_lower.cpp +++ b/Transceiver52M/ms/ms_rx_lower.cpp @@ -54,6 +54,8 @@ extern "C" { #define PRINT_Q_OVERFLOW +extern std::atomic g_exit_flag; + bool ms_trx::decode_sch(char *bits, bool update_global_clock) { int fn; @@ -141,7 +143,7 @@ bool ms_trx::handle_sch_or_nb() memcpy(brst.sch_bits, sch_demod_bits, sizeof(sch_demod_bits)); } - while (upper_is_ready && !rxqueue.spsc_push(&brst)) + while (!g_exit_flag && upper_is_ready && !rxqueue.spsc_push(&brst)) ; if (!use_agc) diff --git a/Transceiver52M/ms/ms_trxcon_if.h b/Transceiver52M/ms/ms_trxcon_if.h index 0928d409..14bdb4b9 100644 --- a/Transceiver52M/ms/ms_trxcon_if.h +++ b/Transceiver52M/ms/ms_trxcon_if.h @@ -37,6 +37,6 @@ struct internal_q_tx_buf { memcpy(buf, (void *)br->burst, br->burst_len); } }; -using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>; +using tx_queue_t = spsc_cond_timeout<8 * 1, internal_q_tx_buf, true, false>; using cmd_queue_t = spsc_cond_timeout<8 * 1, trxcon_phyif_cmd, true, false>; -using cmdr_queue_t = spsc_cond<8 * 1, trxcon_phyif_rsp, false, false>; +using cmdr_queue_t = spsc_cond_timeout<8 * 1, trxcon_phyif_rsp, false, false>; diff --git a/Transceiver52M/ms/ms_upper.cpp b/Transceiver52M/ms/ms_upper.cpp index f505eb60..ca052090 100644 --- a/Transceiver52M/ms/ms_upper.cpp +++ b/Transceiver52M/ms/ms_upper.cpp @@ -172,9 +172,11 @@ bool upper_trx::pullRadioVector(GSM::Time &wTime, int &RSSI, int &timingOffset) std::fill(workbuf, workbuf + workbuf_size, 0); // assert(sv.begin() == &workbuf[40]); - while (!rxqueue.spsc_pop(&e)) { + while (!rxqueue.spsc_pop(&e) && !g_exit_flag) { rxqueue.spsc_prep_pop(); } + if (g_exit_flag) + return false; wTime = e.gsmts;