]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Emit log messages when the server is stable
authorShawn Routhier <sar@isc.org>
Fri, 8 Nov 2013 20:29:20 +0000 (12:29 -0800)
committerShawn Routhier <sar@isc.org>
Fri, 8 Nov 2013 20:29:20 +0000 (12:29 -0800)
Emit a log message when the server had completed initialization
and is about to start dispatching.  And emit log messages when
both peers in a failover pair have reached the normal state.

RELNOTES
server/dhcpd.c
server/failover.c
server/mdb.c
server/mdb6.c

index 48097249a58b590ca87888f8ae0ac7b06f79a380..18ffd448b6ed9fdbdd3588d568db42c00183ff9f 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -96,6 +96,15 @@ work on other platforms. Please report any problems and suggested fixes to
   to a client and before the server stops.  Using this option is
   not recommended.
 
+- Add some logging statements to indicate when the server is ready
+  to serve.  One statement is emitted after the server has finished
+  reading its files and is about to enter the dispatch loop.
+  This is "Server starting service.".
+  The second is emitted when a server determines that both it and
+  its failover peer are in the normal state.
+  This is "failover peer <name>: Both servers normal."
+  [ISC-Bugs 33208]
+
                        Changes since 4.2.5
 
 - Address static analysis warnings.
index 3588349febafd4dfdd7c323697e414597af1f4ae..457b3cc099e0a4fa9a48559264694a05b6dc5767 100644 (file)
@@ -785,6 +785,9 @@ main(int argc, char **argv) {
        signal(SIGINT, dhcp_signal_handler);   /* control-c */
        signal(SIGTERM, dhcp_signal_handler);  /* kill */
 
+       /* Log that we are about to start working */
+       log_info("Server starting service.");
+
        /*
         * Receive packets and dispatch them...
         * dispatch() will return only when we are shutting down.
index 7a9ae9e226ce34736db855dea2d212b298a5a410..3dfe7b99cf851a262e859483b85771232b493915 100644 (file)
@@ -1793,6 +1793,10 @@ isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *state,
     log_info ("failover peer %s: I move from %s to %s",
              state -> name, dhcp_failover_state_name_print (saved_state),
              dhcp_failover_state_name_print (state -> me.state));
+
+    /* If both servers are now normal log it */
+    if ((state->me.state == normal) && (state->partner.state == normal))
+           log_info("failover peer %s: Both servers normal", state->name);
     
     /* If we were in startup and we just left it, cancel the timeout. */
     if (new_state != startup && saved_state == startup)
@@ -1986,6 +1990,10 @@ isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *state,
                  state -> name,
                  dhcp_failover_state_name_print (previous_state),
                  dhcp_failover_state_name_print (state -> partner.state));
