Fix packet pool leak when rx queue is full

PacketQueue::add() silently dropped packets when the queue was at
capacity. The packet pointer was lost — never enqueued, never returned
to the unused pool. Each occurrence permanently shrank the 32-packet
pool until allocNew() returned NULL and the node went deaf. Return bool
from add() and free the packet back to the pool on failure.
This commit is contained in:
Wessel Nieboer 2026-02-17 23:54:33 +01:00
parent bbc5f0c11a
commit ffc9815e9a
No known key found for this signature in database
GPG key ID: 929C8E45E33B5FD2
2 changed files with 12 additions and 6 deletions

View file

@ -11,7 +11,7 @@ class PacketQueue {
public:
PacketQueue(int max_entries);
mesh::Packet* get(uint32_t now);
void add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for);
bool add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for);
int count() const { return _num; }
int countBefore(uint32_t now) const;
mesh::Packet* itemAt(int i) const { return _table[i]; }