]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4555] Better code
authorFrancis Dupont <fdupont@isc.org>
Thu, 9 Jul 2026 10:09:40 +0000 (12:09 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 27 Jul 2026 15:00:43 +0000 (17:00 +0200)
src/bin/dhcp4/dhcp4_srv.cc

index a6c48822c559ee6fe4157d324ab2525095f5ab52..9a8dc35a7459ca926511a2f10b6ac39a80dcfd8e 100644 (file)
@@ -4535,11 +4535,19 @@ Dhcpv4Srv::serverDecline(hooks::CalloutHandlePtr& callout_handle, Pkt4Ptr& query
             }
         }
 
-        if (!lease_exists && !LeaseMgrFactory::instance().addLease(lease)) {
-            LOG_ERROR(lease4_logger, DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED)
-                .arg(query->getLabel())
-                .arg(lease->addr_.toText());
-            return;
+        if (!lease_exists) {
+            bool done;
+            try {
+                done = LeaseMgrFactory::instance().addLease(lease);
+            } catch (const Exception& ex) {
+                done = false;
+            }
+            if (!done) {
+                LOG_ERROR(lease4_logger, DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED)
+                    .arg(query->getLabel())
+                    .arg(lease->addr_.toText());
+                return;
+            }
         }
     }