mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-05-01 12:45:19 +00:00
Fix countBefore sentinel regression from millis wraparound fix
PR #1795 changed PacketQueue::countBefore() to use signed 2's complement arithmetic for millis wraparound safety. However, this broke the 0xFFFFFFFF sentinel pattern used by callers to mean "count all packets regardless of schedule". With the signed comparison, countBefore(0xFFFFFFFF) always returns 0, causing hasPendingWork() to report false and repeaters to sleep with packets still queued. Stats reporting also shows queue_len as 0. Add an early-return for the sentinel value before the loop, and document the sentinel convention on the virtual interface and implementation.
This commit is contained in:
@@ -9,6 +9,7 @@ PacketQueue::PacketQueue(int max_entries) {
|
||||
}
|
||||
|
||||
int PacketQueue::countBefore(uint32_t now) const {
|
||||
if (now == 0xFFFFFFFF) return _num; // sentinel: count all entries regardless of schedule
|
||||
int n = 0;
|
||||
for (int j = 0; j < _num; j++) {
|
||||
if ((int32_t)(_schedule_table[j] - now) > 0) continue; // scheduled for future... ignore for now
|
||||
|
||||
Reference in New Issue
Block a user