From: Razvan Becheriu Date: Fri, 13 Nov 2020 09:54:26 +0000 (+0200) Subject: [#1375] added more comments X-Git-Tag: Kea-1.9.3~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4c92e27a79823db26d5649b3d2d8f82b0093ca3;p=thirdparty%2Fkea.git [#1375] added more comments --- diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index f15d28922d..1225a85dc7 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -2296,6 +2296,25 @@ public: return (count); } + /// @brief Attempts to reconnect the server to the config DB backend manager. + /// + /// This is a self-rescheduling function that attempts to reconnect to the + /// server's host DB backends after connectivity to one or more have been + /// lost. Upon entry it will attempt to reconnect via + /// @ref ConfigBackendDHCPv4Mgr.addBackend. + /// If this is successful, DHCP servicing is re-enabled and server returns + /// to normal operation. + /// + /// If reconnection fails and the maximum number of retries has not been + /// exhausted, it will schedule a call to itself to occur at the + /// configured retry interval. DHCP service remains disabled. + /// + /// If the maximum number of retries has been exhausted an error is logged + /// and the server shuts down. + /// + /// @param db_reconnect_ctl pointer to the ReconnectCtl containing the + /// configured reconnect parameters. + /// @return true if connection has been recovered, false otherwise. static bool dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { DatabaseConnection::invokeDbLostCallback(db_reconnect_ctl); diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 3f8f5ea6e9..bc8ed45342 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -2739,6 +2739,25 @@ public: return (count); } + /// @brief Attempts to reconnect the server to the config DB backend manager. + /// + /// This is a self-rescheduling function that attempts to reconnect to the + /// server's host DB backends after connectivity to one or more have been + /// lost. Upon entry it will attempt to reconnect via + /// @ref ConfigBackendDHCPv6Mgr.addBackend. + /// If this is successful, DHCP servicing is re-enabled and server returns + /// to normal operation. + /// + /// If reconnection fails and the maximum number of retries has not been + /// exhausted, it will schedule a call to itself to occur at the + /// configured retry interval. DHCP service remains disabled. + /// + /// If the maximum number of retries has been exhausted an error is logged + /// and the server shuts down. + /// + /// @param db_reconnect_ctl pointer to the ReconnectCtl containing the + /// configured reconnect parameters. + /// @return true if connection has been recovered, false otherwise. static bool dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { DatabaseConnection::invokeDbLostCallback(db_reconnect_ctl); diff --git a/src/lib/config_backend/base_config_backend.h b/src/lib/config_backend/base_config_backend.h index ad9da62be8..fb6f8ab6c1 100644 --- a/src/lib/config_backend/base_config_backend.h +++ b/src/lib/config_backend/base_config_backend.h @@ -63,14 +63,14 @@ public: /// connection. /// /// @return true if there is at least one unusable connection, false - /// otherwise + /// otherwise. virtual bool isUnusable() { return (false); } - /// @brief Return backend parameters + /// @brief Return backend parameters. /// - /// Returns the backend parameters + /// Returns the backend parameters. /// /// @return Parameters of the backend. virtual isc::db::DatabaseConnection::ParameterMap getParameters() const { diff --git a/src/lib/config_backend/base_config_backend_mgr.h b/src/lib/config_backend/base_config_backend_mgr.h index 8f3efd25bf..6818effefb 100644 --- a/src/lib/config_backend/base_config_backend_mgr.h +++ b/src/lib/config_backend/base_config_backend_mgr.h @@ -188,7 +188,7 @@ public: /// specific parameters. /// This should have the effect of closing the database connection. /// - /// @param db_type Backend to remove + /// @param db_type Backend to remove. /// @param dbaccess Database access string being a collection of /// key=value pairs. /// @param if_unusable Flag which indicates if the config backend manager diff --git a/src/lib/config_backend/base_config_backend_pool.h b/src/lib/config_backend/base_config_backend_pool.h index 01347476a0..fab02171bc 100644 --- a/src/lib/config_backend/base_config_backend_pool.h +++ b/src/lib/config_backend/base_config_backend_pool.h @@ -64,7 +64,7 @@ public: /// @brief Deletes all backends of the given type from the pool. /// - /// @param db_type Backend to remove + /// @param db_type Backend to remove. void delAllBackends(const std::string& db_type) { typename std::list::iterator backend = backends_.begin(); @@ -79,7 +79,7 @@ public: /// @brief Deletes all backends of the given type from the pool. /// - /// @param db_type Backend to remove + /// @param db_type Backend to remove. /// @param dbaccess Database access string being a collection of /// key=value pairs. /// @param if_unusable Flag which indicates if the config backend manager diff --git a/src/lib/database/database_connection.h b/src/lib/database/database_connection.h index 301f3a1378..0910a5a464 100644 --- a/src/lib/database/database_connection.h +++ b/src/lib/database/database_connection.h @@ -201,7 +201,7 @@ public: /// @brief The reconnect settings. /// - /// @brief return The reconnect settings. + /// @return The reconnect settings. ReconnectCtlPtr reconnectCtl() { return (reconnect_ctl_); } diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 8677d74324..90d16cd28b 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -2775,6 +2775,10 @@ MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const DatabaseConnection::Param : parameters_(parameters), ip_reservations_unique_(true), unusable_(false), timer_name_("") { + timer_name_ = "MySqlHostMgr["; + timer_name_ += boost::lexical_cast(reinterpret_cast(this)); + timer_name_ += "]DbReconnectTimer"; + // Validate the schema version first. std::pair code_version(MYSQL_SCHEMA_VERSION_MAJOR, MYSQL_SCHEMA_VERSION_MINOR); @@ -2793,10 +2797,6 @@ MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const DatabaseConnection::Param auto db_reconnect_ctl = pool_->pool_[0]->conn_.reconnectCtl(); - timer_name_ = "MySqlHostMgr["; - timer_name_ += boost::lexical_cast(reinterpret_cast(this)); - timer_name_ += "]DbReconnectTimer"; - TimerMgr::instance()->registerTimer(timer_name_, std::bind(&MySqlHostDataSourceImpl::dbReconnect, db_reconnect_ctl), db_reconnect_ctl->retryInterval(), diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index cd98224a98..8687980ccd 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1261,7 +1261,7 @@ PgSqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { try { CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess(); LeaseMgrFactory::destroy(); - LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString()/*, io_service_ */); + LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString()); reopened = true; } catch (const std::exception& ex) {