Commit e0beab9
Fix ComQueue dropping oldest Fw::Buffer without returning ownership (#5014)
* Fix ComQueue dropping oldest Fw::Buffer without returning ownership
When a buffer queue configured with QUEUE_DROP_OLDEST overflows, the
oldest queued Fw::Buffer was silently discarded by Queue::enqueue via
CircularBuffer::rotate without returning ownership through
bufferReturnOut. This leaked buffer-pool entries, eventually starving
dependent communication or telemetry paths.
Fix:
- Add optional 'discarded' output parameter to Types::Queue::enqueue()
that captures the about-to-be-dropped message data via peek before
the rotate.
- In ComQueue::enqueue(), pass an Fw::Buffer-sized output buffer for
buffer queues and invoke bufferReturnOut_out() when DROP_OLDEST fires.
Closes #5011
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* Add discarded_size assert to Queue::enqueue, use proper Fw::Buffer serialization, add UTs
- Queue::enqueue: added discarded_size parameter with FW_ASSERT validating
the output buffer is large enough when discarded != nullptr
- ComQueue: switched buffer queues from raw reinterpret_cast<U8*>(&buffer)
to proper serializeTo/deserializeFrom using Fw::Buffer::SERIALIZED_SIZE.
This affects buffQueueIn_handler (serialize before enqueue), the discard
path in enqueue(), processQueue() (deserialize after dequeue), and
drainQueue() (deserialize after dequeue).
- Added 4 Queue UTs: DropOldestDiscardedOutput, DropOldestNullDiscarded,
DropNewestIgnoresDiscarded, LIFODropOldestDiscardedOutput
- Added 2 ComQueue UTs: ComQueueDropOldestNoBufferReturn (nullptr discarded
path), BufferQueueFlushAfterDropOldest (drainQueue deserialization)
All 14 Queue UTs and 25 ComQueue UTs pass.
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* Run clang-format on changed files
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* Revert Queue changes, fix ComQueue drop-oldest with pre-emptive dequeue
Reverted all Utils/Types/Queue changes (discarded parameter, UTs) per
review feedback — the fix now lives entirely in ComQueue.
ComQueue::enqueue() now checks if a buffer queue is full with DROP_OLDEST
before calling Queue::enqueue(). When full, it dequeues the oldest entry
first, returns buffer ownership via bufferReturnOut, then enqueues the new
message into the now-available slot. This prevents buffer-pool leaks
without modifying the Queue API.
Also reverted the Fw::Buffer serialization changes (to be done in a
separate PR) and removed the added ComQueue/Queue UTs.
Updated existing testBufferQueueDropOldestMode assertion from 2 to 3
buffer returns to reflect the fix.
All 10 Queue UTs and 22 ComQueue UTs pass.
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* Add Queue::popFront() to fix LIFO+DROP_OLDEST pre-emptive dequeue
Queue::dequeue() respects queue mode (LIFO removes from back), but
DROP_OLDEST always discards the front entry. The pre-emptive dequeue
in ComQueue was using dequeue(), which would remove the wrong entry
for LIFO+DROP_OLDEST queues.
Added Queue::popFront() — always peeks offset 0 then rotates, matching
the rotate-based removal that Queue::enqueue() uses for DROP_OLDEST.
ComQueue::enqueue() now calls popFront() instead of dequeue() for the
pre-emptive overflow path.
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
* Rename deqStatus to dequeueStatus to fix spelling abbreviation
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent fed7efe commit e0beab9
4 files changed
Lines changed: 55 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
318 | 343 | | |
319 | | - | |
| 344 | + | |
| 345 | + | |
320 | 346 | | |
321 | 347 | | |
322 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
| 832 | + | |
| 833 | + | |
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
| |||
0 commit comments