Repository navigation
Drop the write response of a setter that answers after its connection closed - #557
Merged
Merged
Conversation
… closed The deferred cleanup in connection_lost pops the per-connection write responses once. A coroutine setter that finished later stored its response again, via setdefault, and nothing removed it: it stayed under the closed connection's address, where a connection that reuses the address read it. A Setup Endpoints answer carries its session's SRTP keys, so it must not outlive the connection that wrote. The driver now marks the pending writes of a connection dead in connection_lost, and _async_finish_set_characteristics drops the responses of dead writes. A response is answered once, to the writing connection, so one that answers after the close would never be read anyway.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #557 +/- ##
=======================================
Coverage 91.99% 92.00%
=======================================
Files 50 50
Lines 10822 10839 +17
Branches 1402 1404 +2
=======================================
+ Hits 9956 9972 +16
Misses 579 579
- Partials 287 288 +1
🚀 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.
Follow-up to the #544 review: a per-connection write response could outlive its connection.
The deferred cleanup in
connection_lostpops a connection's write responses once. A coroutine setter that finished later stored its response again, viasetdefault, and nothing removed it: the entry stayed under the closed connection's address forever, where a later connection that reuses the address read it. A Setup Endpoints answer carries its session's SRTP keys, so it must not outlive the connection that wrote._pending_connection_writes, andconnection_lostmarks those writes dead._async_finish_set_characteristicsdrops the responses of dead writes and unregisters them, whatever a setter returns. A response is answered once, to the writing connection, so one that answers after the close would never be read anyway.The existing test covered a completion that was already queued when the connection closed; the new tests cover a setter finishing after the deferred cleanup ran, for both a
wrwrite response and aread_back_responsecharacteristic. Both fail without the fix. The guard is per pending batch, so nothing accumulates for dead connections.This PR was made with LLM (GLM-5.3). Verifications mine.