]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3971] Catch exceptions in the CtrlDhcp{4,6}Srv destructors.
authorMarcin Siodelski <marcin@isc.org>
Mon, 28 Sep 2015 13:02:17 +0000 (15:02 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 28 Sep 2015 13:02:17 +0000 (15:02 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc

index a66d56c54a5dc60e1cfc4ab94db0ef1f8c4821ac..9eab7b3eac6705d8b717d2851d80d6cd4db2fd50 100644 (file)
@@ -226,22 +226,29 @@ void ControlledDhcpv4Srv::shutdown() {
 }
 
 ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
-    cleanup();
-
-    // Stop worker thread running timers, if it is running.
-    timer_mgr_->stopThread();
-
-    // Close the command socket (if it exists).
-    CommandMgr::instance().closeCommandSocket();
-
-    // Deregister any registered commands
-    CommandMgr::instance().deregisterCommand("shutdown");
-    CommandMgr::instance().deregisterCommand("statistic-get");
-    CommandMgr::instance().deregisterCommand("statistic-reset");
-    CommandMgr::instance().deregisterCommand("statistic-remove");
-    CommandMgr::instance().deregisterCommand("statistic-get-all");
-    CommandMgr::instance().deregisterCommand("statistic-reset-all");
-    CommandMgr::instance().deregisterCommand("statistic-remove-all");
+    try {
+        cleanup();
+
+        // Stop worker thread running timers, if it is running.
+        timer_mgr_->stopThread();
+
+        // Close the command socket (if it exists).
+        CommandMgr::instance().closeCommandSocket();
+
+        // Deregister any registered commands
+        CommandMgr::instance().deregisterCommand("shutdown");
+        CommandMgr::instance().deregisterCommand("statistic-get");
+        CommandMgr::instance().deregisterCommand("statistic-reset");
+        CommandMgr::instance().deregisterCommand("statistic-remove");
+        CommandMgr::instance().deregisterCommand("statistic-get-all");
+        CommandMgr::instance().deregisterCommand("statistic-reset-all");
+        CommandMgr::instance().deregisterCommand("statistic-remove-all");
+
+    } catch (...) {
+        // Don't want to throw exceptions from the destructor. The server
+        // is shutting down anyway.
+        ;
+    }
 
     server_ = NULL; // forget this instance. Noone should call any handlers at
                     // this stage.
index e0bfcf9e1ee876155ae892526d6546d5b64db653..4e1cf818f2c41effef55ca8f971cbbd13f2b75e1 100644 (file)
@@ -222,22 +222,29 @@ void ControlledDhcpv6Srv::shutdown() {
 }
 
 ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
-    cleanup();
-
-    // Stop worker thread running timers, if it is running.
-    timer_mgr_->stopThread();
-
-   // Close the command socket (if it exists).
-    CommandMgr::instance().closeCommandSocket();
-
-    // Deregister any registered commands
-    CommandMgr::instance().deregisterCommand("shutdown");
-    CommandMgr::instance().deregisterCommand("statistic-get");
-    CommandMgr::instance().deregisterCommand("statistic-reset");
-    CommandMgr::instance().deregisterCommand("statistic-remove");
-    CommandMgr::instance().deregisterCommand("statistic-get-all");
-    CommandMgr::instance().deregisterCommand("statistic-reset-all");
-    CommandMgr::instance().deregisterCommand("statistic-remove-all");
+    try {
+        cleanup();
+
+        // Stop worker thread running timers, if it is running.
+        timer_mgr_->stopThread();
+
+        // Close the command socket (if it exists).
+        CommandMgr::instance().closeCommandSocket();
+
+        // Deregister any registered commands
+        CommandMgr::instance().deregisterCommand("shutdown");
+        CommandMgr::instance().deregisterCommand("statistic-get");
+        CommandMgr::instance().deregisterCommand("statistic-reset");
+        CommandMgr::instance().deregisterCommand("statistic-remove");
+        CommandMgr::instance().deregisterCommand("statistic-get-all");
+        CommandMgr::instance().deregisterCommand("statistic-reset-all");
+        CommandMgr::instance().deregisterCommand("statistic-remove-all");
+
+    } catch (...) {
+        // Don't want to throw exceptions from the destructor. The server
+        // is shutting down anyway.
+        ;
+    }
 
     server_ = NULL; // forget this instance. There should be no callback anymore
                     // at this stage anyway.