]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2088] fixed crash on server shutdown
authorRazvan Becheriu <razvan@isc.org>
Wed, 15 Sep 2021 08:08:01 +0000 (11:08 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 16 Sep 2021 13:14:59 +0000 (16:14 +0300)
src/bin/agent/main.cc
src/bin/d2/d2_process.cc
src/bin/d2/main.cc
src/bin/d2/tests/dns_client_unittests.cc
src/bin/netconf/main.cc
src/lib/process/d_controller.cc
src/lib/process/process_messages.cc
src/lib/process/process_messages.h
src/lib/process/process_messages.mes

index 081993a8b37c14fc08cdeb6e6cc1490486ccdb40..68687083a6775366e1675c7c5eb22a25c5ac2058 100644 (file)
@@ -43,5 +43,7 @@ int main(int argc, char* argv[]) {
         ret = EXIT_FAILURE;
     }
 
+    CtrlAgentController::instance().reset();
+
     return (ret);
 }
index a4a738be240c93708e62ee95908d599a65fb37b2..c06e0bea9a1008064c0a14c3db516b38b2c863ca 100644 (file)
@@ -436,7 +436,7 @@ D2Process::reconfigureQueueMgr() {
 }
 
 D2Process::~D2Process() {
-};
+}
 
 D2CfgMgrPtr
 D2Process::getD2CfgMgr() {
index da7be90dc46550b6fece223c74e9a0422019fdd2..25975a77d39ed6a864591c1f46f37758144d0535 100644 (file)
@@ -52,5 +52,7 @@ int main(int argc, char* argv[]) {
         ret = EXIT_FAILURE;
     }
 
+    D2Controller::instance().reset();
+
     return (ret);
 }
index 33369935ab0904ddca73e031b9c21efa4090c0ed..6d38cc3fac9ebc96037aafb1c02c0ced8b400f06 100644 (file)
@@ -5,20 +5,23 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #include <config.h>
+
 #include <d2/dns_client.h>
 #include <dns/opcode.h>
 #include <asiodns/io_fetch.h>
 #include <asiodns/logger.h>
 #include <asiolink/interval_timer.h>
 #include <dns/messagerenderer.h>
+#include <nc_test_utils.h>
+#include <stats_test_utils.h>
+
 #include <boost/asio/ip/udp.hpp>
 #include <boost/asio/socket_base.hpp>
 #include <boost/scoped_ptr.hpp>
-#include <gtest/gtest.h>
-#include <nc_test_utils.h>
-#include <stats_test_utils.h>
 #include <functional>
 
+#include <gtest/gtest.h>
+
 using namespace std;
 using namespace isc;
 using namespace isc::asiolink;
@@ -178,7 +181,7 @@ public:
         }
         // A response message is now ready to send. Send it!
         socket->send_to(boost::asio::buffer(response_buf.getData(),
-                                     response_buf.getLength()),
+                                            response_buf.getLength()),
                         *remote);
     }
 
@@ -212,7 +215,7 @@ public:
 
         TSIGContextPtr context;
         if (client_key) {
-            context.reset(new TSIGContext(*client_key));
+            context = client_key->createContext();
         }
 
         isc::util::InputBuffer received_data_buffer(receive_buffer_,
@@ -287,7 +290,7 @@ public:
         // ensure that doUpdate doesn't throw an exception for valid timeouts.
         unsigned int timeout = DNSClient::getMaxTimeout();
         EXPECT_NO_THROW(dns_client_->doUpdate(service_, IOAddress(TEST_ADDRESS),
-                                           TEST_PORT, message, timeout));
+                                              TEST_PORT, message, timeout));
 
         // Cross the limit and expect that exception is thrown this time.
         timeout = DNSClient::getMaxTimeout() + 1;
@@ -385,7 +388,7 @@ public:
         const int timeout = 500;
         expected_++;
         dns_client_->doUpdate(service_, IOAddress(TEST_ADDRESS), TEST_PORT,
-                             message, timeout);
+                              message, timeout);
 
         // It is possible to request that two packets are sent concurrently.
         if (two_sends) {
@@ -410,7 +413,7 @@ public:
     // Performs a single request-response exchange with or without TSIG
     //
     // @param client_key TSIG passed to dns_client and also used by the
-    // ""server" to verify the request.
+    // "server" to verify the request.
     // request.
     // @param server_key TSIG key the "server" should use to sign the response.
     // If this is NULL, then client_key is used.
index 4778b3bb8c9dfa050412a4772cc342b0c859049e..3481b5b171eadbe26082acc07b204d9b9c3af705 100644 (file)
@@ -43,5 +43,7 @@ int main(int argc, char* argv[]) {
         ret = EXIT_FAILURE;
     }
 
+    NetconfController::instance().reset();
+
     return (ret);
 }
