2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-04 07:55:18 +00:00

[#1621] addressed comments

This commit is contained in:
Razvan Becheriu
2021-03-17 17:32:54 +02:00
parent 0e05913ccc
commit f37892a82b
11 changed files with 65 additions and 77 deletions

View File

@@ -3009,10 +3009,12 @@ MySqlConfigBackendDHCPv4Impl::MySqlConfigBackendDHCPv4Impl(const DatabaseConnect
tagged_statements.end()); tagged_statements.end());
// tagged_statements.begin() + WRITE_STMTS_BEGIN); // tagged_statements.begin() + WRITE_STMTS_BEGIN);
// Create unique timer name per instance.
timer_name_ = "MySqlConfigBackend4["; timer_name_ = "MySqlConfigBackend4[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
// Create ReconnectCtl for this connection.
conn_.makeReconnectCtl(timer_name_); conn_.makeReconnectCtl(timer_name_);
} }

View File

@@ -3482,10 +3482,12 @@ MySqlConfigBackendDHCPv6Impl::MySqlConfigBackendDHCPv6Impl(const DatabaseConnect
tagged_statements.end()); tagged_statements.end());
// tagged_statements.begin() + WRITE_STMTS_BEGIN); // tagged_statements.begin() + WRITE_STMTS_BEGIN);
// Create unique timer name per instance.
timer_name_ = "MySqlConfigBackend6["; timer_name_ = "MySqlConfigBackend6[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
// Create ReconnectCtl for this connection.
conn_.makeReconnectCtl(timer_name_); conn_.makeReconnectCtl(timer_name_);
} }

View File

