From: Thomas Markwalder Date: Tue, 11 Aug 2020 18:34:02 +0000 (-0400) Subject: [#1369] Addressed review comments X-Git-Tag: Kea-1.8.0~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d1f5e0e96b70ce2a8daafa03b5bfde34245b88d;p=thirdparty%2Fkea.git [#1369] Addressed review comments --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 16e48d8705..5741a94fd8 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -1136,7 +1136,7 @@ void ControlledDhcpv4Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { bool reopened = false; - // We lost at least one of them, Reopen all of them (lease, host, and CB databases) + // We lost at least one of them, Reopen all of them (lease, host, and CB databases). try { CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess(); cfg_db->createManagers(); @@ -1228,9 +1228,11 @@ ControlledDhcpv4Srv::cbFetchUpdates(const SrvConfigPtr& srv_cfg, server_->getCBControl()->databaseConfigFetch(srv_cfg, CBControlDHCPv4::FetchMode::FETCH_UPDATE); (*failure_count) = 0; + } catch (const std::exception& ex) { LOG_ERROR(dhcp4_logger, DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL) .arg(ex.what()); + // We allow at most 10 consecutive failures after which we stop // making further attempts to fetch the configuration updates. // Let's return without re-scheduling the timer. diff --git a/src/lib/mysql/mysql_connection.cc b/src/lib/mysql/mysql_connection.cc index b8577c97da..c95dc0b5b4 100644 --- a/src/lib/mysql/mysql_connection.cc +++ b/src/lib/mysql/mysql_connection.cc @@ -299,7 +299,6 @@ MySqlConnection::getVersion(const ParameterMap& parameters) { void MySqlConnection::prepareStatement(uint32_t index, const char* text) { - checkUnusable(); // Validate that there is space for the statement in the statements array // and that nothing has been placed there before. if ((index >= statements_.size()) || (statements_[index] != NULL)) { @@ -326,7 +325,6 @@ MySqlConnection::prepareStatement(uint32_t index, const char* text) { void MySqlConnection::prepareStatements(const TaggedStatement* start_statement, const TaggedStatement* end_statement) { - checkUnusable(); // Created the MySQL prepared statements for each DML statement. for (const TaggedStatement* tagged_statement = start_statement; tagged_statement != end_statement; ++tagged_statement) { diff --git a/src/lib/pgsql/pgsql_connection.cc b/src/lib/pgsql/pgsql_connection.cc index 21a36f992f..3b32f3d39c 100644 --- a/src/lib/pgsql/pgsql_connection.cc +++ b/src/lib/pgsql/pgsql_connection.cc @@ -363,6 +363,7 @@ PgSqlConnection::checkStatementError(const PgSqlResult& r, void PgSqlConnection::startTransaction() { DB_LOG_DEBUG(DB_DBG_TRACE_DETAIL, PGSQL_START_TRANSACTION); + checkUnusable(); PgSqlResult r(PQexec(conn_, "START TRANSACTION")); if (PQresultStatus(r) != PGRES_COMMAND_OK) { const char* error_message = PQerrorMessage(conn_); @@ -374,6 +375,7 @@ PgSqlConnection::startTransaction() { void PgSqlConnection::commit() { DB_LOG_DEBUG(DB_DBG_TRACE_DETAIL, PGSQL_COMMIT); + checkUnusable(); PgSqlResult r(PQexec(conn_, "COMMIT")); if (PQresultStatus(r) != PGRES_COMMAND_OK) { const char* error_message = PQerrorMessage(conn_); @@ -384,6 +386,7 @@ PgSqlConnection::commit() { void PgSqlConnection::rollback() { DB_LOG_DEBUG(DB_DBG_TRACE_DETAIL, PGSQL_ROLLBACK); + checkUnusable(); PgSqlResult r(PQexec(conn_, "ROLLBACK")); if (PQresultStatus(r) != PGRES_COMMAND_OK) { const char* error_message = PQerrorMessage(conn_);