]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
minor changes old-multi-threading-pkt-processing
authorRazvan Becheriu <razvan@isc.org>
Wed, 4 Sep 2019 15:35:34 +0000 (18:35 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 4 Sep 2019 15:35:34 +0000 (18:35 +0300)
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_host_data_source.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/srv_config.h
src/lib/mysql/mysql_connection.h
src/lib/pgsql/pgsql_connection.h
src/lib/stats/stats_mgr.cc

index 71e4c6defb6f3a4462d175bbce94af17dd9cfe6c..4e5ee8f264db42e701c155be960646c1586626d5 100644 (file)
@@ -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.
index 38e6fb8d971794d44dcd3ff65b0b75ab02d8c970..5b970ef7d489a955cbeaabe68a65d644a4e8d23b 100644 (file)
@@ -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();
index 1a51b345c8823ad18b96401497b0c33626c3c8b4..87ed690929138718d555e295e0a81e5204181f07 100644 (file)
@@ -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.
index 691f867ed82e693b643346aa3eb697ace3db69f1..d2136d6bd87b6a764bdaf6912e6935abf67e3d91 100644 (file)
@@ -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.
index 5c1f3a89a2dbb849b2d69b07abe1f42b7ae83bd8..cbebd70d87018c52c9fea3efd468ba194bfc3b35 100644 (file)
@@ -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_);
index 3d9108b961a7adc69719dac8cee52e82f1a2195b..5f74abfd1f625eb285dd15ae91095d07842c50db 100644 (file)
@@ -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<MYSQL_STMT*> 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
index 0bf72549a4906ca386426a4fb3b2fc5e7b7e47c9..03de8dbc3f8a0ba8a8465c82400508cd55a42338 100644 (file)
@@ -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<const PgSqlTaggedStatement*> statements_;
 
     /// @brief PgSql connection handle
index 41f2bcbca9a90401ba6319d310fa4c5ab15cb4c9..2b5c3849199c9bf098d8f488952c44e191f81c1f 100644 (file)
@@ -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) {