@@ -4176,7 +4176,7 @@ public:
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
} }
~MySqlConfigBackendDHCPv4DbLostCallbackTest() { virtual ~MySqlConfigBackendDHCPv4DbLostCallbackTest() {
isc::db::DatabaseConnection::db_lost_callback_ = 0; isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0; isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0; isc::db::DatabaseConnection::db_failed_callback_ = 0;
@@ -4191,10 +4191,6 @@ public:
/// appropriate schema and create a basic DB manager to /// appropriate schema and create a basic DB manager to
/// wipe out any prior instance /// wipe out any prior instance
virtual void SetUp() { virtual void SetUp() {
isc::dhcp::MySqlConfigBackendImpl::setIOService(io_service_);
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// Ensure we have the proper schema with no transient data. // Ensure we have the proper schema with no transient data.
createMySQLSchema(); createMySQLSchema();
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
@@ -4206,10 +4202,6 @@ public:
/// Invoked by gtest upon test exit, we destroy the schema /// Invoked by gtest upon test exit, we destroy the schema
/// we created. /// we created.
virtual void TearDown() { virtual void TearDown() {
isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr());
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// If data wipe enabled, delete transient data otherwise destroy the schema // If data wipe enabled, delete transient data otherwise destroy the schema
destroyMySQLSchema(); destroyMySQLSchema();
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
@@ -4239,10 +4231,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked /// -# The registered DbRecoveredCallback was invoked
@@ -4251,10 +4243,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked /// -# The registered DbFailedCallback was invoked
@@ -4263,10 +4255,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked after two reconnect /// -# The registered DbRecoveredCallback was invoked after two reconnect
@@ -4276,10 +4268,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked after two reconnect /// -# The registered DbFailedCallback was invoked after two reconnect

View File

@@ -4351,7 +4351,7 @@ public:
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
} }
~MySqlConfigBackendDHCPv6DbLostCallbackTest() { virtual ~MySqlConfigBackendDHCPv6DbLostCallbackTest() {
isc::db::DatabaseConnection::db_lost_callback_ = 0; isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0; isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0; isc::db::DatabaseConnection::db_failed_callback_ = 0;
@@ -4366,10 +4366,6 @@ public:
/// appropriate schema and create a basic DB manager to /// appropriate schema and create a basic DB manager to
/// wipe out any prior instance /// wipe out any prior instance
virtual void SetUp() { virtual void SetUp() {
isc::dhcp::MySqlConfigBackendImpl::setIOService(io_service_);
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// Ensure we have the proper schema with no transient data. // Ensure we have the proper schema with no transient data.
createMySQLSchema(); createMySQLSchema();
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
@@ -4381,10 +4377,6 @@ public:
/// Invoked by gtest upon test exit, we destroy the schema /// Invoked by gtest upon test exit, we destroy the schema
/// we created. /// we created.
virtual void TearDown() { virtual void TearDown() {
isc::dhcp::MySqlConfigBackendImpl::setIOService(isc::asiolink::IOServicePtr());
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// If data wipe enabled, delete transient data otherwise destroy the schema // If data wipe enabled, delete transient data otherwise destroy the schema
destroyMySQLSchema(); destroyMySQLSchema();
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
@@ -4414,10 +4406,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked /// -# The registered DbRecoveredCallback was invoked
@@ -4426,10 +4418,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked /// -# The registered DbFailedCallback was invoked
@@ -4438,10 +4430,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbRecoveredCallback was invoked after two reconnect /// -# The registered DbRecoveredCallback was invoked after two reconnect
@@ -4451,10 +4443,10 @@ public:
/// @brief Verifies the CB manager's behavior if DB connection is lost /// @brief Verifies the CB manager's behavior if DB connection is lost
/// ///
/// This function creates a CB manager with a back end that supports /// This function creates a CB manager with a back end that supports
/// connectivity lost callback (currently only MySQL and PostgreSQL). It /// connectivity lost callback. It verifies connectivity by issuing a known
/// verifies connectivity by issuing a known valid query. Next it simulates /// valid query. Next it simulates connectivity lost by identifying and
/// connectivity lost by identifying and closing the socket connection to /// closing the socket connection to the CB backend. It then reissues the
/// the CB backend. It then reissues the query and verifies that: /// query and verifies that:
/// -# The Query throws DbOperationError (rather than exiting) /// -# The Query throws DbOperationError (rather than exiting)
/// -# The registered DbLostCallback was invoked /// -# The registered DbLostCallback was invoked
/// -# The registered DbFailedCallback was invoked after two reconnect /// -# The registered DbFailedCallback was invoked after two reconnect

View File

@@ -2781,6 +2781,7 @@ MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const DatabaseConnection::Param
: parameters_(parameters), ip_reservations_unique_(true), unusable_(false), : parameters_(parameters), ip_reservations_unique_(true), unusable_(false),
timer_name_("") { timer_name_("") {
// Create unique timer name per instance.
timer_name_ = "MySqlHostMgr["; timer_name_ = "MySqlHostMgr[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
@@ -2841,6 +2842,7 @@ MySqlHostDataSourceImpl::createContext() const {
ctx->host_ipv6_reservation_exchange_.reset(new MySqlIPv6ReservationExchange()); ctx->host_ipv6_reservation_exchange_.reset(new MySqlIPv6ReservationExchange());
ctx->host_option_exchange_.reset(new MySqlOptionExchange()); ctx->host_option_exchange_.reset(new MySqlOptionExchange());
// Create ReconnectCtl for this connection.
ctx->conn_.makeReconnectCtl(timer_name_); ctx->conn_.makeReconnectCtl(timer_name_);
return (ctx); return (ctx);
@@ -2872,7 +2874,6 @@ MySqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
HostMgr::addBackend(hds); HostMgr::addBackend(hds);
} }
} }
reopened = true; reopened = true;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED) LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED)
@@ -2902,7 +2903,6 @@ MySqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Invoke application layer connection failed callback. // Invoke application layer connection failed callback.
DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl); DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
return (false); return (false);
} }

View File

@@ -1783,6 +1783,7 @@ MySqlLeaseMgr::MySqlLeaseContextAlloc::~MySqlLeaseContextAlloc() {
MySqlLeaseMgr::MySqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) MySqlLeaseMgr::MySqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters), timer_name_("") { : parameters_(parameters), timer_name_("") {
// Create unique timer name per instance.
timer_name_ = "MySqlLeaseMgr["; timer_name_ = "MySqlLeaseMgr[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
@@ -1825,7 +1826,6 @@ MySqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess(); CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
LeaseMgrFactory::destroy(); LeaseMgrFactory::destroy();
LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString()); LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString());
reopened = true; reopened = true;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED) LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED)
@@ -1855,7 +1855,6 @@ MySqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Invoke application layer connection failed callback. // Invoke application layer connection failed callback.
DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl); DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
return (false); return (false);
} }
@@ -1897,6 +1896,7 @@ MySqlLeaseMgr::createContext() const {
ctx->exchange4_.reset(new MySqlLease4Exchange()); ctx->exchange4_.reset(new MySqlLease4Exchange());
ctx->exchange6_.reset(new MySqlLease6Exchange()); ctx->exchange6_.reset(new MySqlLease6Exchange());
// Create ReconnectCtl for this connection.
ctx->conn_.makeReconnectCtl(timer_name_); ctx->conn_.makeReconnectCtl(timer_name_);
return (ctx); return (ctx);

View File

@@ -2222,6 +2222,7 @@ PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl(const DatabaseConnection::Param
: parameters_(parameters), ip_reservations_unique_(true), unusable_(false), : parameters_(parameters), ip_reservations_unique_(true), unusable_(false),
timer_name_("") { timer_name_("") {
// Create unique timer name per instance.
timer_name_ = "PgSqlHostMgr["; timer_name_ = "PgSqlHostMgr[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
@@ -2277,6 +2278,7 @@ PgSqlHostDataSourceImpl::createContext() const {
ctx->host_ipv6_reservation_exchange_.reset(new PgSqlIPv6ReservationExchange()); ctx->host_ipv6_reservation_exchange_.reset(new PgSqlIPv6ReservationExchange());
ctx->host_option_exchange_.reset(new PgSqlOptionExchange()); ctx->host_option_exchange_.reset(new PgSqlOptionExchange());
// Create ReconnectCtl for this connection.
ctx->conn_.makeReconnectCtl(timer_name_); ctx->conn_.makeReconnectCtl(timer_name_);
return (ctx); return (ctx);
@@ -2308,7 +2310,6 @@ PgSqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
HostMgr::addBackend(hds); HostMgr::addBackend(hds);
} }
} }
reopened = true; reopened = true;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED) LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB_RECONNECT_ATTEMPT_FAILED)
@@ -2338,7 +2339,6 @@ PgSqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Invoke application layer connection failed callback. // Invoke application layer connection failed callback.
DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl); DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
return (false); return (false);
} }

