Repository navigation
Close a connection attempt still in flight when the client is destroyed - #34
Merged
Merged
Conversation
The destructor cancelled only the connection timeout timer. The handler of a pending connect or handshake holds its own reference to the stream, and the timer that would have cancelled the attempt was the one just cancelled, so the attempt stayed pending until the peer answered or the system gave up. An owner that lets its io_context run until the pending operations have unwound then waited for it. The destructor now posts a close of the stream to the io_context; the stream member is only set between the start of a connect and the creation of the session, so an established session is not affected.
JakaMohorko
approved these changes
Nov 24, 2026
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.
Brief
Close a connection attempt that is still pending when
Clientis destroyed, so an owner that lets itsio_contextrun out of work does not wait for the peer or the system to give up on the attempt.Description
The
Clientdestructor cancelled only the connection timeout timer. The handler of a pending connect or handshake holds its own reference to the stream, and the timer that would have cancelled the attempt was the one just cancelled, so the attempt stayed pending until the peer answered or the system gave up. An owner that drains itsio_context(waits forrun()to return once the pending operations have unwound) then waited for it.The destructor now posts a close of the stream to the
io_context. The stream member is only set between the start of a connect and the creation of the session, so an established session is not affected.openDAQ/openDAQ#1386 depends on this: it drains the native streaming client's transport thread on shutdown instead of stopping it, and without this change removing a device that is connecting to a host that does not answer waits for the stop timeout. That pull request needs a library release that contains this fix.