Repository navigation
Sockets: make ServerSocket::close() private; the destructor performs the teardown - #1864
Merged
Merged
Conversation
…the teardown Per review: only close_connection() needs to be public. A listener that wants to disconnect the client calls close_connection(); completely shutting down the server only needs to happen in the destructor. - Remove close() from the public API of AbstractServerSocket and the backends. Each backend now has a private non-virtual close() (the blocking teardown, unchanged bodies for POSIX/WinSocket) that only the destructor calls. - Remove close_and_wait() and the start() prelude: close() is no longer user-callable, so a server can never be left DESTRUCTING while alive. - Keep the Qt DESTRUCTING-preservation in on_close_connection(): a queued connection-close can still race the destructor's close(). - Drop the server-callback regression test from the first commit and all server.close() cleanup calls in Sockets_Tests.cpp; the destructor now performs the teardown at scope exit.
Mysticial
pushed a commit
that referenced
this pull request
Nov 7, 2026
Mirrors the ClientSocket naming, per review of #1864: the private blocking teardown in ServerSocket_POSIX, ServerSocket_WinSocket and ServerSocket_Qt is now close_and_wait() (destructor-only), and the comments and docs that referred to it as close() are updated. No behaviour change. Co-authored-by: PA Dev Bot <344001113+pa-devbot@users.noreply.github.com>
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 #1859 (per review of it): I don't think both
close_connection()andclose()need to be public. If a listener wants to disconnect the client, it can callclose_connection(). Completely shutting down the server and blocking future connections only needs to happen in the destructor.Changes
AbstractServerSocketno longer declaresclose(). Each backend now has a private non-virtualclose()- the blocking teardown, bodies unchanged frommainfor POSIX/WinSocket, theQTcpServer-destroying body for Qt - called only by the destructor.close()and the privateclose_and_wait()introduced by Sockets: make ServerSocket::close() private; the destructor performs the teardown #1859, plus thestart()prelude: withclose()no longer user-callable, a server can never be leftDESTRUCTINGwhile the object is alive.close_connection()keeps its public API; its doc now contrasts with "the full teardown the destructor performs" instead of a publicclose().on_close_connection()DESTRUCTING-preservation from Sockets: make ServerSocket::close() private; the destructor performs the teardown #1859: a queued connection-close can still run on the event thread after the destructor'sclose()has setDESTRUCTING(it is queued before the destruction event), and without the check the state could flicker back toLISTENINGmid-teardown and accept a connection.Sockets_Tests.cpp: allserver.close()/second_server.close()cleanup calls removed - the destructor now performs the same teardown at scope exit - and Sockets: make ServerSocket::close() private; the destructor performs the teardown #1859's server-callback regression test dropped (its publicclose()no longer exists).Verification
Full local run: 0 failures, all 27 socket tests pass (Qt 15 + POSIX 12); POSIX/WinSocket
.cppfiles end up byte-identical tomain.