From f0f4f44915a0f6dd1ea3107f26fc386ba19fae59 Mon Sep 17 00:00:00 2001 From: andrekir Date: Thu, 19 Oct 2023 17:12:08 -0300 Subject: [PATCH] refactor: handle `QueueStatus` not responding under load workaround for when the mesh is busy, radios fail to respond with `QueueStatus` and acknowledge sent packets. - wait until radio queue is free or timeout, always assume sent packets went through; - never resend, just timeout and move on to the next packet when there is no `QueueStatus` response. --- .../com/geeksville/mesh/service/MeshService.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index e2ecdb2f0..c3f2aba71 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -833,23 +833,17 @@ class MeshService : Service(), Logging { queueJob = serviceScope.handledLaunch { debug("packet queueJob started") while (connectionState == ConnectionState.CONNECTED) { - var retryCount = 0 // take the first packet from the queue head val packet = queuedPackets.poll() ?: break - while (retryCount < 3) try { + try { // send packet to the radio and wait for response val response = sendPacket(packet) - debug("queueJob packet id=${packet.id.toUInt()} waiting (retry $retryCount)") - @Suppress("BlockingMethodInNonBlockingContext") - val success = response.get(45, TimeUnit.SECONDS) + debug("queueJob packet id=${packet.id.toUInt()} waiting") + val success = response.get(2, TimeUnit.MINUTES) debug("queueJob packet id=${packet.id.toUInt()} success $success") - if (success) break - retryCount++ // if send operation fails, retry } catch (e: TimeoutException) { - debug("queueJob timeout waiting packet id=${packet.id.toUInt()}") - retryCount++ // if send operation fails, retry - } - if (retryCount >= 3) { + debug("queueJob packet id=${packet.id.toUInt()} timeout") + } catch (e: Exception) { debug("queueJob packet id=${packet.id.toUInt()} failed") } }