]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4310] Put LOG_FATAL() calls in a try block to avoid double errors
authorFrancis Dupont <fdupont@isc.org>
Wed, 24 Feb 2016 12:17:32 +0000 (13:17 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 24 Feb 2016 12:17:32 +0000 (13:17 +0100)
src/bin/dhcp4/main.cc
src/bin/dhcp6/main.cc

index 3300a8572c918e49bffb193bc21e0fd10c9603b8..553520a7c45585b716fb271252fbcde03a5791ac 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -175,8 +175,12 @@ main(int argc, char* argv[]) {
         // Let's also try to log it using logging system, but we're not
         // sure if it's usable (the exception may have been thrown from
         // the logger subsystem)
-        LOG_FATAL(dhcp4_logger, DHCP4_ALREADY_RUNNING)
-                  .arg(DHCP4_NAME).arg(ex.what());
+        try {
+            LOG_FATAL(dhcp4_logger, DHCP4_ALREADY_RUNNING)
+                .arg(DHCP4_NAME).arg(ex.what());
+        } catch (...) {
+            // Already logged so ignore
+        }
         ret = EXIT_FAILURE;
     } catch (const std::exception& ex) {
         // First, we print the error on stderr (that should always work)
@@ -186,7 +190,11 @@ main(int argc, char* argv[]) {
         // Let's also try to log it using logging system, but we're not
         // sure if it's usable (the exception may have been thrown from
         // the logger subsystem)
-        LOG_FATAL(dhcp4_logger, DHCP4_SERVER_FAILED).arg(ex.what());
+        try {
+            LOG_FATAL(dhcp4_logger, DHCP4_SERVER_FAILED).arg(ex.what());
+        } catch (...) {
+            // Already logged so ignore
+        }
         ret = EXIT_FAILURE;
     }
 
index 3c35acc202cfab22506c527858f9de57a05ae591..6bde296fa64ebc24b86612282545e4339427ba34 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -182,8 +182,12 @@ main(int argc, char* argv[]) {
         // Let's also try to log it using logging system, but we're not
         // sure if it's usable (the exception may have been thrown from
         // the logger subsystem)
-        LOG_FATAL(dhcp6_logger, DHCP6_ALREADY_RUNNING)
-                  .arg(DHCP6_NAME).arg(ex.what());
+        try {
+            LOG_FATAL(dhcp6_logger, DHCP6_ALREADY_RUNNING)
+                .arg(DHCP6_NAME).arg(ex.what());
+        } catch (...) {
+            // Already logged so ignore
+        }
         ret = EXIT_FAILURE;
     } catch (const std::exception& ex) {
 
@@ -194,7 +198,11 @@ main(int argc, char* argv[]) {
         // Let's also try to log it using logging system, but we're not
         // sure if it's usable (the exception may have been thrown from
         // the logger subsystem)
-        LOG_FATAL(dhcp6_logger, DHCP6_SERVER_FAILED).arg(ex.what());
+        try {
+            LOG_FATAL(dhcp6_logger, DHCP6_SERVER_FAILED).arg(ex.what());
+        } catch (...) {
+            // Already logged so ignore
+        }
         ret = EXIT_FAILURE;
     }