From: Razvan Becheriu Date: Wed, 4 Sep 2019 15:35:34 +0000 (+0300) Subject: minor changes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fold-multi-threading-pkt-processing;p=thirdparty%2Fkea.git minor changes --- diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 71e4c6defb..4e5ee8f264 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -2348,7 +2348,6 @@ TaggedStatementArray tagged_statements = { { "h.dhcp_identifier_type, h.dhcp4_subnet_id, " "h.dhcp6_subnet_id, h.ipv4_address, h.hostname, " "h.dhcp4_client_classes, h.dhcp6_client_classes, h.user_context, " - "h.dhcp4_next_server, h.dhcp4_server_hostname, " "h.dhcp4_boot_file_name, h.auth_key, " "o.option_id, o.code, o.value, o.formatted_value, o.space, " @@ -2415,8 +2414,8 @@ TaggedStatementArray tagged_statements = { { }; // anonymous namespace MySqlHostDataSourceImpl:: -MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters) - : conn_(parameters), +MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters) : + conn_(parameters), is_readonly_(false) { // Open the database. diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index 38e6fb8d97..5b970ef7d4 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1670,8 +1670,8 @@ private: // MySqlLeaseMgr Constructor and Destructor -MySqlLeaseMgr::MySqlLeaseMgr(const MySqlConnection::ParameterMap& parameters) - : conn_(parameters) { +MySqlLeaseMgr::MySqlLeaseMgr(const MySqlConnection::ParameterMap& parameters) : + conn_(parameters) { // Open the database. conn_.openDatabase(); diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index 1a51b345c8..87ed690929 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -1621,82 +1621,6 @@ TaggedStatementArray tagged_statements = { { "ORDER BY h.host_id, o.option_id, r.reservation_id" }, - // PgSqlHostDataSourceImpl::INSERT_HOST - // Inserts a host into the 'hosts' table. Returns the inserted host id. - {13, - { OID_BYTEA, OID_INT2, OID_INT8, OID_INT8, OID_INT8, OID_VARCHAR, OID_VARCHAR, OID_VARCHAR, - OID_TEXT, OID_INT8, OID_VARCHAR, OID_VARCHAR, OID_VARCHAR}, - "insert_host", - "INSERT INTO hosts(dhcp_identifier, dhcp_identifier_type, " - " dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, " - " dhcp4_client_classes, dhcp6_client_classes, user_context, " - " dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) " - "RETURNING host_id" - }, - - //PgSqlHostDataSourceImpl::INSERT_V6_RESRV - // Inserts a single IPv6 reservation into 'reservations' table. - {5, - { OID_VARCHAR, OID_INT2, OID_INT4, OID_INT4, OID_INT4 }, - "insert_v6_resrv", - "INSERT INTO ipv6_reservations(address, prefix_len, type, " - " dhcp6_iaid, host_id) " - "VALUES ($1, $2, $3, $4, $5)" - }, - - // PgSqlHostDataSourceImpl::INSERT_V4_HOST_OPTION - // Inserts a single DHCPv4 option into 'dhcp4_options' table. - // Using fixed scope_id = 3, which associates an option with host. - {7, - { OID_INT2, OID_BYTEA, OID_TEXT, - OID_VARCHAR, OID_BOOL, OID_TEXT, OID_INT8}, - "insert_v4_host_option", - "INSERT INTO dhcp4_options(code, value, formatted_value, space, " - " persistent, user_context, host_id, scope_id) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, 3)" - }, - - // PgSqlHostDataSourceImpl::INSERT_V6_HOST_OPTION - // Inserts a single DHCPv6 option into 'dhcp6_options' table. - // Using fixed scope_id = 3, which associates an option with host. - {7, - { OID_INT2, OID_BYTEA, OID_TEXT, - OID_VARCHAR, OID_BOOL, OID_TEXT, OID_INT8}, - "insert_v6_host_option", - "INSERT INTO dhcp6_options(code, value, formatted_value, space, " - " persistent, user_context, host_id, scope_id) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, 3)" - }, - - // PgSqlHostDataSourceImpl::DEL_HOST_ADDR4 - // Deletes a v4 host that matches (subnet-id, addr4) - {2, - { OID_INT8, OID_INT8 }, - "del_host_addr4", - "DELETE FROM hosts WHERE dhcp4_subnet_id = $1 AND ipv4_address = $2" - }, - - // PgSqlHostDataSourceImpl::DEL_HOST_SUBID4_ID - // Deletes a v4 host that matches (subnet4-id, identifier-type, identifier) - {3, - { OID_INT8, OID_INT2, OID_BYTEA }, - "del_host_subid4_id", - "DELETE FROM hosts WHERE dhcp4_subnet_id = $1 " - "AND dhcp_identifier_type = $2 " - "AND dhcp_identifier = $3" - }, - - // PgSqlHostDataSourceImpl::DEL_HOST_SUBID6_ID - // Deletes a v6 host that matches (subnet6-id, identifier-type, identifier) - {3, - { OID_INT8, OID_INT2, OID_BYTEA }, - "del_host_subid6_id", - "DELETE FROM hosts WHERE dhcp6_subnet_id = $1 " - "AND dhcp_identifier_type = $2 " - "AND dhcp_identifier = $3" - }, - // PgSqlHostDataSourceImpl::GET_HOST_SUBID4 // // Retrieves host information for all hosts in a subnet, along with the @@ -1795,6 +1719,84 @@ TaggedStatementArray tagged_statements = { { "LEFT JOIN dhcp6_options AS o ON h.host_id = o.host_id " "LEFT JOIN ipv6_reservations AS r ON h.host_id = r.host_id " "ORDER BY h.host_id, o.option_id, r.reservation_id" + }, + + // PgSqlHostDataSourceImpl::INSERT_HOST + // Inserts a host into the 'hosts' table. Returns the inserted host id. + {13, + { OID_BYTEA, OID_INT2, + OID_INT8, OID_INT8, OID_INT8, OID_VARCHAR, + OID_VARCHAR, OID_VARCHAR, OID_TEXT, + OID_INT8, OID_VARCHAR, OID_VARCHAR, OID_VARCHAR }, + "insert_host", + "INSERT INTO hosts(dhcp_identifier, dhcp_identifier_type, " + " dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, " + " dhcp4_client_classes, dhcp6_client_classes, user_context, " + " dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) " + "RETURNING host_id" + }, + + //PgSqlHostDataSourceImpl::INSERT_V6_RESRV + // Inserts a single IPv6 reservation into 'reservations' table. + {5, + { OID_VARCHAR, OID_INT2, OID_INT4, OID_INT4, OID_INT4 }, + "insert_v6_resrv", + "INSERT INTO ipv6_reservations(address, prefix_len, type, " + " dhcp6_iaid, host_id) " + "VALUES ($1, $2, $3, $4, $5)" + }, + + // PgSqlHostDataSourceImpl::INSERT_V4_HOST_OPTION + // Inserts a single DHCPv4 option into 'dhcp4_options' table. + // Using fixed scope_id = 3, which associates an option with host. + {7, + { OID_INT2, OID_BYTEA, OID_TEXT, + OID_VARCHAR, OID_BOOL, OID_TEXT, OID_INT8 }, + "insert_v4_host_option", + "INSERT INTO dhcp4_options(code, value, formatted_value, space, " + " persistent, user_context, host_id, scope_id) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, 3)" + }, + + // PgSqlHostDataSourceImpl::INSERT_V6_HOST_OPTION + // Inserts a single DHCPv6 option into 'dhcp6_options' table. + // Using fixed scope_id = 3, which associates an option with host. + {7, + { OID_INT2, OID_BYTEA, OID_TEXT, + OID_VARCHAR, OID_BOOL, OID_TEXT, OID_INT8 }, + "insert_v6_host_option", + "INSERT INTO dhcp6_options(code, value, formatted_value, space, " + " persistent, user_context, host_id, scope_id) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, 3)" + }, + + // PgSqlHostDataSourceImpl::DEL_HOST_ADDR4 + // Deletes a v4 host that matches (subnet-id, addr4) + {2, + { OID_INT8, OID_INT8 }, + "del_host_addr4", + "DELETE FROM hosts WHERE dhcp4_subnet_id = $1 AND ipv4_address = $2" + }, + + // PgSqlHostDataSourceImpl::DEL_HOST_SUBID4_ID + // Deletes a v4 host that matches (subnet4-id, identifier-type, identifier) + {3, + { OID_INT8, OID_INT2, OID_BYTEA }, + "del_host_subid4_id", + "DELETE FROM hosts WHERE dhcp4_subnet_id = $1 " + "AND dhcp_identifier_type = $2 " + "AND dhcp_identifier = $3" + }, + + // PgSqlHostDataSourceImpl::DEL_HOST_SUBID6_ID + // Deletes a v6 host that matches (subnet6-id, identifier-type, identifier) + {3, + { OID_INT8, OID_INT2, OID_BYTEA }, + "del_host_subid6_id", + "DELETE FROM hosts WHERE dhcp6_subnet_id = $1 " + "AND dhcp_identifier_type = $2 " + "AND dhcp_identifier = $3" } } }; @@ -1802,8 +1804,8 @@ TaggedStatementArray tagged_statements = { { } // namespace PgSqlHostDataSourceImpl:: -PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters) - : conn_(parameters), +PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters) : + conn_(parameters), is_readonly_(false) { // Open the database. diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 691f867ed8..d2136d6bd8 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1082,8 +1082,8 @@ protected: bool fetch_type_; }; -PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) - : LeaseMgr(), conn_(parameters) { +PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) : + conn_(parameters) { conn_.openDatabase(); // Validate schema version first. diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h index 5c1f3a89a2..cbebd70d87 100644 --- a/src/lib/dhcpsrv/srv_config.h +++ b/src/lib/dhcpsrv/srv_config.h @@ -615,6 +615,7 @@ public: uint32_t getServerMaxThreadQueueSize() const { return (server_max_thread_queue_size_); } + /// @brief Returns pointer to the D2 client configuration D2ClientConfigPtr getD2ClientConfig() { return (d2_client_config_); diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h index 3d9108b961..5f74abfd1f 100644 --- a/src/lib/mysql/mysql_connection.h +++ b/src/lib/mysql/mysql_connection.h @@ -144,7 +144,7 @@ public: /// @brief Prepared statements /// /// This field is public, because it is used heavily from MySqlConnection - /// and will be from MySqlHostDataSource. + /// and from MySqlHostDataSource. std::vector statements_; bool connected_; ///< Flag to indicate openDatabase has been called @@ -223,8 +223,8 @@ public: /// @brief Constructor /// /// Initialize MySqlConnection object with parameters needed for connection. - MySqlConnection(const ParameterMap& parameters) - : DatabaseConnection(parameters), connected_(false), prepared_(false) { + MySqlConnection(const ParameterMap& parameters) : + DatabaseConnection(parameters), connected_(false), prepared_(false) { } /// @brief Destructor @@ -378,7 +378,8 @@ public: int status = 0; if (!in_bind_vec.empty()) { // Bind parameters to the prepared statement. - status = mysql_stmt_bind_param(holderHandle.statements_[index], &in_bind_vec[0]); + status = mysql_stmt_bind_param(holderHandle.statements_[index], + &in_bind_vec[0]); checkError(status, index, "unable to bind parameters for select"); } @@ -453,7 +454,8 @@ public: } // Bind the parameters to the statement - int status = mysql_stmt_bind_param(holderHandle.statements_[index], &in_bind_vec[0]); + int status = mysql_stmt_bind_param(holderHandle.statements_[index], + &in_bind_vec[0]); checkError(status, index, "unable to bind parameters"); // Execute the statement @@ -493,7 +495,8 @@ public: } // Bind the parameters to the statement - int status = mysql_stmt_bind_param(holderHandle.statements_[index], &in_bind_vec[0]); + int status = mysql_stmt_bind_param(holderHandle.statements_[index], + &in_bind_vec[0]); checkError(status, index, "unable to bind parameters"); // Execute the statement diff --git a/src/lib/pgsql/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h index 0bf72549a4..03de8dbc3f 100644 --- a/src/lib/pgsql/pgsql_connection.h +++ b/src/lib/pgsql/pgsql_connection.h @@ -300,8 +300,8 @@ public: /// @brief Constructor /// /// Initialize PgSqlConnection object with parameters needed for connection. - PgSqlConnection(const ParameterMap& parameters) - : DatabaseConnection(parameters), connected_(false), prepared_(false) { + PgSqlConnection(const ParameterMap& parameters) : + DatabaseConnection(parameters), connected_(false), prepared_(false) { } /// @brief Destructor @@ -399,7 +399,7 @@ public: /// @brief Raw statements /// /// This field is public, because it is used heavily from PgSqlConnection - /// and will be from MySqlHostDataSource. + /// and from PgSqlHostDataSource. std::vector statements_; /// @brief PgSql connection handle diff --git a/src/lib/stats/stats_mgr.cc b/src/lib/stats/stats_mgr.cc index 41f2bcbca9..2b5c384919 100644 --- a/src/lib/stats/stats_mgr.cc +++ b/src/lib/stats/stats_mgr.cc @@ -25,8 +25,8 @@ StatsMgr& StatsMgr::instance() { return (stats_mgr); } -StatsMgr::StatsMgr() - :global_(new StatContext()) { +StatsMgr::StatsMgr() : + global_(new StatContext()) { mutex_.reset(new std::mutex()); } @@ -111,7 +111,6 @@ ObservationPtr StatsMgr::getObservation(const std::string& name, bool lock) cons /// @todo: Implement contexts. // Currently we keep everything in a global context. return (global_->get(name)); - } void StatsMgr::addObservation(const ObservationPtr& stat, bool lock) {