]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3486] backport #3449 to Kea-2.6.1
authorRazvan Becheriu <razvan@isc.org>
Wed, 10 Jul 2024 10:01:44 +0000 (13:01 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 10 Jul 2024 10:09:48 +0000 (13:09 +0300)
ChangeLog
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/tests/dhcp4_test_utils.h
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/hooks/dhcp/high_availability/ha_callouts.cc
src/hooks/dhcp/high_availability/ha_impl.cc
src/hooks/dhcp/high_availability/ha_impl.h
src/hooks/dhcp/mysql_cb/mysql_cb_callouts.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_callouts.cc

index c3e74b22333a34fdb569298b526a75c721ed24dd..f3de3922fa7f59005d6fea2531374bb7923d3a12 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2248.  [bug]           razvan
+       Fixed a file descriptor leak in the High Availability hook
+       library.
+       (Gitlab #3449, #3486)
+
 Kea 2.6.0 (stable) released on May 29, 2024
 
 2247.  [build]         razvan
index d0483a3584a2e13a11e3cb27a61c68728b1ef5e5..84827d62b06176fbaf5e180db1ced059eec3d271 100644 (file)
@@ -878,7 +878,6 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
         cfg_db->createManagers();
         // Reset counters related to connections as all managers have been recreated.
         srv->getNetworkState()->resetForDbConnection();
-
     } catch (const std::exception& ex) {
         err << "Unable to open database: " << ex.what();
         return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
index c576c1d67436a3df49c35eb49eb6a40625a11f4c..269e6906f01eaf9fbf51bfac18a19823714a1e4c 100644 (file)
@@ -209,16 +209,7 @@ public:
         fake_received_.push_back(pkt);
     }
 
-    virtual ~NakedDhcpv4Srv() {
-        // Close the lease database
-        isc::dhcp::LeaseMgrFactory::destroy();
-
-        getIOService()->restart();
-        try {
-            getIOService()->poll();
-        } catch (...) {
-        }
-    }
+    virtual ~NakedDhcpv4Srv() = default;
 
     /// @brief Runs processing DHCPDISCOVER.
     ///
index ddcd64a8a2afc9fabe156f68c5a84add49bf4636..b67a36d6b1dcd337479795bdbe2c8904a6922af4 100644 (file)
@@ -215,11 +215,7 @@ public:
         fake_received_.push_back(pkt);
     }
 
-    virtual ~NakedDhcpv6Srv() {
-        // Close the lease database
-        isc::dhcp::LeaseMgrFactory::destroy();
-        getIOService()->stopAndPoll();
-    }
+    virtual ~NakedDhcpv6Srv() = default;
 
     /// @brief Processes incoming Solicit message.
     ///
@@ -637,7 +633,7 @@ public:
     /// @brief Destructor
     ///
     /// Removes existing configuration.
-    ~Dhcpv6SrvTest();
+    virtual ~Dhcpv6SrvTest();
 
     /// @brief Used to configure a server for tests.
     ///
index 2e4410983b3be70478d7d10c2d00f7e120764c5b..0075d71320f570aca8ef770af914b74acfe6ebe7 100644 (file)
@@ -430,9 +430,8 @@ int load(LibraryHandle& handle) {
 int unload() {
     if (impl) {
         IOServiceMgr::instance().unregisterIOService(impl->getIOService());
-        impl->getIOService()->stopAndPoll();
+        impl.reset();
     }
-    impl.reset();
     LOG_INFO(ha_logger, HA_DEINIT_OK);
     return (0);
 }
index d8ea4ee910591ac2e14c449724c623e10b57c759..cc7ff614fd81cbe91010340ecb2392b6e873faf8 100644 (file)
@@ -66,6 +66,9 @@ HAImpl::~HAImpl() {
         // than relying on destruction order.
         service->stopClientAndListener();
     }
+    config_.reset();
+    services_.reset(new HAServiceMapper());
+    io_service_->stopAndPoll();
 }
 
 void
index d7920cf737cae8740b0ab480bdf5008d6c1b253e..9c5e652f3d6b9a9556877edd9445f9a3b3dcb1cc 100644 (file)
@@ -245,7 +245,6 @@ protected:
 
     /// @brief Pointer to the high availability services (state machines).
     HAServiceMapperPtr services_;
-
 };
 
 /// @brief Pointer to the High Availability hooks library implementation.
index f4c6d2816b518a6c26f6f685821d35902d676360..f9e6f09ed35d3715c49918ea2af05cf481dbb0e0 100644 (file)
@@ -94,9 +94,11 @@ int unload() {
     // Unregister the factories and remove MySQL backends
     isc::dhcp::MySqlConfigBackendDHCPv4::unregisterBackendType();
     isc::dhcp::MySqlConfigBackendDHCPv6::unregisterBackendType();
-    IOServiceMgr::instance().unregisterIOService(isc::dhcp::MySqlConfigBackendImpl::getIOService());
-    if (isc::dhcp::MySqlConfigBackendImpl::getIOService()) {
-        isc::dhcp::MySqlConfigBackendImpl::getIOService()->stopAndPoll();
+    IOServicePtr io_service = isc::dhcp::MySqlConfigBackendImpl::getIOService();
+    if (io_service) {
+        IOServiceMgr::instance().unregisterIOService(io_service);
+        io_service->stopAndPoll();
+        isc::dhcp::MySqlConfigBackendImpl::setIOService(IOServicePtr());
     }
     return (0);
 }
index 3916427bb0bfe38f27bf2a5c76fe96683e844b85..536f94f11485c8096821f60908cf045b7192933e 100644 (file)
@@ -94,9 +94,11 @@ int unload() {
     // Unregister the factories and remove PostgreSQL backends
     isc::dhcp::PgSqlConfigBackendDHCPv4::unregisterBackendType();
     isc::dhcp::PgSqlConfigBackendDHCPv6::unregisterBackendType();
-    IOServiceMgr::instance().unregisterIOService(isc::dhcp::PgSqlConfigBackendImpl::getIOService());
-    if (isc::dhcp::PgSqlConfigBackendImpl::getIOService()) {
-        isc::dhcp::PgSqlConfigBackendImpl::getIOService()->stopAndPoll();
+    IOServicePtr io_service = isc::dhcp::PgSqlConfigBackendImpl::getIOService();
+    if (io_service) {
+        IOServiceMgr::instance().unregisterIOService(io_service);
+        io_service->stopAndPoll();
+        isc::dhcp::PgSqlConfigBackendImpl::setIOService(IOServicePtr());
     }
     return (0);
 }