]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3478] Checkpoint: added logs
authorFrancis Dupont <fdupont@isc.org>
Wed, 31 Jul 2024 19:53:39 +0000 (21:53 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 21 Aug 2024 07:58:57 +0000 (09:58 +0200)
src/lib/http/connection.cc
src/lib/http/connection.h
src/lib/http/http_messages.cc
src/lib/http/http_messages.h
src/lib/http/http_messages.mes

index 141390cd260d7c31e35046acb0aaef225c2f22c6..8f494de712b1107d7ccb7d01aa30a6cf03133c09 100644 (file)
@@ -166,6 +166,34 @@ HttpConnection::shutdown() {
     isc_throw(Unexpected, "internal error: unable to shutdown the socket");
 }
 
+void
+HttpConnection::markWatchSocketReady() {
+    if (!watch_socket_) {
+        /// Should not happen...
+        return;
+    }
+    try {
+        watch_socket_->markReady();
+    } catch (const std::exception& ex) {
+        LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR)
+            .arg(ex.what());
+    }
+}
+
+void
+HttpConnection::clearWatchSocket() {
+    if (!watch_socket_) {
+        /// Should not happen...
+        return;
+    }
+    try {
+        watch_socket_->clearReady();
+    } catch (const std::exception& ex) {
+        LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR)
+            .arg(ex.what());
+    }
+}
+
 void
 HttpConnection::closeWatchSocket() {
     if (!watch_socket_) {
@@ -176,7 +204,8 @@ HttpConnection::closeWatchSocket() {
     // Close watch socket and log errors if occur.
     std::string watch_error;
     if (!watch_socket_->closeSocket(watch_error)) {
-        /// log
+        LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR)
+            .arg(watch_error);
     }
 }
 
@@ -283,10 +312,7 @@ HttpConnection::doHandshake() {
     try {
         tls_socket_->handshake(cb);
         if (use_external_) {
-            // Asynchronous handshake has been scheduled and we need to
-            // indicate this to break the synchronous select(). The handler
-            // should clear this status when invoked.
-            watch_socket_->markReady();
+            markWatchSocketReady();
         }
     } catch (const std::exception& ex) {
         isc_throw(HttpConnectionError, "unable to perform TLS handshake: "
@@ -348,11 +374,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
                                        transaction->getOutputBufSize(),
                                        cb);
                 if (use_external_) {
-                    // Asynchronous send has been scheduled and we
-                    // need to indicate this to break the synchronous
-                    // select(). The handler should clear this status
-                    // when invoked.
-                    watch_socket_->markReady();
+                    markWatchSocketReady();
                 }
                 return;
             }
@@ -361,11 +383,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
                                        transaction->getOutputBufSize(),
                                        cb);
                 if (use_external_) {
-                    // Asynchronous send has been scheduled and we
-                    // need to indicate this to break the synchronous
-                    // select(). The handler should clear this status
-                    // when invoked.
-                    watch_socket_->markReady();
+                    markWatchSocketReady();
                 }
                 return;
             }
@@ -432,13 +450,7 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
 void
 HttpConnection::handshakeCallback(const boost::system::error_code& ec) {
     if (use_external_) {
-        // Clear the watch socket so as the future send operation can
-        // mark it again to interrupt the synchronous select() call.
-        try {
-            watch_socket_->clearReady();
-        } catch (const std::exception& ex) {
-            // log.
-        }
+        clearWatchSocket();
     }
     if (ec) {
         LOG_INFO(http_logger, HTTP_CONNECTION_HANDSHAKE_FAILED)
@@ -552,13 +564,7 @@ void
 HttpConnection::socketWriteCallback(HttpConnection::TransactionPtr transaction,
                                     boost::system::error_code ec, size_t length) {
     if (use_external_) {
-        // Clear the watch socket so as the future send operation can
-        // mark it again to interrupt the synchronous select() call.
-        try {
-            watch_socket_->clearReady();
-        } catch (const std::exception& ex) {
-            // log.
-        }
+        clearWatchSocket();
     }
     if (ec) {
         // IO service has been stopped and the connection is probably
index 39e165964ed4df6a2f214547e1ac4b63caf1b73b..adf6b7a64eb2119a93f667fbb27544ced5cdca1d 100644 (file)
@@ -402,6 +402,19 @@ protected:
     /// @brief Returns remote address in textual form
     std::string getRemoteEndpointAddressAsText() const;
 
+    /// @brief Mark the watch socket as ready.
+    ///
+    /// Asynchronous handshake or send has been scheduled and we need to
+    /// indicate this to break the synchronous select(). The handler
+    /// should clear this status when invoked.
+    void markWatchSocketReady();
+
+    /// @brief Clear the watch socket's ready marker.
+    ///
+    /// Clear the watch socket so as the future send operation can
+    /// mark it again to interrupt the synchronous select() call.
+    void clearWatchSocket();
+
     /// @brief Close the watch socket.
     void closeWatchSocket();
 
index 292d2d85d9f6299671ac4331e7a5971205d8a06b..965609c4d0a5f29042812e35ce55ff3b2c206332 100644 (file)
@@ -26,6 +26,9 @@ extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN = "HTTP_CONNECTION_SHU
 extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED = "HTTP_CONNECTION_SHUTDOWN_FAILED";
 extern const isc::log::MessageID HTTP_CONNECTION_STOP = "HTTP_CONNECTION_STOP";
 extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED = "HTTP_CONNECTION_STOP_FAILED";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR";
 extern const isc::log::MessageID HTTP_DATA_RECEIVED = "HTTP_DATA_RECEIVED";
 extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED";
 extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED";
@@ -60,6 +63,9 @@ const char* values[] = {
     "HTTP_CONNECTION_SHUTDOWN_FAILED", "shutting down HTTP connection failed",
     "HTTP_CONNECTION_STOP", "stopping HTTP connection from %1",
     "HTTP_CONNECTION_STOP_FAILED", "stopping HTTP connection failed",
+    "HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR", "clearing connection watch socket failed: %1",
+    "HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR", "closing connection watch socket failed: %1",
+    "HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR", "marking ready connection watch socket failed: %1",
     "HTTP_DATA_RECEIVED", "received %1 bytes from %2",
     "HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED", "closing persistent connection with %1 as a result of a timeout",
     "HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED", "premature connection timeout occurred: in transaction ? %1, transid: %2, current_transid: %3",
index 4ac303081bfc74a0fdef1cf9a5f4ee310213684d..48bc84f13ea3bcc4f097b58497c1d05bf5874d91 100644 (file)
@@ -27,6 +27,9 @@ extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN;
 extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED;
 extern const isc::log::MessageID HTTP_CONNECTION_STOP;
 extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR;
 extern const isc::log::MessageID HTTP_DATA_RECEIVED;
 extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED;
 extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED;
index dd496ec3ae0ef7232d783b5e8864afe8065b3105..0074505c3ef13c8b1930279c87087292afd1a1e3 100644 (file)
@@ -128,6 +128,21 @@ successful message exchange with a client.
 This error message is issued when an error occurred during closing a
 HTTP connection with a client.
 
+% HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR clearing connection watch socket failed: %1
+This error message is issued when an error occurred during clearing the
+watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
+% HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR closing connection watch socket failed: %1
+This error message is issued when an error occurred during closing the
+watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
+% HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR marking ready connection watch socket failed: %1
+This error message is issued when an error occurred during marking as ready
+the watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
 % HTTP_DATA_RECEIVED received %1 bytes from %2
 Logged at debug log level 55.
 This debug message is issued when the server receives a chunk of data from