ソースを参照

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.
yhirose 5 日 前
親
コミット
eea8ce9798
2 ファイル変更、11 行追加、11 行削除
  1. 9 9
      httplib.h
  2. 2 2
      test/test.cc

+ 9 - 9
httplib.h

@@ -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()
-// owns while it is idle, and a worker owns while it serves a request. A
-// derived class adds the transport: the stream, and for TLS the session.
+// A connection served across its requests. With set_keep_alive_parking(), the
+// event loop owns it while it is idle, and a worker while it serves a request.
+// 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
-  // turn.park tells whether it may be parked again.
+  // On a worker, with parking once the event loop has seen the socket
+  // 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
-// first resumes it runs the handshake, so one that has not sent its
-// ClientHello yet waits in the event loop like an idle connection.
+// The connection of SSLServer. The worker that first resumes it runs the
+// handshake, so with parking one that has not sent its ClientHello yet waits
+// 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
test/test.cc

@@ -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
-  // guard, so it is exercised on its own.
+  // SSLServer serves through its own connection type, so it is exercised on
+  // 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); };