From d63667f87f7ec2ceb6910a8a540f4985d6fe004f Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Thu, 4 Jun 2015 16:51:36 +0200 Subject: [PATCH] [sedhcpv6] Fixed a static destruction order fiasco with Botan on Fedora --- src/bin/dhcp6/main.cc | 7 +++++++ src/lib/dhcpsrv/cfgmgr.cc | 6 ++++-- src/lib/dhcpsrv/cfgmgr.h | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 902c3a65d3..1cc3106770 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -172,6 +172,10 @@ main(int argc, char* argv[]) { LOG_INFO(dhcp6_logger, DHCP6_SHUTDOWN); + // Avoid a static destruction order fiasco with secure DHCPv6 + // and Botan crypto backend... + CfgMgr::instance().clear(false); + } catch (const std::exception& ex) { // First, we print the error on stderr (that should always work) @@ -183,6 +187,9 @@ main(int argc, char* argv[]) { // the logger subsystem) LOG_FATAL(dhcp6_logger, DHCP6_SERVER_FAILED).arg(ex.what()); ret = EXIT_FAILURE; + + // No finally in C++? + CfgMgr::instance().clear(false); } return (ret); diff --git a/src/lib/dhcpsrv/cfgmgr.cc b/src/lib/dhcpsrv/cfgmgr.cc index 8d3147e6b8..acdc278d06 100644 --- a/src/lib/dhcpsrv/cfgmgr.cc +++ b/src/lib/dhcpsrv/cfgmgr.cc @@ -109,9 +109,11 @@ CfgMgr::ensureCurrentAllocated() { } void -CfgMgr::clear() { +CfgMgr::clear(bool reinit) { configs_.clear(); - ensureCurrentAllocated(); + if (reinit) { + ensureCurrentAllocated(); + } } void diff --git a/src/lib/dhcpsrv/cfgmgr.h b/src/lib/dhcpsrv/cfgmgr.h index 77d8fd996a..7d875fba7c 100644 --- a/src/lib/dhcpsrv/cfgmgr.h +++ b/src/lib/dhcpsrv/cfgmgr.h @@ -192,10 +192,10 @@ public: /// /// This function removes all configurations, including current and /// staging configurations. It creates a new current configuration with - /// default settings. + /// default settings when @param reinit is true. /// /// This function is exception safe. - void clear(); + void clear(bool reinit = true); /// @brief Commits the staging configuration. /// -- 2.47.2