From: Razvan Becheriu Date: Wed, 6 Nov 2019 15:47:45 +0000 (+0200) Subject: [#884,!567] use thread_local when creating exchanges X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fa3aab04bcaf2e4887d6779c072dcc6792f70c5;p=thirdparty%2Fkea.git [#884,!567] use thread_local when creating exchanges --- diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index f537a7b31e..fc87fe5ab1 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -2634,7 +2634,7 @@ MySqlHostDataSourceImpl::delStatement(StatementIndex stindex, void MySqlHostDataSourceImpl::addResv(const IPv6Resrv& resv, const HostID& id) { - std::shared_ptr host_ipv6_reservation_exchange( + thread_local std::shared_ptr host_ipv6_reservation_exchange( std::make_shared()); std::vector bind = @@ -2649,7 +2649,7 @@ MySqlHostDataSourceImpl::addOption(const StatementIndex& stindex, const std::string& opt_space, const Optional& subnet_id, const HostID& id) { - std::shared_ptr host_option_exchange( + thread_local std::shared_ptr host_option_exchange( std::make_shared()); std::vector bind = @@ -2820,7 +2820,7 @@ MySqlHostDataSource::add(const HostPtr& host) { // If operating in read-only mode, throw exception. impl_->checkReadOnly(); - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Initiate MySQL transaction as we will have to make multiple queries @@ -2976,7 +2976,7 @@ ConstHostCollection MySqlHostDataSource::getAll(const Host::IdentifierType& identifier_type, const uint8_t* identifier_begin, const size_t identifier_len) const { - std::shared_ptr host_ipv46_exchange( + thread_local std::shared_ptr host_ipv46_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_AND_DHCP6)); // Set up the WHERE clause value @@ -3006,7 +3006,7 @@ MySqlHostDataSource::getAll(const Host::IdentifierType& identifier_type, ConstHostCollection MySqlHostDataSource::getAll4(const SubnetID& subnet_id) const { - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Set up the WHERE clause value @@ -3025,7 +3025,7 @@ MySqlHostDataSource::getAll4(const SubnetID& subnet_id) const { ConstHostCollection MySqlHostDataSource::getAll6(const SubnetID& subnet_id) const { - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); // Set up the WHERE clause value @@ -3044,7 +3044,7 @@ MySqlHostDataSource::getAll6(const SubnetID& subnet_id) const { ConstHostCollection MySqlHostDataSource::getAllbyHostname(const std::string& hostname) const { - std::shared_ptr host_ipv46_exchange( + thread_local std::shared_ptr host_ipv46_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_AND_DHCP6)); // Set up the WHERE clause value @@ -3069,7 +3069,7 @@ MySqlHostDataSource::getAllbyHostname(const std::string& hostname) const { ConstHostCollection MySqlHostDataSource::getAllbyHostname4(const std::string& hostname, const SubnetID& subnet_id) const { - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Set up the WHERE clause value @@ -3100,7 +3100,7 @@ MySqlHostDataSource::getAllbyHostname4(const std::string& hostname, ConstHostCollection MySqlHostDataSource::getAllbyHostname6(const std::string& hostname, const SubnetID& subnet_id) const { - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); // Set up the WHERE clause value @@ -3133,7 +3133,7 @@ MySqlHostDataSource::getPage4(const SubnetID& subnet_id, size_t& /*source_index*/, uint64_t lower_host_id, const HostPageSize& page_size) const { - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Set up the WHERE clause value @@ -3169,7 +3169,7 @@ MySqlHostDataSource::getPage6(const SubnetID& subnet_id, size_t& /*source_index*/, uint64_t lower_host_id, const HostPageSize& page_size) const { - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); // Set up the WHERE clause value @@ -3202,7 +3202,7 @@ MySqlHostDataSource::getPage6(const SubnetID& subnet_id, ConstHostCollection MySqlHostDataSource::getAll4(const asiolink::IOAddress& address) const { - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Set up the WHERE clause value @@ -3226,7 +3226,7 @@ MySqlHostDataSource::get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type, const uint8_t* identifier_begin, const size_t identifier_len) const { - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); return (impl_->getHost(subnet_id, identifier_type, identifier_begin, @@ -3242,7 +3242,7 @@ MySqlHostDataSource::get4(const SubnetID& subnet_id, "wrong address type, address supplied is an IPv6 address"); } - std::shared_ptr host_ipv4_exchange( + thread_local std::shared_ptr host_ipv4_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP4_ONLY)); // Set up the WHERE clause value @@ -3276,7 +3276,7 @@ MySqlHostDataSource::get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type, const uint8_t* identifier_begin, const size_t identifier_len) const { - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); return (impl_->getHost(subnet_id, identifier_type, identifier_begin, @@ -3292,7 +3292,7 @@ MySqlHostDataSource::get6(const asiolink::IOAddress& prefix, "wrong address type, address supplied is an IPv4 address"); } - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); // Set up the WHERE clause value @@ -3334,7 +3334,7 @@ MySqlHostDataSource::get6(const SubnetID& subnet_id, "wrong address type, address supplied is an IPv4 address"); } - std::shared_ptr host_ipv6_exchange( + thread_local std::shared_ptr host_ipv6_exchange( std::make_shared(MySqlHostWithOptionsExchange::DHCP6_ONLY)); // Set up the WHERE clause value diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index 30c8233dde..102bc73981 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -1759,7 +1759,7 @@ MySqlLeaseMgr::addLeaseCommon(StatementIndex stindex, bool MySqlLeaseMgr::addLease(const Lease4Ptr& lease) { - std::shared_ptr exchange4( + thread_local std::shared_ptr exchange4( std::make_shared()); LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, @@ -1774,7 +1774,7 @@ MySqlLeaseMgr::addLease(const Lease4Ptr& lease) { bool MySqlLeaseMgr::addLease(const Lease6Ptr& lease) { - std::shared_ptr exchange6( + thread_local std::shared_ptr exchange6( std::make_shared()); LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, @@ -1879,21 +1879,21 @@ void MySqlLeaseMgr::getLeaseCollection(StatementIndex stindex, void MySqlLeaseMgr::getLeaseCollection(StatementIndex stindex, MYSQL_BIND* bind, Lease4Collection& result) const { - std::shared_ptr exchange4( + thread_local std::shared_ptr exchange4( std::make_shared()); getLeaseCollection(stindex, bind, exchange4, result); } void MySqlLeaseMgr::getLeaseCollection(StatementIndex stindex, MYSQL_BIND* bind, Lease6Collection& result) const { - std::shared_ptr exchange6( + thread_local std::shared_ptr exchange6( std::make_shared()); getLeaseCollection(stindex, bind, exchange6, result); } void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind, Lease4Ptr& result) const { - std::shared_ptr exchange4( + thread_local std::shared_ptr exchange4( std::make_shared()); // Create appropriate collection object and get all leases matching @@ -1914,7 +1914,7 @@ void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind, void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind, Lease6Ptr& result) const { - std::shared_ptr exchange6( + thread_local std::shared_ptr exchange6( std::make_shared()); // Create appropriate collection object and get all leases matching @@ -2540,7 +2540,7 @@ MySqlLeaseMgr::updateLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind, void MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) { - std::shared_ptr exchange4( + thread_local std::shared_ptr exchange4( std::make_shared()); const StatementIndex stindex = UPDATE_LEASE4; @@ -2567,7 +2567,7 @@ MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) { void MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) { - std::shared_ptr exchange6( + thread_local std::shared_ptr exchange6( std::make_shared()); const StatementIndex stindex = UPDATE_LEASE6;