From cac58cea1f442e790121a0490c74f87a1751da5e Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 16 Aug 2024 15:10:26 -0400 Subject: [PATCH] move buffer size checks to host watchdog thread; add additional checks to prevent aggressive buffer overflow check logging; --- src/host/Host.DMR.cpp | 8 -------- src/host/Host.NXDN.cpp | 4 ---- src/host/Host.P25.cpp | 4 ---- src/host/Host.cpp | 31 ++++++++++++++++++++++++++++++- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/host/Host.DMR.cpp b/src/host/Host.DMR.cpp index 460041ea..e05406ed 100644 --- a/src/host/Host.DMR.cpp +++ b/src/host/Host.DMR.cpp @@ -276,10 +276,6 @@ void* Host::threadDMRWriter1(void* arg) host->m_lastDstId = host->m_dmr->getLastDstId(1U); host->m_lastSrcId = host->m_dmr->getLastSrcId(1U); } - } else { - if (host->m_dmr->isQueueFull(1U)) { - LogError(LOG_HOST, "PANIC; modem->hasDMRSpace1() = %u, and DMR slot 1 queue is full!", ret); - } } } } @@ -540,10 +536,6 @@ void* Host::threadDMRWriter2(void* arg) host->m_lastDstId = host->m_dmr->getLastDstId(2U); host->m_lastSrcId = host->m_dmr->getLastSrcId(2U); } - } else { - if (host->m_dmr->isQueueFull(2U)) { - LogError(LOG_HOST, "PANIC; modem->hasDMRSpace2() = %u, and DMR slot 2 queue is full!", ret); - } } } } diff --git a/src/host/Host.NXDN.cpp b/src/host/Host.NXDN.cpp index 12fa8a8e..35d4bcec 100644 --- a/src/host/Host.NXDN.cpp +++ b/src/host/Host.NXDN.cpp @@ -213,10 +213,6 @@ void* Host::threadNXDNWriter(void* arg) host->m_lastDstId = host->m_nxdn->getLastDstId(); host->m_lastSrcId = host->m_nxdn->getLastSrcId(); } - } else { - if (host->m_nxdn->isQueueFull()) { - LogError(LOG_HOST, "PANIC; modem->hasNXDNSpace() = %u, and NXDN queue is full!", ret); - } } } } diff --git a/src/host/Host.P25.cpp b/src/host/Host.P25.cpp index 0aa1b90c..5af51fb7 100644 --- a/src/host/Host.P25.cpp +++ b/src/host/Host.P25.cpp @@ -259,10 +259,6 @@ void* Host::threadP25Writer(void* arg) else { nextLen = 0U; } - } else { - if (host->m_p25->isQueueFull()) { - LogError(LOG_HOST, "PANIC; modem->hasP25Space() = %u, and P25 queue is full!", ret); - } } } diff --git a/src/host/Host.cpp b/src/host/Host.cpp index f84cf7da..48195d73 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -735,6 +735,11 @@ int Host::run() if (m_network != nullptr) m_network->clock(ms); + if (m_p25 != nullptr) + m_p25->reset(); + if (m_nxdn != nullptr) + m_nxdn->reset(); + Thread::sleep(IDLE_WARMUP_MS); if (elapsedMs > 15000U) @@ -1706,12 +1711,26 @@ void* Host::threadWatchdog(void* arg) LogError(LOG_HOST, "DMR, slot 1 frame processor hung >%us, ms = %u", host->m_dmrTx1WatchdogTimer.getTimeout(), host->m_dmrTx1LoopMS); } + if (host->m_dmr->getTSCCSlotNo() != 1U) { + if (host->m_modem->gotModemStatus() && !host->m_modem->hasDMRSpace1() && host->m_dmr->isQueueFull(1U) && + !host->m_dmrBeaconDurationTimer.isRunning()) { + LogError(LOG_HOST, "PANIC; has no DMR slot 1 buffer space, and DMR slot 1 queue is full!"); + } + } + if (host->m_dmrTx2WatchdogTimer.isRunning()) host->m_dmrTx2WatchdogTimer.clock(ms); if (host->m_dmrTx2WatchdogTimer.isRunning() && host->m_dmrTx2WatchdogTimer.hasExpired() && !host->m_dmrTx2WatchdogTimer.isPaused()) { host->m_dmrTx2WatchdogTimer.pause(); LogError(LOG_HOST, "DMR, slot 2 frame processor hung >%us, ms = %u", host->m_dmrTx2WatchdogTimer.getTimeout(), host->m_dmrTx2LoopMS); } + + if (host->m_dmr->getTSCCSlotNo() != 2U) { + if (host->m_modem->gotModemStatus() && !host->m_modem->hasDMRSpace2() && host->m_dmr->isQueueFull(2U) && + !host->m_dmrBeaconDurationTimer.isRunning()) { + LogError(LOG_HOST, "PANIC; has no DMR slot 2 buffer space, and DMR slot 2 queue is full!"); + } + } } /** Project 25 */ @@ -1720,7 +1739,12 @@ void* Host::threadWatchdog(void* arg) host->m_p25TxWatchdogTimer.clock(ms); if (host->m_p25TxWatchdogTimer.isRunning() && host->m_p25TxWatchdogTimer.hasExpired() && !host->m_p25TxWatchdogTimer.isPaused()) { host->m_p25TxWatchdogTimer.pause(); - LogError(LOG_HOST, "P25, frame processor hung >%us, ms = %u", host->m_p25TxWatchdogTimer.getTimeout(), host->m_p25TxLoopMS); + LogError(LOG_HOST, "P25, PANIC; frame processor hung >%us, ms = %u", host->m_p25TxWatchdogTimer.getTimeout(), host->m_p25TxLoopMS); + } + + if (host->m_modem->gotModemStatus() && !host->m_modem->hasP25Space(P25DEF::P25_LDU_FRAME_LENGTH_BYTES) && host->m_p25->isQueueFull() && + !host->m_p25CtrlChannel && !host->m_p25BcastDurationTimer.isRunning()) { + LogError(LOG_HOST, "PANIC; modem has no P25 buffer space, and internal P25 queue is full!"); } } @@ -1732,6 +1756,11 @@ void* Host::threadWatchdog(void* arg) host->m_nxdnTxWatchdogTimer.pause(); LogError(LOG_HOST, "NXDN, frame processor hung >%us, ms = %u", host->m_nxdnTxWatchdogTimer.getTimeout(), host->m_nxdnTxLoopMS); } + + if (host->m_modem->gotModemStatus() && !host->m_modem->hasNXDNSpace() && host->m_nxdn->isQueueFull() && + !host->m_nxdnCtrlChannel && !host->m_nxdnBcastDurationTimer.isRunning()) { + LogError(LOG_HOST, "PANIC; modem has no NXDN buffer space, and NXDN queue is full!"); + } } }