Repository navigation
Sockets: add Listener::on_disconnect() hook - #1780
Merged
Merged
Conversation
New virtual AbstractClientSocket::Listener::on_disconnect(error_message), empty by default, called when an established connection is lost (the server closed the connection or a socket error occurred). It is not called by close(). The Windows implementation fires it in 'Fixes to ClientSocket_WinSocket'; the POSIX and Qt implementations adopt it in their own follow-up PRs. The sysbotbase connection overrides it to log the disconnect and update the status line, so a sys-botbase restart shows 'Disconnected: ...' instead of a zombie 'Last Ack: Ns ago'. Also log the actual error_message in on_connect_finished() (previously only the 'Connecting To: ...' line was logged, hiding the underlying error).
This was referenced Oct 31, 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.
Carve-out of
Common/Cpp/Socketswork so the implementation PRs can stack on top of this and go in parallel.Changes
AbstractClientSocket::Listener::on_disconnect(error_message)(Common/Cpp/Sockets/AbstractClientSocket.h) — empty by default, so all existing listeners keep compiling. It is called when an established connection is lost (the server closed it or a socket error occurred); it is not called byclose().SysbotBase_Connection.{h,cpp}) — logs the disconnect and sets the status line toDisconnected: <error>, so a sys-botbase restart is visible instead of a zombie "Last Ack: Ns ago" (the ping loop stops on its own because the socket reportsNOT_RUNNINGon loss).on_connect_finished()previously logged only the "Connecting To: ..." line, hiding the underlying error (e.g. a WSA/errno code). It now appendserror_message.Stacking
Fixes to ClientSocket_WinSocket(Sockets: fixes to ClientSocket_WinSocket #1774) will be rebased onto this branch (it fireson_disconnectfrom the Windows implementation).on_disconnect+ the lost-connection state machine) will branch off this branch so they can be reviewed/merged in parallel with Sockets: fixes to ClientSocket_WinSocket #1774.No behavior change for any implementation until the follow-ups land. Linux build + full command-line test suite pass.