]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2043] added try catch block for all MT CS
authorRazvan Becheriu <razvan@isc.org>
Mon, 23 Aug 2021 23:40:35 +0000 (02:40 +0300)
committerRazvan Becheriu <razvan@isc.org>
Tue, 24 Aug 2021 18:52:09 +0000 (21:52 +0300)
src/hooks/dhcp/stat_cmds/stat_cmds.cc
src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc
src/hooks/dhcp/stat_cmds/stat_cmds_messages.h
src/hooks/dhcp/stat_cmds/stat_cmds_messages.mes

index 520534f28f1c086d69fda178a9663a85fc920a9c..c10c60997eaa611488856a3592d85cbdcd4da901 100644 (file)
@@ -676,16 +676,30 @@ LeaseStatCmdsImpl::getSubnetStat(const SubnetID& subnet_id, const std::string& n
 
 int
 StatCmds::statLease4GetHandler(CalloutHandle& handle) {
-    LeaseStatCmdsImpl impl;
-    MultiThreadingCriticalSection sc;
-    return(impl.statLease4GetHandler(handle));
+    try {
+        LeaseStatCmdsImpl impl;
+        MultiThreadingCriticalSection sc;
+        return (impl.statLease4GetHandler(handle));
+    } catch (const std::exception& ex) {
+
+        LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE4_FAILED)
+                  .arg(ex.what());
+    }
+    return (1);
 }
 
 int
 StatCmds::statLease6GetHandler(CalloutHandle& handle) {
-    LeaseStatCmdsImpl impl;
-    MultiThreadingCriticalSection sc;
-    return(impl.statLease6GetHandler(handle));
+    try {
+        LeaseStatCmdsImpl impl;
+        MultiThreadingCriticalSection sc;
+        return (impl.statLease6GetHandler(handle));
+    } catch (const std::exception& ex) {
+
+        LOG_ERROR(stat_cmds_logger, STAT_CMDS_LEASE6_FAILED)
+                  .arg(ex.what());
+    }
+    return (1);
 }
 
 };
index a8dddfecd84d2cd5160d9477f0ba5d66a968f454..9c5d58b13f15b57dc611bb023687917d4cf7f05f 100644 (file)
@@ -8,10 +8,12 @@ extern const isc::log::MessageID STAT_CMDS_DEINIT_FAILED = "STAT_CMDS_DEINIT_FAI
 extern const isc::log::MessageID STAT_CMDS_DEINIT_OK = "STAT_CMDS_DEINIT_OK";
 extern const isc::log::MessageID STAT_CMDS_INIT_FAILED = "STAT_CMDS_INIT_FAILED";
 extern const isc::log::MessageID STAT_CMDS_INIT_OK = "STAT_CMDS_INIT_OK";
