]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1005] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 14 Apr 2020 13:16:20 +0000 (15:16 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 14 Apr 2020 18:31:35 +0000 (20:31 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/ctrl_dhcp4_srv.h
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.h
src/lib/stats/stats_mgr.cc
src/lib/stats/stats_mgr.h

index e89504cebd9df7fd186e0ccd98963c309ac1b660..ebbb15ecd78040ff2b75525cdd386f456ecaac2b 100644 (file)
@@ -639,9 +639,10 @@ ControlledDhcpv4Srv::commandStatusGetHandler(const string&,
 ConstElementPtr
 ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(const string&,
                                                                  ConstElementPtr args) {
-    ConstElementPtr answer = StatsMgr::statisticSetMaxSampleCountAllHandler(args);
+    StatsMgr& stats_mgr = StatsMgr::instance();
+    ConstElementPtr answer = stats_mgr.statisticSetMaxSampleCountAllHandler(args);
     // Update the default parameter.
-    long max_samples = StatsMgr::instance().getMaxSampleCountDefault();
+    long max_samples = stats_mgr.getMaxSampleCountDefault();
     CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
         "statistic-default-sample-count", Element::create(max_samples));
     return (answer);
@@ -649,10 +650,11 @@ ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(const string&,
 
 ConstElementPtr
 ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler(const string&,
-                                                                 ConstElementPtr args) {
-    ConstElementPtr answer = StatsMgr::statisticSetMaxSampleAgeAllHandler(args);
+                                                               ConstElementPtr args) {
+    StatsMgr& stats_mgr = StatsMgr::instance();
+    ConstElementPtr answer = stats_mgr.statisticSetMaxSampleAgeAllHandler(args);
     // Update the default parameter.
-    auto duration = StatsMgr::instance().getMaxSampleAgeDefault();
+    auto duration = stats_mgr.getMaxSampleAgeDefault();
     long max_age = duration.total_seconds();
     CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
         "statistic-default-sample-age", Element::create(max_age));
index eeaf47e8577ed98c7479df711f8d10e577bbbf8e..cc77f4727c9c4b1a5de9a05656a50f7e6c53bd5c 100644 (file)
@@ -332,7 +332,7 @@ private:
     /// @brief handler for processing 'statistic-sample-count-set-all' command
     ///
     /// This handler processes statistic-sample-count-set-all command,
-    /// which set max_sample_count_ limit of all statistics and the default.
+    /// which sets max_sample_count_ limit of all statistics and the default.
     /// @ref isc::stats::StatsMgr::statisticSetMaxSampleCountAllHandler
     ///
     /// @param command (ignored)
@@ -345,7 +345,7 @@ private:
     /// @brief handler for processing 'statistic-sample-age-set-all' command
     ///
     /// This handler processes statistic-sample-age-set-all command,
-    /// which set max_sample_age_ limit of all statistics and the default.
+    /// which sets max_sample_age_ limit of all statistics and the default.
     /// @ref isc::stats::StatsMgr::statisticSetMaxSampleAgeAllHandler
     ///
     /// @param command (ignored)
index bb7899cd575b93fbfbba781e116165272c153cb4..c54256b15a09feb824f48e9fb1dc89e42cdbd605 100644 (file)
@@ -643,9 +643,10 @@ ControlledDhcpv6Srv::commandStatusGetHandler(const string&,
 ConstElementPtr
 ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler(const string&,
                                                                  ConstElementPtr args) {
-    ConstElementPtr answer = StatsMgr::statisticSetMaxSampleCountAllHandler(args);
+    StatsMgr& stats_mgr = StatsMgr::instance();
+    ConstElementPtr answer = stats_mgr.statisticSetMaxSampleCountAllHandler(args);
     // Update the default parameter.
-    long max_samples = StatsMgr::instance().getMaxSampleCountDefault();
+    long max_samples = stats_mgr.getMaxSampleCountDefault();
     CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
         "statistic-default-sample-count", Element::create(max_samples));
     return (answer);
@@ -653,10 +654,11 @@ ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler(const string&,
 
 ConstElementPtr
 ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler(const string&,
-                                                                 ConstElementPtr args) {
-    ConstElementPtr answer = StatsMgr::statisticSetMaxSampleAgeAllHandler(args);
+                                                               ConstElementPtr args) {
+    StatsMgr& stats_mgr = StatsMgr::instance();
+    ConstElementPtr answer = stats_mgr.statisticSetMaxSampleAgeAllHandler(args);
     // Update the default parameter.
-    auto duration = StatsMgr::instance().getMaxSampleAgeDefault();
+    auto duration = stats_mgr.getMaxSampleAgeDefault();
     long max_age = duration.total_seconds();
     CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
         "statistic-default-sample-age", Element::create(max_age));
index a09f084c96d3c3fa3e2ac9147adb499f70150d3e..1dcf6e289a59710efde403c24f307fff1a1c4ad7 100644 (file)
@@ -332,7 +332,7 @@ private:
     /// @brief handler for processing 'statistic-sample-count-set-all' command
     ///
     /// This handler processes statistic-sample-count-set-all command,
-    /// which set max_sample_count_ limit of all statistics and the default.
+    /// which sets max_sample_count_ limit of all statistics and the default.
     /// @ref isc::stats::StatsMgr::statisticSetMaxSampleCountAllHandler
     ///
     /// @param command (ignored)
@@ -345,7 +345,7 @@ private:
     /// @brief handler for processing 'statistic-sample-age-set-all' command
     ///
     /// This handler processes statistic-sample-age-set-all command,
-    /// which set max_sample_age_ limit of all statistics and the default.
+    /// which sets max_sample_age_ limit of all statistics and the default.
     /// @ref isc::stats::StatsMgr::statisticSetMaxSampleAgeAllHandler
     ///
     /// @param command (ignored)
index 026816299dc24b75083359f28b9a9291b718cc8f..67f5e5a3384897f39795925517c3e28f398fd742 100644 (file)
@@ -545,6 +545,7 @@ StatsMgr::statisticSetMaxSampleAgeAllHandler(const ConstElementPtr& params) {
         return (createAnswer(CONTROL_RESULT_ERROR, error));
     }
     if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
         StatsMgr::instance().setMaxSampleCountDefaultInternal(0);
         StatsMgr::instance().setMaxSampleAgeDefaultInternal(duration);
         StatsMgr::instance().setMaxSampleAgeAllInternal(duration);
@@ -569,6 +570,7 @@ StatsMgr::statisticSetMaxSampleCountAllHandler(const ConstElementPtr& params) {
         return (createAnswer(CONTROL_RESULT_ERROR, error));
     }
     if (MultiThreadingMgr::instance().getMode()) {
+        lock_guard<mutex> lock(*mutex_);
         StatsMgr::instance().setMaxSampleCountDefaultInternal(max_samples);
         StatsMgr::instance().setMaxSampleCountAllInternal(max_samples);
     } else {
index 845429c5f99c7304b7e61a242db204377b66526a..59ed8445e1c7ce3953ade84778c495cd39d56aee 100644 (file)
@@ -347,7 +347,7 @@ public:
     /// @brief Handles statistic-sample-age-set command
     ///
     /// This method handles statistic-sample-age-set command,
-    /// which set max_sample_age_ limit of a given statistic
+    /// which sets max_sample_age_ limit of a given statistic
     /// and leaves max_sample_count_ disabled.
     /// It expects two parameters stored in params map:
     /// name: name of the statistic
@@ -369,7 +369,7 @@ public:
     /// @brief Handles statistic-sample-count-set command
     ///
     /// This method handles statistic-sample-count-set command,
-    /// which set max_sample_count_ limit of a given statistic
+    /// which sets max_sample_count_ limit of a given statistic
     /// and leaves max_sample_age_ disabled.
     /// It expects two parameters stored in params map:
     /// name: name of the statistic
@@ -427,7 +427,7 @@ public:
     /// @brief Handles statistic-sample-age-set-all command
     ///
     /// This method handles statistic-sample-age-set-all command,
-    /// which set max_sample_age_ limit to all statistics and the default.
+    /// which sets max_sample_age_ limit to all statistics and the default.
     /// It expects one parameter stored in params map:
     /// duration: limit expressed as a number of seconds
     ///
@@ -438,13 +438,13 @@ public:
     ///
     /// @param params structure containing a map that contains "duration"
     /// @return answer confirming success of this operation
-    static isc::data::ConstElementPtr
+    isc::data::ConstElementPtr
     statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr& params);
 
     /// @brief Handles statistic-sample-count-set-all command
     ///
     /// This method handles statistic-sample-count-set-all command,
-    /// which set max_sample_count_ limit of all statistics and the default.
+    /// which sets max_sample_count_ limit of all statistics and the default.
     /// It expects one parameter stored in params map:
     /// max-samples: count limit
     /// The value 0 is out of range.
@@ -456,7 +456,7 @@ public:
     ///
     /// @param params structure containing a map that contains "max-samples"
     /// @return answer confirming success of this operation
-    static isc::data::ConstElementPtr
+    isc::data::ConstElementPtr
     statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr& params);
 
     /// @}
@@ -612,14 +612,14 @@ private:
     ///
     /// Should be called in a thread safe context.
     ///
-    /// @param duration determines default maximum age of samples
+    /// @param duration default maximum age of samples to keep.
     void setMaxSampleAgeDefaultInternal(const StatsDuration& duration);
 
     /// @brief Set default count limit.
     ///
     /// Should be called in a thread safe context.
     ///
-    /// @param max_samples default maximum number of samples to keep
+    /// @param max_samples default maximum number of samples to keep.
     /// (0 means to disable count limit and enable age limit)
     void setMaxSampleCountDefaultInternal(uint32_t max_samples);