From: Thomas Markwalder Date: Mon, 6 Jul 2015 13:35:38 +0000 (-0400) Subject: [3769] Removed static from Daemon::config_file_ and proc_name_ X-Git-Tag: trac3785_base~2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c6b2862c9cac1e6486a256a17385174528325a1;p=thirdparty%2Fkea.git [3769] Removed static from Daemon::config_file_ and proc_name_ Rendered config_file_ and proc_name_ instance members as there is no reason for them to be static. --- diff --git a/src/bin/d2/tests/d_controller_unittests.cc b/src/bin/d2/tests/d_controller_unittests.cc index f5612b5c38..e882bd4c5c 100644 --- a/src/bin/d2/tests/d_controller_unittests.cc +++ b/src/bin/d2/tests/d_controller_unittests.cc @@ -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. diff --git a/src/lib/dhcpsrv/daemon.cc b/src/lib/dhcpsrv/daemon.cc index 49868c3ee1..a020b0abb2 100644 --- a/src/lib/dhcpsrv/daemon.cc +++ b/src/lib/dhcpsrv/daemon.cc @@ -34,14 +34,9 @@ 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_); }; diff --git a/src/lib/dhcpsrv/daemon.h b/src/lib/dhcpsrv/daemon.h index 77035dbb69..94a6e38ab9 100644 --- a/src/lib/dhcpsrv/daemon.h +++ b/src/lib/dhcpsrv/daemon.h @@ -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 diff --git a/src/lib/dhcpsrv/tests/daemon_unittest.cc b/src/lib/dhcpsrv/tests/daemon_unittest.cc index b6618e539b..afc791fe70 100644 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@ -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(""); } };