View File

@@ -1217,6 +1217,7 @@ PgSqlLeaseMgr::PgSqlLeaseContextAlloc::~PgSqlLeaseContextAlloc() {
PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters), timer_name_("") { : parameters_(parameters), timer_name_("") {
// Create unique timer name per instance.
timer_name_ = "PgSqlLeaseMgr["; timer_name_ = "PgSqlLeaseMgr[";
timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this)); timer_name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
timer_name_ += "]DbReconnectTimer"; timer_name_ += "]DbReconnectTimer";
@@ -1259,7 +1260,6 @@ PgSqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess(); CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
LeaseMgrFactory::destroy(); LeaseMgrFactory::destroy();
LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString()); LeaseMgrFactory::create(cfg_db->getLeaseDbAccessString());
reopened = true; reopened = true;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED) LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_LEASE_DB_RECONNECT_ATTEMPT_FAILED)
@@ -1289,7 +1289,6 @@ PgSqlLeaseMgr::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
// Invoke application layer connection failed callback. // Invoke application layer connection failed callback.
DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl); DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
return (false); return (false);
} }
@@ -1339,6 +1338,7 @@ PgSqlLeaseMgr::createContext() const {
ctx->exchange4_.reset(new PgSqlLease4Exchange()); ctx->exchange4_.reset(new PgSqlLease4Exchange());
ctx->exchange6_.reset(new PgSqlLease6Exchange()); ctx->exchange6_.reset(new PgSqlLease6Exchange());
// Create ReconnectCtl for this connection.
ctx->conn_.makeReconnectCtl(timer_name_); ctx->conn_.makeReconnectCtl(timer_name_);
return (ctx); return (ctx);

View File

@@ -549,7 +549,7 @@ public:
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();
} }
~HostMgrDbLostCallbackTest() { virtual ~HostMgrDbLostCallbackTest() {
isc::db::DatabaseConnection::db_lost_callback_ = 0; isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0; isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0; isc::db::DatabaseConnection::db_failed_callback_ = 0;
@@ -564,10 +564,6 @@ public:
/// appropriate schema and create a basic host manager to /// appropriate schema and create a basic host manager to
/// wipe out any prior instance /// wipe out any prior instance
virtual void SetUp() { virtual void SetUp() {
isc::dhcp::HostMgr::setIOService(io_service_);
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// Ensure we have the proper schema with no transient data. // Ensure we have the proper schema with no transient data.
createSchema(); createSchema();
// Wipe out any pre-existing mgr // Wipe out any pre-existing mgr
@@ -580,10 +576,6 @@ public:
/// Invoked by gtest upon test exit, we destroy the schema /// Invoked by gtest upon test exit, we destroy the schema
/// we created. /// we created.
virtual void TearDown() { virtual void TearDown() {
isc::dhcp::HostMgr::setIOService(isc::asiolink::IOServicePtr());
isc::db::DatabaseConnection::db_lost_callback_ = 0;
isc::db::DatabaseConnection::db_recovered_callback_ = 0;
isc::db::DatabaseConnection::db_failed_callback_ = 0;
// If data wipe enabled, delete transient data otherwise destroy the schema // If data wipe enabled, delete transient data otherwise destroy the schema
destroySchema(); destroySchema();
isc::dhcp::CfgMgr::instance().clear(); isc::dhcp::CfgMgr::instance().clear();

View File

@@ -658,11 +658,15 @@ public:
/// ///
/// @note The recover function must be run on the IO Service thread. /// @note The recover function must be run on the IO Service thread.
void startRecoverDbConnection() { void startRecoverDbConnection() {
if (!io_service_ && io_service_access_callback_) { if (callback_) {
io_service_ = (*io_service_access_callback_)(); if (!io_service_ && io_service_access_callback_) {
} io_service_ = (*io_service_access_callback_)();
if (callback_ && io_service_) { io_service_access_callback_.reset();
io_service_->post(std::bind(callback_, reconnectCtl())); }
if (io_service_) {
io_service_->post(std::bind(callback_, reconnectCtl()));
}
} }
} }

View File

@@ -426,11 +426,15 @@ public:
/// ///
/// @note The recover function must be run on the IO Service thread. /// @note The recover function must be run on the IO Service thread.
void startRecoverDbConnection() { void startRecoverDbConnection() {
if (!io_service_ && io_service_access_callback_) { if (callback_) {
io_service_ = (*io_service_access_callback_)(); if (!io_service_ && io_service_access_callback_) {
} io_service_ = (*io_service_access_callback_)();
if (callback_ && io_service_) { io_service_access_callback_.reset();
io_service_->post(std::bind(callback_, reconnectCtl())); }
if (io_service_) {
io_service_->post(std::bind(callback_, reconnectCtl()));
}
} }
} }