index 72bf80e027f2d719d71f5d59f1a8f8d138153203..4a2062cdb5d0c8c9a3985149fb32c12972e15788 100644 (file)
@@ -8,6 +8,7 @@
 #include <cc/command_interpreter.h>
 #include <cfgrpt/config_report.h>
 #include <exceptions/exceptions.h>
+#include <hooks/hooks_manager.h>
 #include <log/logger.h>
 #include <log/logger_support.h>
 #include <process/daemon.h>
@@ -23,6 +24,7 @@
 using namespace isc::asiolink;
 using namespace isc::data;
 using namespace isc::config;
+using namespace isc::hooks;
 namespace ph = std::placeholders;
 
 namespace isc {
@@ -805,6 +807,19 @@ DControllerBase::usage(const std::string & text) {
 }
 
 DControllerBase::~DControllerBase() {
+    // Explicitly unload hooks
+    HooksManager::prepareUnloadLibraries();
+    if (!HooksManager::unloadLibraries()) {
+        auto names = HooksManager::getLibraryNames();
+        std::string msg;
+        if (!names.empty()) {
+            msg = names[0];
+            for (size_t i = 1; i < names.size(); ++i) {
+                msg += std::string(", ") + names[i];
+            }
+        }
+        LOG_ERROR(dctl_logger, DCTL_UNLOAD_LIBRARIES_ERROR).arg(msg);
+    }
 }
 
 // Refer to config_report so it will be embedded in the binary
index af290ed4099aec63ade2c0e184f3785d22f18922..a4ee304d3dafeebe8556503cbb606482f2a4f326 100644 (file)
@@ -35,6 +35,7 @@ extern const isc::log::MessageID DCTL_SHUTDOWN = "DCTL_SHUTDOWN";
 extern const isc::log::MessageID DCTL_SHUTDOWN_SIGNAL_RECVD = "DCTL_SHUTDOWN_SIGNAL_RECVD";
 extern const isc::log::MessageID DCTL_STANDALONE = "DCTL_STANDALONE";
 extern const isc::log::MessageID DCTL_STARTING = "DCTL_STARTING";
+extern const isc::log::MessageID DCTL_UNLOAD_LIBRARIES_ERROR = "DCTL_UNLOAD_LIBRARIES_ERROR";
 extern const isc::log::MessageID DCTL_UNSUPPORTED_SIGNAL = "DCTL_UNSUPPORTED_SIGNAL";
 
 } // namespace process
@@ -71,6 +72,7 @@ const char* values[] = {
     "DCTL_SHUTDOWN_SIGNAL_RECVD", "OS signal %1 received, starting shutdown",
     "DCTL_STANDALONE", "%1 skipping message queue, running standalone",
     "DCTL_STARTING", "%1 starting, pid: %2, version: %3 (%4)",
+    "DCTL_UNLOAD_LIBRARIES_ERROR", "error unloading hooks libraries during shutdown: %1",
     "DCTL_UNSUPPORTED_SIGNAL", "ignoring reception of unsupported signal: %1",
     NULL
 };
index 8e1334ea984252959d85244c456120f37de011ef..0ae950a5202811f25dd4850c853fe4a2963e9501 100644 (file)
@@ -36,6 +36,7 @@ extern const isc::log::MessageID DCTL_SHUTDOWN;
 extern const isc::log::MessageID DCTL_SHUTDOWN_SIGNAL_RECVD;
 extern const isc::log::MessageID DCTL_STANDALONE;
 extern const isc::log::MessageID DCTL_STARTING;
+extern const isc::log::MessageID DCTL_UNLOAD_LIBRARIES_ERROR;
 extern const isc::log::MessageID DCTL_UNSUPPORTED_SIGNAL;
 
 } // namespace process
index dc25ae3991ddd771a06382cd9f56a1646d78f4b4..95d6cfcd826931dc9a5ca80f70616859fa496116 100644 (file)
@@ -87,6 +87,13 @@ to create and initialize its application instance.
 This error message is issued if the controller could not initialize the
 application and will exit.
 
+% DCTL_UNLOAD_LIBRARIES_ERROR error unloading hooks libraries during shutdown: %1
+This error message indicates that during shutdown, unloading hooks
+libraries failed to close them. If the list of libraries is empty it is
+a programmatic error in the server code. If it is not empty it could be
+a programmatic error in one of the hooks libraries which could lead to
+a crash during finalization.
+
 % DCTL_NOT_RUNNING %1 application instance is not running
 A warning message is issued when an attempt is made to shut down the
 application when it is not running.