]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4309] Fixed Coverity issue 1341466e in alloc_engine.cc
authorThomas Markwalder <tmark@isc.org>
Mon, 14 Mar 2016 19:07:35 +0000 (15:07 -0400)
committerThomas Markwalder <tmark@isc.org>
Mon, 14 Mar 2016 19:07:35 +0000 (15:07 -0400)
src/lib/dhcpsrv/alloc_engine.cc
 - AllocEngine::reclaimExpiredLease(const Lease6Ptr& lease,
                                 const DbReclaimMode& reclaim_mode,
                                 const CalloutHandlePtr& callout_handle)

   Simplified logic for flagging a lease for removal.  Renamed "remove_tmp"
   to "remove_lease" for clarity.

 - AllocEngine::reclaimExpiredLease(const Lease4Ptr& lease,
                                 const DbReclaimMode& reclaim_mode,
                                 const CalloutHandlePtr& callout_handle)

   Simplified logic for flagging a lease for removal.  Renamed "remove_tmp"
   to "remove_lease" for clarity.

src/lib/dhcpsrv/alloc_engine.cc

index 8d409e6ada173bd11c119b561d14488dca2afbb2..41dc5169f5378cdc018c640b281faa902ccef24f 100644 (file)
@@ -1633,28 +1633,25 @@ AllocEngine::reclaimExpiredLease(const Lease6Ptr& lease,
         queueNCR(CHG_REMOVE, lease);
 
         // Let's check if the lease that just expired is in DECLINED state.
-        // If it is, we need to conduct couple extra steps and also force
-        // its removal.
-        bool remove_tmp = (reclaim_mode == DB_RECLAIM_REMOVE);
+        // If it is, we need to conduct couple extra steps.
+        bool remove_lease = (reclaim_mode == DB_RECLAIM_REMOVE);
         if (lease->state_ == Lease::STATE_DECLINED) {
-            // There's no point in keeping declined lease after its
-            // reclaimation. Declined lease doesn't have any client
-            // identifying information anymore.
-            if (reclaim_mode != DB_RECLAIM_LEAVE_UNCHANGED) {
-                remove_tmp = true;
-            }
-
             // Do extra steps required for declined lease reclaimation:
+            // - call the recover hook
             // - bump decline-related stats
             // - log separate message
-            remove_tmp = reclaimDeclined(lease);
+            // There's no point in keeping declined lease after its
+            // reclaimation. Declined lease doesn't have any client
+            // identifying information anymore.  So we'll flag it for
+            // removal unless the hook has set the skip flag.
+            remove_lease = reclaimDeclined(lease);
         }
 
         if (reclaim_mode != DB_RECLAIM_LEAVE_UNCHANGED) {
             // Reclaim the lease - depending on the configuration, set the
             // expired-reclaimed state or simply remove it.
             LeaseMgr& lease_mgr = LeaseMgrFactory::instance();
-            reclaimLeaseInDatabase<Lease6Ptr>(lease, remove_tmp,
+            reclaimLeaseInDatabase<Lease6Ptr>(lease, remove_lease,
                                               boost::bind(&LeaseMgr::updateLease6,
                                                           &lease_mgr, _1));
         }
@@ -1726,28 +1723,25 @@ AllocEngine::reclaimExpiredLease(const Lease4Ptr& lease,
         queueNCR(CHG_REMOVE, lease);
 
         // Let's check if the lease that just expired is in DECLINED state.
-        // If it is, we need to conduct couple extra steps and also force
-        // its removal.
-        bool remove_tmp = (reclaim_mode == DB_RECLAIM_REMOVE);
+        // If it is, we need to conduct couple extra steps.
+        bool remove_lease = (reclaim_mode == DB_RECLAIM_REMOVE);
         if (lease->state_ == Lease::STATE_DECLINED) {
-            // There's no point in keeping declined lease after its
-            // reclaimation. Declined lease doesn't have any client
-            // identifying information anymore.
-            if (reclaim_mode != DB_RECLAIM_LEAVE_UNCHANGED) {
-                remove_tmp = true;
-            }
-
             // Do extra steps required for declined lease reclaimation:
+            // - call the recover hook
             // - bump decline-related stats
             // - log separate message
-            remove_tmp = reclaimDeclined(lease);
+            // There's no point in keeping declined lease after its
+            // reclaimation. Declined lease doesn't have any client
+            // identifying information anymore.  So we'll flag it for
+            // removal unless the hook has set the skip flag.
+            remove_lease = reclaimDeclined(lease);
         }
 
         if (reclaim_mode != DB_RECLAIM_LEAVE_UNCHANGED) {
             // Reclaim the lease - depending on the configuration, set the
             // expired-reclaimed state or simply remove it.
             LeaseMgr& lease_mgr = LeaseMgrFactory::instance();
-            reclaimLeaseInDatabase<Lease4Ptr>(lease, remove_tmp,
+            reclaimLeaseInDatabase<Lease4Ptr>(lease, remove_lease,
                                               boost::bind(&LeaseMgr::updateLease4,
                                                           &lease_mgr, _1));
         }