+
+       /* If both servers are now normal log it */
+       if ((state->me.state == normal) && (state->partner.state == normal))
+               log_info("failover peer %s: Both servers normal", state->name);
     
        if (!write_failover_state (state) || !commit_leases ()) {
                /* This is bad, but it's not fatal.  Of course, if we
index 53bf34dcd2c55e86d80e3be7a89cee6055a4162b..ba2c3d326bb6a4b7190fc7ef29d2c3c8f9d63ba7 100644 (file)
@@ -2296,13 +2296,48 @@ void hw_hash_delete (lease)
                lease_dereference (&head, MDL);
 }
 
+/* Write v4 leases to permanent storage. */
+int write_leases4(void) {
+       struct lease *l;
+       struct shared_network *s;
+       struct pool *p;
+       struct lease **lptr[RESERVED_LEASES+1];
+       int num_written = 0, i;
+
+       /* Write all the leases. */
+       for (s = shared_networks; s; s = s->next) {
+           for (p = s->pools; p; p = p->next) {
+               lptr[FREE_LEASES] = &p->free;
+               lptr[ACTIVE_LEASES] = &p->active;
+               lptr[EXPIRED_LEASES] = &p->expired;
+               lptr[ABANDONED_LEASES] = &p->abandoned;
+               lptr[BACKUP_LEASES] = &p->backup;
+               lptr[RESERVED_LEASES] = &p->reserved;
+
+               for (i = FREE_LEASES; i <= RESERVED_LEASES; i++) {
+                   for (l = *(lptr[i]); l; l = l->next) {
+#if !defined (DEBUG_DUMP_ALL_LEASES)
+                       if (l->hardware_addr.hlen != 0 || l->uid_len != 0 ||
+                           l->tsfp != 0 || l->binding_state != FTS_FREE)
+#endif
+                       {
+                           if (write_lease(l) == 0)
+                                   return (0);
+                           num_written++;
+                       }
+                   }
+               }
+           }
+       }
+
+       log_info ("Wrote %d leases to leases file.", num_written);
+       return (1);
+}
+
 /* Write all interesting leases to permanent storage. */
 
 int write_leases ()
 {
-       struct lease *l;
-       struct shared_network *s;
-       struct pool *p;
        struct host_decl *hp;
        struct group_object *gp;
        struct hash_bucket *hb;
@@ -2310,7 +2345,6 @@ int write_leases ()
        struct collection *colp;
        int i;
        int num_written;
-       struct lease **lptr[RESERVED_LEASES+1];
 
        /* write all the dynamically-created class declarations. */
        if (collections->classes) {
@@ -2390,41 +2424,22 @@ int write_leases ()
                return 0;
 #endif
 
-       /* Write all the leases. */
-       num_written = 0;
-       for (s = shared_networks; s; s = s -> next) {
-           for (p = s -> pools; p; p = p -> next) {
-               lptr [FREE_LEASES] = &p -> free;
-               lptr [ACTIVE_LEASES] = &p -> active;
-               lptr [EXPIRED_LEASES] = &p -> expired;
-               lptr [ABANDONED_LEASES] = &p -> abandoned;
-               lptr [BACKUP_LEASES] = &p -> backup;
-               lptr [RESERVED_LEASES] = &p->reserved;
-
-               for (i = FREE_LEASES; i <= RESERVED_LEASES; i++) {
-                   for (l = *(lptr [i]); l; l = l -> next) {
-#if !defined (DEBUG_DUMP_ALL_LEASES)
-                       if (l->hardware_addr.hlen != 0 || l->uid_len != 0 ||
-                           l->tsfp != 0 || l->binding_state != FTS_FREE)
-#endif
-                       {
-                           if (!write_lease (l))
-                                   return 0;
-                           num_written++;
-                       }
-                   }
-               }
-           }
-       }
-       log_info ("Wrote %d leases to leases file.", num_written);
+       switch (local_family) {
+             case AF_INET:
+               if (write_leases4() == 0)
+                       return (0);
+               break;
 #ifdef DHCPv6
-       if (!write_leases6()) {
-               return 0;
-       }
+             case AF_INET6:
+               if (write_leases6() == 0)
+                       return (0);
+               break;
 #endif /* DHCPv6 */
-       if (!commit_leases ())
-               return 0;
-       return 1;
+       }
+
+       if (commit_leases() == 0)
+               return (0);
+       return (1);
 }
 
 /* In addition to placing this lease upon a lease queue depending on its
index 419e58e35b78a84536bff455b4313c9d8afaf623..58fec01caae6e7b44c12059b1faeff7b6811f353 100644 (file)
@@ -2166,20 +2166,25 @@ write_ia_leases(const void *name, unsigned len, void *value) {
  */
 int
 write_leases6(void) {
+       int nas, tas, pds;
+
        write_error = 0;
        write_server_duid();
-       ia_hash_foreach(ia_na_active, write_ia_leases);
+       nas = ia_hash_foreach(ia_na_active, write_ia_leases);
        if (write_error) {
                return 0;
        }
-       ia_hash_foreach(ia_ta_active, write_ia_leases);
+       tas = ia_hash_foreach(ia_ta_active, write_ia_leases);
        if (write_error) {
                return 0;
        }
-       ia_hash_foreach(ia_pd_active, write_ia_leases);
+       pds = ia_hash_foreach(ia_pd_active, write_ia_leases);
        if (write_error) {
                return 0;
        }
+
+       log_info("Wrote %d NA, %d TA, %d PD leases to lease file.",
+                nas, tas, pds);
        return 1;
 }
 #endif /* DHCPv6 */