2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#2088] fixed crash on server shutdown

This commit is contained in:
Razvan Becheriu
2021-09-15 11:08:01 +03:00
parent 2d337d8d81
commit 5c81b25fb2
9 changed files with 43 additions and 9 deletions

View File

@@ -43,5 +43,7 @@ int main(int argc, char* argv[]) {
ret = EXIT_FAILURE;
}
CtrlAgentController::instance().reset();
return (ret);
}

View File

@@ -436,7 +436,7 @@ D2Process::reconfigureQueueMgr() {
}
D2Process::~D2Process() {
};
}
D2CfgMgrPtr
D2Process::getD2CfgMgr() {

View File

@@ -52,5 +52,7 @@ int main(int argc, char* argv[]) {
ret = EXIT_FAILURE;
}
D2Controller::instance().reset();
return (ret);
}

View 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.

View File

@@ -43,5 +43,7 @@ int main(int argc, char* argv[]) {
ret = EXIT_FAILURE;
}
NetconfController::instance().reset();
return (ret);
}

View 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

View 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
};

View 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

View 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.