]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1040] address review
authorRazvan Becheriu <razvan@isc.org>
Thu, 23 Jan 2020 21:23:51 +0000 (23:23 +0200)
committerRazvan Becheriu <razvan@isc.org>
Fri, 24 Jan 2020 12:27:09 +0000 (12:27 +0000)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc

index 74f1f01952c16b127785e0f453d560d20f348fd7..01773340e82e336783e081e4d5e9cf62c133898b 100644 (file)
@@ -3039,6 +3039,10 @@ Dhcpv4Srv::declineLease(const Lease4Ptr& lease, const Pkt4Ptr& decline,
         }
     }
 
+    // Remove existing DNS entries for the lease, if any.
+    // queueNCR will do the necessary checks and will skip the update, if not needed.
+    queueNCR(CHG_REMOVE, lease);
+
     // @todo: Call hooks.
 
     // We need to disassociate the lease from the client. Once we move a lease
@@ -3048,10 +3052,6 @@ Dhcpv4Srv::declineLease(const Lease4Ptr& lease, const Pkt4Ptr& decline,
 
     LeaseMgrFactory::instance().updateLease4(lease);
 
-    // Remove existing DNS entries for the lease, if any.
-    // queueNCR will do the necessary checks and will skip the update, if not needed.
-    queueNCR(CHG_REMOVE, lease);
-
     // Bump up the statistics.
 
     // Per subnet declined addresses counter.
index 68586a7ebdfb9291ebc44fd125c79b1191169f96..9bcd7d296797f860aebf73d6334920cdaeffab28 100644 (file)
@@ -3395,6 +3395,11 @@ Dhcpv6Srv::declineLease(const Pkt6Ptr& decline, const Lease6Ptr lease,
         }
     }
 
+    // Check if a lease has flags indicating that the FQDN update has
+    // been performed. If so, create NameChangeRequest which removes
+    // the entries. This method does all necessary checks.
+    queueNCR(CHG_REMOVE, lease);
+
     // @todo: Call hooks.
 
     // We need to disassociate the lease from the client. Once we move a lease
@@ -3404,11 +3409,6 @@ Dhcpv6Srv::declineLease(const Pkt6Ptr& decline, const Lease6Ptr lease,
 
     LeaseMgrFactory::instance().updateLease6(lease);
 
-    // Check if a lease has flags indicating that the FQDN update has
-    // been performed. If so, create NameChangeRequest which removes
-    // the entries. This method does all necessary checks.
-    queueNCR(CHG_REMOVE, lease);
-
     // Bump up the subnet-specific statistic.
     StatsMgr::instance().addValue(
         StatsMgr::generateName("subnet", lease->subnet_id_, "declined-addresses"),
index 8f49fa6c81343bb0b1f77b1fd975baebc8bcbc1e..f0514aebf3b74aa7d70903850068ac6f27aa179d 100644 (file)
@@ -1474,9 +1474,7 @@ AllocEngine::removeNonmatchingReservedLeases6(ClientContext6& ctx,
 
         // Remove this lease from LeaseMgr as it is reserved to someone
         // else or doesn't belong to a pool.
-        bool success = LeaseMgrFactory::instance().deleteLease(candidate);
-
-        if (!success) {
+        if (!LeaseMgrFactory::instance().deleteLease(candidate)) {
             continue;
         }
 
@@ -1521,9 +1519,7 @@ AllocEngine::removeNonmatchingReservedNoHostLeases6(ClientContext6& ctx,
         }
 
         // Remove this lease from LeaseMgr as it doesn't belong to a pool.
-        bool success = LeaseMgrFactory::instance().deleteLease(candidate);
-
-        if (!success) {
+        if (!LeaseMgrFactory::instance().deleteLease(candidate)) {
             continue;
         }
 
@@ -1592,9 +1588,7 @@ AllocEngine::removeNonreservedLeases6(ClientContext6& ctx,
         // simply remove it from the list.
         // We have reservations, but not for this lease. Release it.
         // Remove this lease from LeaseMgr
-        bool success = LeaseMgrFactory::instance().deleteLease(*lease);
-
-        if (!success) {
+        if (!LeaseMgrFactory::instance().deleteLease(*lease)) {
             continue;
         }
 
@@ -1996,9 +1990,7 @@ AllocEngine::extendLease6(ClientContext6& ctx, Lease6Ptr lease) {
         // Oh dear, the lease is no longer valid. We need to get rid of it.
 
         // Remove this lease from LeaseMgr
-        bool success = LeaseMgrFactory::instance().deleteLease(lease);
-
-        if (!success) {
+        if (!LeaseMgrFactory::instance().deleteLease(lease)) {
             return;
         }
 
@@ -3539,9 +3531,7 @@ AllocEngine::requestLease4(AllocEngine::ClientContext4& ctx) {
             .arg(ctx.query_->getLabel())
             .arg(client_lease->addr_.toText());
 
-        bool success = lease_mgr.deleteLease(client_lease);
-
-        if (success) {
+        if (lease_mgr.deleteLease(client_lease)) {
             // Need to decrease statistic for assigned addresses.
             StatsMgr::instance().addValue(
                 StatsMgr::generateName("subnet", client_lease->subnet_id_,
index 2b1a8227d63091bb0939d19db491eb3a6e5a1cb7..f582f8a2db749d3feef43208282a33ef7aaa9c40 100644 (file)
@@ -2836,9 +2836,7 @@ MySqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind) {
 
     // See how many rows were affected.  Note that the statement may delete
     // multiple rows.
-    int affected_rows = mysql_stmt_affected_rows(ctx->conn_.statements_[stindex]);
-
-    return (static_cast<uint64_t>(affected_rows));
+    return (static_cast<uint64_t>(mysql_stmt_affected_rows(ctx->conn_.statements_[stindex])));
 }
 
 bool