From: Thomas Markwalder Date: Mon, 14 Mar 2016 19:07:35 +0000 (-0400) Subject: [4309] Fixed Coverity issue 1341466e in alloc_engine.cc X-Git-Tag: trac4248_base~10^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d981c5ce848db57bd6a3d96bb1cc9e93100e5031;p=thirdparty%2Fkea.git [4309] Fixed Coverity issue 1341466e in alloc_engine.cc 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. --- diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 8d409e6ada..41dc5169f5 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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(lease, remove_tmp, + reclaimLeaseInDatabase(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(lease, remove_tmp, + reclaimLeaseInDatabase(lease, remove_lease, boost::bind(&LeaseMgr::updateLease4, &lease_mgr, _1)); }