Removes the need for HTTPClient::ReleaseRequest() as the client<->request cycle is broken. Not having to remember to call ReleaseRequest() reduces cognitive load.
Follow-up to #35735.
Removes the need for HTTPClient::ReleaseRequest() as the client<->request cycle is broken. Not having to remember to call ReleaseRequest() reduces cognitive load.
Follow-up to #35735.
This removes the need for HTTPClient::ReleaseRequest() as the client<->request cycle is broken. Not having to remember to call ReleaseRequest() reduces cognitive load.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36007.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline and AI policy for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | pinheadmz |
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
Possible typos and grammar issues:
// This must happen between, leaving m_send_ready set on an empty buffer. -> sentence is incomplete; missing words make the intended meaning unclear.<sup>2026-08-18 08:03:53</sup>
Will a weak pointer still keep the client connection open if a request is being handled in a worker thread, but the IO loop has dropped I from m_connected ?
Will a weak pointer still keep the client connection open if a request is being handled in a worker thread, but the IO loop has dropped it from m_connected ?
HTTPRequest::WriteReply() could be holding an ephemeral shared_ptr created by locking the weak_ptr. This would prevent the HTTPRemoteClient from being destroyed directly within HTTPServer::DisconnectClients() running on another thread. Destruction would in that case happen as HTTPRequest::WriteReply() exits, on that thread.
StopHTTPServer() blocks until the ThreadPool::Stop() has shut down all workers before calling InterruptNet()/JoinSocketsThreads()/ClearConnectedClients().
untested ACK 979a42ec17369b55a3a20c9e45965e6733fbeb19
Thanks for the improvement and the explanation 🏆
post-merge ACK 979a42ec17369b55a3a20c9e45965e6733fbeb19
Code change looks good to me, utACK 979a42ec17369b55a3a20c9e45965e6733fbeb19.
But a bit of documentation is no longer correct after this change. For example inhttpserver.h the DisconnectClients() doc comment still says:
* Close underlying socket connections for flagged clients
* by removing their shared pointer from m_connected. If an HTTPRemoteClient
* is busy in a worker thread, its connection will be closed once that
* job is done and the HTTPRequest is out of scope.
Now the connection is now closed before the job is done unless I am confused.
There are also mention of the shared pointers being present in worker threads which does not seem relevant anymore: https://github.com/bitcoin/bitcoin/blob/15a7a4ed7c4d0952ce966087e55a9a3e2f28ec1d/src/httpserver.h#L334 and https://github.com/bitcoin/bitcoin/blob/15a7a4ed7c4d0952ce966087e55a9a3e2f28ec1d/src/httpserver.cpp#L1087.