+extern const isc::log::MessageID STAT_CMDS_LEASE4_FAILED = "STAT_CMDS_LEASE4_FAILED";
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET = "STAT_CMDS_LEASE4_GET";
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_FAILED = "STAT_CMDS_LEASE4_GET_FAILED";
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_INVALID = "STAT_CMDS_LEASE4_GET_INVALID";
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_NO_SUBNETS = "STAT_CMDS_LEASE4_GET_NO_SUBNETS";
+extern const isc::log::MessageID STAT_CMDS_LEASE6_FAILED = "STAT_CMDS_LEASE6_FAILED";
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET = "STAT_CMDS_LEASE6_GET";
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET_FAILED = "STAT_CMDS_LEASE6_GET_FAILED";
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET_INVALID = "STAT_CMDS_LEASE6_GET_INVALID";
@@ -24,12 +26,14 @@ const char* values[] = {
     "STAT_CMDS_DEINIT_OK", "unloading Stat Commands hooks library successful",
     "STAT_CMDS_INIT_FAILED", "loading Stat Commands hooks library failed: %1",
     "STAT_CMDS_INIT_OK", "loading Stat Commands hooks library successful",
+    "STAT_CMDS_LEASE4_FAILED", "stat-lease4-get command failed: reason: %1",
     "STAT_CMDS_LEASE4_GET", "stat-lease4-get command successful, parameters: %1 rows found: %2",
     "STAT_CMDS_LEASE4_GET_FAILED", "stat-lease4-get command failed: parameters: %1, reason: %2",
     "STAT_CMDS_LEASE4_GET_INVALID", "stat-lease4-get command is malformed or invalid, reason: %1",
     "STAT_CMDS_LEASE4_GET_NO_SUBNETS", "stat-lease4-get, parameters: %1, %2\"",
+    "STAT_CMDS_LEASE6_FAILED", "stat-lease6-get command failed: reason: %1",
     "STAT_CMDS_LEASE6_GET", "stat-lease6-get command successful, parameters: %1 rows found: %2",
-    "STAT_CMDS_LEASE6_GET_FAILED", "stat-lease4-get command failed: parameters: %1, reason: %2",
+    "STAT_CMDS_LEASE6_GET_FAILED", "stat-lease6-get command failed: parameters: %1, reason: %2",
     "STAT_CMDS_LEASE6_GET_INVALID", "stat-lease6-get command is malformed or invalid, reason: %1",
     "STAT_CMDS_LEASE6_GET_NO_SUBNETS", "stat-lease6-get, parameters: %1, %2\"",
     NULL
index c35863e0d2c00d79b6dd1a425b98dc5fe364cd9f..7baa360011120a8ac7695ac05186c7a4e3b0e3be 100644 (file)
@@ -9,10 +9,12 @@ extern const isc::log::MessageID STAT_CMDS_DEINIT_FAILED;
 extern const isc::log::MessageID STAT_CMDS_DEINIT_OK;
 extern const isc::log::MessageID STAT_CMDS_INIT_FAILED;
 extern const isc::log::MessageID STAT_CMDS_INIT_OK;
+extern const isc::log::MessageID STAT_CMDS_LEASE4_FAILED;
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET;
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_FAILED;
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_INVALID;
 extern const isc::log::MessageID STAT_CMDS_LEASE4_GET_NO_SUBNETS;
+extern const isc::log::MessageID STAT_CMDS_LEASE6_FAILED;
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET;
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET_FAILED;
 extern const isc::log::MessageID STAT_CMDS_LEASE6_GET_INVALID;
index 3b3d0c744d80e0ee9f5eb4c936f4ab3e9b5702e9..6db097681cb92292d20597a87ab35691c6206337 100644 (file)
@@ -26,6 +26,9 @@ the parameters supplied and the number of rows found.
 The stat-lease4-get command has failed. Both the parameters supplied and
 the reason for failure are logged.
 
+% STAT_CMDS_LEASE4_FAILED stat-lease4-get command failed: reason: %1
+The stat-lease4-get command has failed. The reason for failure is logged.
+
 % STAT_CMDS_LEASE4_GET_INVALID stat-lease4-get command is malformed or invalid, reason: %1
 The stat-lease4-get command was either malformed or contained invalid
 parameters.  A detailed explanation should be logged.
@@ -39,10 +42,13 @@ be logged.
 The stat-lease6-get command has been successful. The log will contain
 the parameters supplied and the number of rows found.
 
-% STAT_CMDS_LEASE6_GET_FAILED stat-lease4-get command failed: parameters: %1, reason: %2
+% STAT_CMDS_LEASE6_GET_FAILED stat-lease6-get command failed: parameters: %1, reason: %2
 The stat-lease6-get command has failed. Both the parameters supplied and
 the reason for failure are logged.
 
+% STAT_CMDS_LEASE6_FAILED stat-lease6-get command failed: reason: %1
+The stat-lease6-get command has failed. The reason for failure is logged.
+
 % STAT_CMDS_LEASE6_GET_INVALID stat-lease6-get command is malformed or invalid, reason: %1
 The stat-lease6-get command was either malformed or contained invalid
 parameters.  A detailed explanation should be logged.