Describe KeepAliveConnection as the one serving path

The comments said these connections belong to keep-alive parking, which is no longer true now that every accepted socket is served through one.
This commit is contained in:
yhirose committed 2026-11-25 23:00:11 -05:00
1 parent 84acde731b
commit eea8ce9798
2 files changed
+11 -11

No files matched your search

+9 -9
View File
@@ -2589,7 +2589,7 @@ private:
ContentReceiver multipart_receiver) const; ContentReceiver multipart_receiver) const;
virtual bool process_and_close_socket(socket_t sock); virtual bool process_and_close_socket(socket_t sock);
// The connection that parking_loop() keeps for a socket it has accepted. // The connection that serves an accepted socket, with or without parking.
virtual std::shared_ptr<KeepAliveConnection> virtual std::shared_ptr<KeepAliveConnection>
new_keep_alive_connection(socket_t sock); new_keep_alive_connection(socket_t sock);
@@ -14326,9 +14326,9 @@ WebSocketSSLStream::set_read_interrupt(std::function<bool()> interrupted) {
* Group 4: Server implementation * Group 4: Server implementation
*/ */
// A kept-alive connection that the event loop of set_keep_alive_parking() // A connection served across its requests. With set_keep_alive_parking(), the
// owns while it is idle, and a worker owns while it serves a request. A // event loop owns it while it is idle, and a worker while it serves a request.
// derived class adds the transport: the stream, and for TLS the session. // A derived class adds the transport: the stream, and for TLS the session.
struct Server::KeepAliveConnection { struct Server::KeepAliveConnection {
KeepAliveConnection(socket_t s, Server &server) : svr(server), sock(s) {} KeepAliveConnection(socket_t s, Server &server) : svr(server), sock(s) {}
// Every owner closes it before letting go, which the transport hooks need; // Every owner closes it before letting go, which the transport hooks need;
@@ -14348,8 +14348,8 @@ struct Server::KeepAliveConnection {
// close_notify. // close_notify.
virtual void shut_down(bool /*graceful*/) {} virtual void shut_down(bool /*graceful*/) {}
// On a worker, once the event loop has seen the socket readable. Afterwards // On a worker, with parking once the event loop has seen the socket
// turn.park tells whether it may be parked again. // readable. Afterwards turn.park tells whether it may be parked again.
bool resume() { bool resume() {
turn = Turn(); turn = Turn();
return svr.serve_guarded([this]() { return svr.serve_guarded([this]() {
@@ -20187,9 +20187,9 @@ inline bool ssl_free_buffers_is_safe(unsigned long version) {
} // namespace detail } // namespace detail
#endif #endif
// A connection that keep-alive parking keeps for SSLServer. The worker that // The connection of SSLServer. The worker that first resumes it runs the
// first resumes it runs the handshake, so one that has not sent its // handshake, so with parking one that has not sent its ClientHello yet waits
// ClientHello yet waits in the event loop like an idle connection. // in the event loop like an idle connection.
struct SSLServer::TlsConnection final : Server::KeepAliveConnection { struct SSLServer::TlsConnection final : Server::KeepAliveConnection {
TlsConnection(socket_t s, SSLServer &server) TlsConnection(socket_t s, SSLServer &server)
: KeepAliveConnection(s, server), ssl_svr(server) {} : KeepAliveConnection(s, server), ssl_svr(server) {}
+2 -2
View File
@@ -6442,8 +6442,8 @@ TEST(ServerExceptionTest, ThrowingWebSocketHandlerDoesNotKillTheServer) {
#ifdef CPPHTTPLIB_SSL_ENABLED #ifdef CPPHTTPLIB_SSL_ENABLED
TEST(ServerExceptionTest, ThrowingContentProviderDoesNotKillTheSSLServer) { TEST(ServerExceptionTest, ThrowingContentProviderDoesNotKillTheSSLServer) {
// SSLServer::process_and_close_socket() is a separate overload with its own // SSLServer serves through its own connection type, so it is exercised on
// guard, so it is exercised on its own. // its own.
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE); SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
ASSERT_TRUE(svr.is_valid()); ASSERT_TRUE(svr.is_valid());
svr.new_task_queue = [] { return new ThreadPool(1); }; svr.new_task_queue = [] { return new ThreadPool(1); };