From: Marcin Siodelski Date: Fri, 5 Oct 2018 15:02:05 +0000 (+0200) Subject: [#93,!35] Enclose subnet/network creation in transaction. X-Git-Tag: 5-netconf-extend-syntax_base~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f25ffc08fd76e266e24dbeac93cf211a33fadde;p=thirdparty%2Fkea.git [#93,!35] Enclose subnet/network creation in transaction. --- diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index 16d5561685..32cc96fa8d 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -361,6 +361,8 @@ public: MySqlBinding::createInteger(subnet->getValid()) }; + MySqlTransaction transaction(conn_); + // Check if the subnet already exists. Subnet4Ptr existing_subnet = getSubnet4(server_selector, subnet->getID()); @@ -385,6 +387,8 @@ public: for (auto pool : subnet->getPools(Lease::TYPE_V4)) { createPool4(boost::dynamic_pointer_cast(pool), subnet); } + + transaction.commit(); } /// @brief Inserts new IPv4 pool to the database. @@ -598,6 +602,8 @@ public: MySqlBinding::condCreateInteger(shared_network->getValid()) }; + MySqlTransaction transaction(conn_); + // Check if the shared network already exists. SharedNetwork4Ptr existing_network = getSharedNetwork4(server_selector, shared_network->getName()); @@ -614,6 +620,8 @@ public: conn_.insertQuery(MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4, in_bindings); } + + transaction.commit(); } /// @brief Sends query to the database to retrieve multiple option