No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Martin Sivak 721241353d Replace the heapless Deque queues with a shift left buffer
heapless 0.9.3 Deque::make_contiguous() corrupts a wrapped queue whose tail
fits into the free space: it sets back to 0 instead of the end of the data, so
the queue gains a stray byte (8 queued bytes become 9). The receive queue
calls make_contiguous() before every parse, so the MQTT stream gets out of step
and the next packet fails with UnknownPacketType or MalformedVarInt. Whether it
happens depends on where the queue wraps, which made it look like a race on the
devices (a firmware upload interleaved with other messages). The transmit queue
uses make_contiguous() in pending_transmit() as well.

Fixed upstream, but not released yet (0.9.3 is the latest release):
https://github.com/rust-embedded/heapless/pull/695
367accdec4
The full queue case worked around by keeping one byte free:
https://github.com/rust-embedded/heapless/issues/676

Both queues are now a LinearBuffer: a fixed size array whose contents always
start at index 0. Bytes are appended at the back and removed from the front a
packet or a block at a time with one copy_within, so the contents never wrap,
are always one slice and need no compaction. handle_sent() and the packet
drain remove bytes in bulk instead of one pop_front() per byte, a partly sent
block gets its length byte rewritten in place. handle_received_slice() stores
all of the bytes or none of them. The one free byte of the old workaround is
no longer kept.

heapless::format! for the numbers is replaced by a small decimal writer, and
the heapless dependency is dropped.
2026-11-15 09:14:01 +01:00
src Replace the heapless Deque queues with a shift left buffer 2026-11-15 09:14:01 +01:00
tests Enhance client APIs for keep alive, will, and packet id 2026-11-03 16:16:57 +01:00
.gitignore Initial import 2026-10-21 08:37:24 +02:00
AGENTS.md Add restricted AI note 2026-10-21 08:44:44 +02:00
Cargo.lock Replace the heapless Deque queues with a shift left buffer 2026-11-15 09:14:01 +01:00
Cargo.toml Replace the heapless Deque queues with a shift left buffer 2026-11-15 09:14:01 +01:00