]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Clean up deleted vs. undeleted leases.
authorTed Lemon <source@isc.org>
Mon, 25 Oct 1999 01:55:40 +0000 (01:55 +0000)
committerTed Lemon <source@isc.org>
Mon, 25 Oct 1999 01:55:40 +0000 (01:55 +0000)
server/mdb.c

index 57bb07ef4c339214e1c7074f4277546dbe8e76d6..9ed3e0773a2e2de5e7a4b4538a12edb988023448 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: mdb.c,v 1.13 1999/10/24 23:27:52 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: mdb.c,v 1.14 1999/10/25 01:55:40 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -68,7 +68,7 @@ isc_result_t enter_host (hd, dynamicp, commit)
                        /* If the old entry wasn't dynamic, then we
                           always have to keep the deletion. */
                        if (!hp -> flags & HOST_DECL_DYNAMIC)
-                               hd -> flags &= ~HOST_DECL_DYNAMIC;
+                               hd -> flags |= HOST_DECL_STATIC;
                }
 
                /* If there isn't already a host decl matching this
@@ -292,7 +292,7 @@ isc_result_t delete_host (hd, commit)
                                     strlen (hd -> name));
                
                if (hp) {
-                       if (hp == hd && (hp -> flags & HOST_DECL_DYNAMIC)) {
+                       if (hp == hd && !(hp -> flags & HOST_DECL_STATIC)) {
                                delete_hash_entry (host_name_hash,
                                                   (unsigned char *)hd -> name,
                                                   strlen (hd -> name));
@@ -1385,20 +1385,31 @@ void write_leases ()
            }
        }
 
-       /* Write all the dynamically-created group declarations. */
+       /* Write all the deleted host declarations. */
        if (host_name_hash) {
            for (i = 0; i < host_name_hash -> hash_count; i++) {
                for (hb = host_name_hash -> buckets [i];
                     hb; hb = hb -> next) {
                        hp = (struct host_decl *)hb -> value;
-                       if ((hp -> flags & HOST_DECL_DYNAMIC) ||
-                           (!(hp -> flags & HOST_DECL_DYNAMIC) &&
+                       if (((hp -> flags & HOST_DECL_STATIC) &&
                             (hp -> flags & HOST_DECL_DELETED)))
                                write_host (hp);
                }
            }
        }
 
+       /* Write all the new, dynamic host declarations. */
+       if (host_name_hash) {
+           for (i = 0; i < host_name_hash -> hash_count; i++) {
+               for (hb = host_name_hash -> buckets [i];
+                    hb; hb = hb -> next) {
+                       hp = (struct host_decl *)hb -> value;
+                       if ((hp -> flags & HOST_DECL_DYNAMIC))
+                               write_host (hp);
+               }
+           }
+       }
+
        /* Write all the leases. */
        for (s = shared_networks; s; s = s -> next) {
                for (p = s -> pools; p; p = p -> next) {