]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3769] Removed static from Daemon::config_file_ and proc_name_
authorThomas Markwalder <tmark@isc.org>
Mon, 6 Jul 2015 13:35:38 +0000 (09:35 -0400)
committerThomas Markwalder <tmark@isc.org>
Mon, 6 Jul 2015 13:35:38 +0000 (09:35 -0400)
Rendered config_file_ and proc_name_ instance members as there is
no reason for them to be static.

src/bin/d2/tests/d_controller_unittests.cc
src/lib/dhcpsrv/daemon.cc
src/lib/dhcpsrv/daemon.h
src/lib/dhcpsrv/tests/daemon_unittest.cc

index f5612b5c38fa72cfb855129767b67c3d0c76994a..e882bd4c5c17c16dd4607e2f2bdc9c4dad801cde 100644 (file)
@@ -229,7 +229,7 @@ TEST_F(DStubControllerTest, missingConfigFileArgument) {
     int argc = 2;
 
     // Record start time, and invoke launch().
-    EXPECT_THROW(launch(argc, argv), ProcessInitError);
+    EXPECT_THROW(launch(argc, argv), LaunchError);
 }
 
 /// @brief Tests launch with an operational error during application execution.
index 49868c3ee1c4e635eb997ba8144ffb4aad3fba21..a020b0abb2008e3be9ec05dbb76d4832673cc2f5 100644 (file)
 namespace isc {
 namespace dhcp {
 
-// This is an initial config file location.
-std::string Daemon::config_file_ = "";
-
-std::string Daemon::proc_name_ = "";
-
 Daemon::Daemon()
-    : signal_set_(), signal_handler_(), pid_file_dir_(DHCP_DATA_DIR),
-    pid_file_(), am_file_author_(false) {
+    : signal_set_(), signal_handler_(), config_file_(""), proc_name_(""),
+    pid_file_dir_(DHCP_DATA_DIR), pid_file_(), am_file_author_(false) {
 
     // The pid_file_dir can be overridden via environment variable
     // This is primarily intended to simplify testing
@@ -113,13 +108,18 @@ std::string Daemon::getVersion(bool /*extended*/) {
     isc_throw(isc::NotImplemented, "Daemon::getVersion() called");
 }
 
+std::string
+Daemon::getConfigFile() const {
+    return (config_file_);
+}
+
 void
 Daemon::setConfigFile(const std::string& config_file) {
     config_file_ = config_file;
 }
 
 std::string
-Daemon::getProcName() {
+Daemon::getProcName() const {
     return (proc_name_);
 };
 
index 77035dbb69a4811ed88d931d22c45ea564fac959..94a6e38ab912dd6d952188532be10847c8241dc7 100644 (file)
@@ -46,16 +46,6 @@ public:
 /// Dhcpv6Srv) in tests, without going through the hassles of implemeting stub
 /// methods.
 ///
-/// This class comprises a static object holding a location of the configuration
-/// file. The object must be static because it is instantiated by the signal
-/// handler functions, which are static by their nature. The signal handlers
-/// are used to reconfigure a running server and they need access to the
-/// configuration file location. They get this access by calling
-/// @c Daemon::getConfigFile function.
-///
-/// By default, the configuration file location is empty and its actual value
-/// is assigned to the static object in @c Daemon::init function.
-///
 /// Classes derived from @c Daemon may install custom signal handlers using
 /// @c isc::util::SignalSet class. This base class provides a declaration
 /// of the @c SignalSet object that should be initialized in the derived
@@ -81,6 +71,10 @@ public:
 
     /// @brief Initializes the server.
     ///
+    /// @todo #3753 - This method should be revisited as its original purpose
+    /// has been lost.  As of #3769, it has been superseded with setConfigFile().
+    /// None of the following is currently accurate.
+    ///
     /// Depending on the configuration backend, it establishes msgq session,
     /// or reads the configuration file.
     ///
@@ -111,11 +105,6 @@ public:
     /// @brief Initiates shutdown procedure for the whole DHCPv6 server.
     virtual void shutdown();
 
-    /// @brief Returns config file name.
-    static std::string getConfigFile() {
-        return (config_file_);
-    }
-
     /// @brief Initializes logger
     ///
     /// This method initializes logging system. It also sets the default
@@ -169,19 +158,23 @@ public:
     /// @return text string
     static std::string getVersion(bool extended);
 
+    /// @brief Returns config file name.
+    /// @return text string
+    std::string getConfigFile() const;
+
     /// @brief Sets the configuration file name
     ///
     /// @param config_file pathname of the configuration file
-    static void setConfigFile(const std::string& config_file);
+    void setConfigFile(const std::string& config_file);
 
     /// @brief returns the process name
     /// This value is used as when forming the default PID file name
     /// @return text string
-    static std::string getProcName();
+    std::string getProcName() const;
 
     /// @brief Sets the process name
     /// @param proc_name name the process by which the process is recognized
-    static void setProcName(const std::string& proc_name);
+    void setProcName(const std::string& proc_name);
 
     /// @brief Returns the directory used when forming default PID file name
     /// @return text string
@@ -252,10 +245,10 @@ protected:
 
 private:
     /// @brief Config file name or empty if config file not used.
-    static std::string config_file_;
+    std::string config_file_;
 
     /// @brief Name of this process, used when creating its pid file
-    static std::string proc_name_;
+    std::string proc_name_;
 
     /// @brief Pointer to the directory where PID file(s) are written
     /// It defaults to --localstatedir
index b6618e539b2bc1fb7e4a6bfa7d197139fb0ad286..afc791fe7006b6b590aecdd9bd25b0683bc02d29 100644 (file)
@@ -65,9 +65,6 @@ public:
     /// the default after each test completes.
     ~DaemonTest() {
         isc::log::setDefaultLoggingOutput();
-        // Since they're static we need to clear them between tests
-        Daemon::setConfigFile("");
-        Daemon::setProcName("");
     }
 };