Skip to content

Commit

Permalink
Only cancel packet in Tx queue if it was already sent out via LoRa (#…
Browse files Browse the repository at this point in the history
…3191)

To avoid canceling a transmission if it was already ACKed via MQTT

Co-authored-by: Ben Meadors <[email protected]>
  • Loading branch information
GUVWAF and thebentern authored Feb 9, 2024
1 parent 74b90d3 commit bcbc2f2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/mesh/ReliableRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ bool ReliableRouter::stopRetransmission(GlobalPacketId key)
auto p = old->packet;
auto numErased = pending.erase(key);
assert(numErased == 1);
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
cancelSending(getFrom(p), p->id);
// now free the pooled copy for retransmission too
packetPool.release(p);
/* Only when we already transmitted a packet via LoRa, we will cancel the packet in the Tx queue
to avoid canceling a transmission if it was ACKed super fast via MQTT */
if (old->numRetransmissions < NUM_RETRANSMISSIONS - 1) {
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
cancelSending(getFrom(p), p->id);
// now free the pooled copy for retransmission too
packetPool.release(p);
}
return true;
} else
return false;
Expand Down

0 comments on commit bcbc2f2

Please sign in to comment.