From: Razvan Becheriu Date: Mon, 23 Aug 2021 23:40:35 +0000 (+0300) Subject: [#2043] added try catch block for all MT CS X-Git-Tag: Kea-1.9.11~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73951e6bc64ac240ee751e9a72a4077ab43405ed;p=thirdparty%2Fkea.git [#2043] added try catch block for all MT CS --- diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds.cc b/src/hooks/dhcp/stat_cmds/stat_cmds.cc index 520534f28f..c10c60997e 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds.cc +++ b/src/hooks/dhcp/stat_cmds/stat_cmds.cc @@ -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); } }; diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc index a8dddfecd8..9c5d58b13f 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc +++ b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc @@ -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 diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.h b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.h index c35863e0d2..7baa360011 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.h +++ b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.h @@ -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; diff --git a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.mes b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.mes index 3b3d0c744d..6db097681c 100644 --- a/src/hooks/dhcp/stat_cmds/stat_cmds_messages.mes +++ b/src/hooks/dhcp/stat_cmds/stat_cmds_messages.mes @@ -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.