Repository navigation
Wait for the peer to confirm the disconnect request - #987
Open
gijzelaerr wants to merge 1 commit into
Open
gijzelaerr wants to merge 1 commit into
gijzelaerr wants to merge 1 commit into
Conversation
A CP 343-1 kept the connection's resource after disconnect() even with the DR addressed to its reference (#979): the capture shows our FIN 7 us after the DR and the CP answering both with a reset, never with a DC. disconnect() now waits up to one second for a DC, or for the peer to close or reset the connection, before closing the socket, in both clients. The DR also carried a zero byte after its header, outside the length indicator. Class 0 allows no user data in a DR, so it is dropped. Refs #972. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gijzelaerr
force-pushed
the
fix/disconnect-close-sequence
branch
from
November 11, 2026 13:41
488de24 to
db0747e
Compare
This branch has not been deployed
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.
Refs #972. The reporter tested #979 and the CP 343-1 still keeps a connection resource after each
disconnect().What the new capture shows. #979 works: the DR now goes to the CP's reference (
06 80 4431 0001 …). What's still wrong is the close sequence:The CP never gets the chance to send a DC. The first capture (before #979) has the same sequence.
Changes, in both clients:
disconnect()waits up toDISCONNECT_CONFIRM_TIMEOUT(1 s, and at most the connection timeout) for a COTP DC, or for the peer to close or reset the connection, before closing the socket. Other frames still in flight are skipped. The emulator server already answers a DR with a DC, so the test suite isn't slower.Whether either change frees the CP's resource needs the reporter's hardware. Their next capture will show whether the CP now sends a DC.
Tests: socket-pair tests check that no FIN reaches the peer before it sends its DC, that
disconnect()returns at once when the peer closes, that a silent peer is bounded by the timeout, and that a late data frame before the DC is skipped. An asyncio-server test does the same for the async client. Full suite: 1657 passed, 62 skipped (Windows, Python 3.13). Pre-commit and mypy are clean.🤖 Generated with Claude Code