]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#884,!567] use thread_local when creating exchanges
authorRazvan Becheriu <razvan@isc.org>
Wed, 6 Nov 2019 15:47:45 +0000 (17:47 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 6 Nov 2019 17:28:24 +0000 (19:28 +0200)
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc

index f537a7b31e3ec7c2fe224236eadab010d8a3bc23..fc87fe5ab17707d58f26b42575687c287f779d33 100644 (file)
@@ -2634,7 +2634,7 @@ MySqlHostDataSourceImpl::delStatement(StatementIndex stindex,
 void
 MySqlHostDataSourceImpl::addResv(const IPv6Resrv& resv,
                                  const HostID& id) {
-    std::shared_ptr<MySqlIPv6ReservationExchange> host_ipv6_reservation_exchange(
+    thread_local std::shared_ptr<MySqlIPv6ReservationExchange> host_ipv6_reservation_exchange(
         std::make_shared<MySqlIPv6ReservationExchange>());
 
     std::vector<MYSQL_BIND> bind =
@@ -2649,7 +2649,7 @@ MySqlHostDataSourceImpl::addOption(const StatementIndex& stindex,
                                    const std::string& opt_space,
                                    const Optional<SubnetID>& subnet_id,
                                    const HostID& id) {
-    std::shared_ptr<MySqlOptionExchange> host_option_exchange(
+    thread_local std::shared_ptr<MySqlOptionExchange> host_option_exchange(
         std::make_shared<MySqlOptionExchange>());
 
     std::vector<MYSQL_BIND> bind =
@@ -2820,7 +2820,7 @@ MySqlHostDataSource::add(const HostPtr& host) {
     // If operating in read-only mode, throw exception.
     impl_->checkReadOnly();
 
-    std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostIPv6Exchange> host_ipv46_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv46_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostIPv6Exchange> host_ipv46_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv46_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostWithOptionsExchange> host_ipv4_exchange(
+    thread_local std::shared_ptr<MySqlHostWithOptionsExchange> host_ipv4_exchange(
         std::make_shared<MySqlHostWithOptionsExchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(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<MySqlHostIPv6Exchange> host_ipv6_exchange(
+    thread_local std::shared_ptr<MySqlHostIPv6Exchange> host_ipv6_exchange(
         std::make_shared<MySqlHostIPv6Exchange>(MySqlHostWithOptionsExchange::DHCP6_ONLY));
 
     // Set up the WHERE clause value
index 30c8233dde795d79b02b61c33d4ffe8f7760e138..102bc739814102dca07058977db31963a5cb43d6 100644 (file)
@@ -1759,7 +1759,7 @@ MySqlLeaseMgr::addLeaseCommon(StatementIndex stindex,
 
 bool
 MySqlLeaseMgr::addLease(const Lease4Ptr& lease) {
-    std::shared_ptr<MySqlLease4Exchange> exchange4(
+    thread_local std::shared_ptr<MySqlLease4Exchange> exchange4(
         std::make_shared<MySqlLease4Exchange>());
 
     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<MySqlLease6Exchange> exchange6(
+    thread_local std::shared_ptr<MySqlLease6Exchange> exchange6(
         std::make_shared<MySqlLease6Exchange>());
 
     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<MySqlLease4Exchange> exchange4(
+    thread_local std::shared_ptr<MySqlLease4Exchange> exchange4(
         std::make_shared<MySqlLease4Exchange>());
     getLeaseCollection(stindex, bind, exchange4, result);
 }
 
 void MySqlLeaseMgr::getLeaseCollection(StatementIndex stindex, MYSQL_BIND* bind,
                                        Lease6Collection& result) const {
-    std::shared_ptr<MySqlLease6Exchange> exchange6(
+    thread_local std::shared_ptr<MySqlLease6Exchange> exchange6(
         std::make_shared<MySqlLease6Exchange>());
     getLeaseCollection(stindex, bind, exchange6, result);
 }
 
 void MySqlLeaseMgr::getLease(StatementIndex stindex, MYSQL_BIND* bind,
                              Lease4Ptr& result) const {
-    std::shared_ptr<MySqlLease4Exchange> exchange4(
+    thread_local std::shared_ptr<MySqlLease4Exchange> exchange4(
         std::make_shared<MySqlLease4Exchange>());
 
     // 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<MySqlLease6Exchange> exchange6(
+    thread_local std::shared_ptr<MySqlLease6Exchange> exchange6(
         std::make_shared<MySqlLease6Exchange>());
 
     // 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<MySqlLease4Exchange> exchange4(
+    thread_local std::shared_ptr<MySqlLease4Exchange> exchange4(
         std::make_shared<MySqlLease4Exchange>());
 
     const StatementIndex stindex = UPDATE_LEASE4;
@@ -2567,7 +2567,7 @@ MySqlLeaseMgr::updateLease4(const Lease4Ptr& lease) {
 
 void
 MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
-    std::shared_ptr<MySqlLease6Exchange> exchange6(
+    thread_local std::shared_ptr<MySqlLease6Exchange> exchange6(
         std::make_shared<MySqlLease6Exchange>());
 
     const StatementIndex stindex = UPDATE_LEASE6;