]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#491,!363] Addressed review comments.
authorMarcin Siodelski <marcin@isc.org>
Mon, 17 Jun 2019 14:40:18 +0000 (16:40 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 18 Jun 2019 07:17:08 +0000 (03:17 -0400)
- Fixed one doxygen error in HttpListenerImpl
- Described lifecycle of the transaction within the Http connection.
- Use another variable in HttpConnection::doRead to be less confusing
- Fixed a typo in Http connection.

src/lib/http/connection.cc
src/lib/http/connection.h
src/lib/http/listener_impl.h

index 331106b49e9aeda9e98caf769ee2e615e4f7c99c..d3d117a049cc32e90ceb21c3bd7ecbf8ab285d97 100644 (file)
@@ -122,7 +122,7 @@ HttpConnection::doRead(TransactionPtr transaction) {
     try {
         TCPEndpoint endpoint;
 
-        // Transaction is was not created if we are starting to read the
+        // Transaction hasn't been created if we are starting to read the
         // new request.
         if (!transaction) {
             transaction = Transaction::create(response_creator_);
@@ -380,11 +380,11 @@ HttpConnection::requestTimeoutCallback(TransactionPtr transaction) {
     // We need to differentiate the transactions between a normal response and the
     // timeout. We create new transaction from the current transaction. It is
     // to preserve the request we're responding to.
-    transaction = Transaction::spawn(response_creator_, transaction);
+    auto spawned_transaction = Transaction::spawn(response_creator_, transaction);
 
     // The new transaction inherits the request from the original transaction
     // if such transaction exists.
-    auto request = transaction->getRequest();
+    auto request = spawned_transaction->getRequest();
 
     // Depending on when the timeout occured, the HTTP version of the request
     // may or may not be available. Therefore we check if the HTTP version is
@@ -404,7 +404,7 @@ HttpConnection::requestTimeoutCallback(TransactionPtr transaction) {
                                                    HttpStatusCode::REQUEST_TIMEOUT);
 
     // Send the HTTP 408 status.
-    asyncSendResponse(response, transaction);
+    asyncSendResponse(response, spawned_transaction);
 }
 
 void
index c7ec7224d1de344cc1fb2e5d978217e2720f733f..3c3c3ffad8a114fc6f14bb8e7f81b243f806cd79 100644 (file)
@@ -96,9 +96,25 @@ protected:
     /// parser (being in the particular state of parsing), input buffer
     /// and the output buffer.
     ///
-    /// A pointer to the @c Transaction object is passed to the ASIO
-    /// callbacks when the new message exchange begins. It is passed
-    /// between the callbacks until the message exchange is completed.
+    /// The new @c Transaction instance is created when the connection
+    /// is established and the server starts receiving the HTTP request.
+    /// The shared pointer to the created transaction is passed between
+    /// the asynchronous handlers. Therefore, as long as the asynchronous
+    /// communication is conducted the instance of the transaction is
+    /// held by the IO service which runs the handlers. The transaction
+    /// instance exists as long as the asynchronous handlers for the
+    /// given request/response exchange are executed. When the server
+    /// responds to the client and all corresponding IO handlers are
+    /// invoked the transaction is automatically destroyed.
+    ///
+    /// The timeout may occur anytime during the transaction. In such
+    /// cases, a new transaction instance is created to send the
+    /// HTTP 408 (timeout) response to the client. Creation of the
+    /// new transaction for the timeout response is necessary because
+    /// there may be some asynchronous handlers scheduled by the
+    /// original transaction which rely on the original transaction's
+    /// state. The timeout response's state is held within the new
+    /// transaction spawned from the original transaction.
     class Transaction {
     public:
 
index c6a8952d9a0e70ca68b9736fd4ecfa7448a245f7..83e084cff495d4299ba938de634ed348ff1fe5b0 100644 (file)
@@ -81,7 +81,7 @@ protected:
 
     /// @brief Callback invoked when the new connection is accepted.
     ///
-    /// It calls @ref HttpListener::accept to create new @ref HttpConnection
+    /// It calls @c HttpListener::accept to create new @c HttpConnection
     /// instance.
     ///
     /// @param ec Error code passed to the handler. This is currently ignored.