Browse Source

[2697] Lease4::operator== is now safe to use for leases without client-id

Tomek Mrugalski 12 years ago
parent
commit
1d6a2e3fb2
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/lib/dhcpsrv/lease_mgr.cc

+ 12 - 1
src/lib/dhcpsrv/lease_mgr.cc

@@ -113,11 +113,22 @@ Lease4::toText() const {
 
 bool
 Lease4::operator==(const Lease4& other) const {
+    if ( (client_id_ && !other.client_id_) ||
+         (!client_id_ && other.client_id_) ) {
+        // One lease has client-id, but the other doesn't
+        return false;
+    }
+
+    if (client_id_ && other.client_id_ &&
+        *client_id_ != *other.client_id_) {
+        // Different client-ids
+        return false;
+    }
+
     return (
         addr_ == other.addr_ &&
         ext_ == other.ext_ &&
         hwaddr_ == other.hwaddr_ &&
-        *client_id_ == *other.client_id_ &&
         t1_ == other.t1_ &&
         t2_ == other.t2_ &&
         valid_lft_ == other.valid_lft_ &&