fix: bound TC-deferral assembly window to first-arrival + max delay#1732
Draft
bluetoothbot wants to merge 1 commit into
Draft
fix: bound TC-deferral assembly window to first-arrival + max delay#1732bluetoothbot wants to merge 1 commit into
bluetoothbot wants to merge 1 commit into
Conversation
A peer streaming truncated queries faster than the 400–500 ms random delay used to rearm `_timers[addr]` could keep extending the flush deadline indefinitely, so the per-addr deferred list never drained (RFC 6762 §18.5 expects the window to be a fixed reassembly budget starting at first arrival, not a sliding heartbeat). Track first-arrival in `_deferred_deadlines` and cap each scheduled fire time at `first_arrival + _TC_DELAY_RANDOM_INTERVAL[1]`. If the next packet would push the timer past that deadline, leave the existing TimerHandle in place so the queue flushes on schedule.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1732 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 33 33
Lines 3440 3452 +12
Branches 473 476 +3
=======================================
+ Hits 3432 3444 +12
Misses 5 5
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AsyncListener.handle_query_or_deferre-armedself._timers[addr]on every new TC packet, so a peer streaming truncated queries faster than the 400–500 ms random delay could slide the flush deadline forward indefinitely and keep the per-addr deferred list growing. RFC 6762 §18.5 frames that delay as a fixed reassembly budget starting at first arrival, not a sliding heartbeat.The fix tracks first-arrival in
_deferred_deadlinesand caps each scheduled fire time atfirst_arrival + _TC_DELAY_RANDOM_INTERVAL[1]. If the next packet would push the timer past that deadline the existingTimerHandleis left in place so the queue still flushes on schedule.Fixes #1726
Changes
_listener.py: add_deferred_deadlinesslot, boundhandle_query_or_deferreset at the per-addr deadline, clear it in_respond_query._listener.pxd: declare the newcython.dictand the locals used in the bounded path.tests/test_core.py: regression test that pinsrandom.randintto the max delay and asserts subsequent TC packets do not push_timers[addr].when()past the deadline established by the first packet.Test plan
SKIP_CYTHON=1 poetry run pytest --timeout=60 tests/— 359 passed, 2 skipped.tests/test_core.py::test_tc_bit_defer_window_is_boundedfails onmaster(timer slides forward) and passes with the fix.poetry run ruff checkandpoetry run ruff format --checkclean on the touched files.Generated by Kōan /fix
Quality Report
Changes: 3 files changed, 65 insertions(+), 3 deletions(-)
Code scan: clean
Tests: passed (4 PASSED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline