]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Memory leak in the load_balance_mine() function is fixed. This would
authorDavid Hankins <dhankins@isc.org>
Tue, 7 Apr 2009 19:55:52 +0000 (19:55 +0000)
committerDavid Hankins <dhankins@isc.org>
Tue, 7 Apr 2009 19:55:52 +0000 (19:55 +0000)
  leak ~20-30 octets per DHCPDISCOVER packet while failover was in use
  and in normal state. [ISC-Bugs #19548]

- Various compilation fixes have been included for the memory related
  DEBUG #defines in includes/site.h.  [ISC-Bugs #19548]

RELNOTES
includes/dhcpd.h
includes/site.h
omapip/alloc.c
omapip/message.c
server/dhcp.c
server/failover.c
server/mdb.c

index f20a29c30d0d104799a9ff7a5ea043f643d43d6e..5760b126b6c983fd88f0b45d17869059f8324c60 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -99,6 +99,13 @@ work on other platforms. Please report any problems and suggested fixes to
   be removed at expiration or release time.  Thanks to a patch submitted by
   Christof Chen.
 
+- Memory leak in the load_balance_mine() function is fixed.  This would
+  leak ~20-30 octets per DHCPDISCOVER packet while failover was in use
+  and in normal state.
+
+- Various compilation fixes have been included for the memory related
+  DEBUG #defines in includes/site.h.
+
                        Changes since 4.1.0b1
 
 - A missing "else" in dhcrelay.c could have caused an interface not to
index 8a014bc51511986dcec2972b95468ebd4a05ab38..d020b5fcf9a68cefa7c584f1ef4724bb2c1a02a1 100644 (file)
@@ -1673,6 +1673,9 @@ extern enum dhcp_shutdown_state shutdown_state;
 isc_result_t dhcp_io_shutdown (omapi_object_t *, void *);
 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
                                     control_object_state_t newstate);
+#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+void relinquish_ackqueue(void);
+#endif
 
 /* conflex.c */
 isc_result_t new_parse PROTO ((struct parse **, int,
index 220e995972ed257e8c77812bf82b81443855cb0f..651a98c2c688615e73445db26457f4a6733e752c 100644 (file)
@@ -46,6 +46,7 @@
    noticing memory leaks quickly. */
 
 /* #define DEBUG_MEMORY_LEAKAGE */
+/* #define DEBUG_MEMORY_LEAKAGE_ON_EXIT */
 
 /* Define this if you want exhaustive (and very slow) checking of the
    malloc pool for corruption. */
index 4572633c9f7532cd0ab8c5846d860dd0fc014520..3a79d90aea15762c45aa8a9f296a2a03182c3253 100644 (file)
@@ -255,8 +255,9 @@ void dmalloc_dump_outstanding ()
 {
        static unsigned long dmalloc_cutoff_point;
        struct dmalloc_preamble *dp;
+#if defined(DEBUG_MALLOC_POOL)
        unsigned char *foo;
-       int i;
+#endif
 
        if (!dmalloc_cutoff_point)
                dmalloc_cutoff_point = dmalloc_cutoff_generation;
@@ -307,7 +308,7 @@ void dmalloc_dump_outstanding ()
                            if (rc_history [i].addr == dp + 1) {
                                inhistory = 1;
                                if (!noted) {
-                                   log_info ("  %s(%d): %d", dp -> file,
+                                   log_info ("  %s(%d): %ld", dp -> file,
                                              dp -> line, dp -> size);
                                    noted = 1;
                                }
@@ -320,7 +321,7 @@ void dmalloc_dump_outstanding ()
                        } while (count--);
                        if (!inhistory)
 #endif
-                               log_info ("  %s(%d): %d",
+                               log_info ("  %s(%d): %ld",
                                          dp -> file, dp -> line, dp -> size);
                }
 #endif
@@ -353,7 +354,7 @@ void dump_rc_history (void *addr)
                        i += RC_HISTORY_MAX;
        }
        rc_history_count = 0;
-               
+
        while (rc_history [i].file) {
                if (!addr || addr == rc_history [i].addr)
                        print_rc_hist_entry (i);
@@ -427,7 +428,6 @@ static int dmalloc_find_entry (struct dmalloc_preamble *dp,
                               int min, int max)
 {
        int middle;
-       int cmp;
 
        middle = (min + max) / 2;
        if (middle == min)
@@ -448,8 +448,7 @@ static int dmalloc_find_entry (struct dmalloc_preamble *dp,
 void omapi_print_dmalloc_usage_by_caller ()
 {
        struct dmalloc_preamble *dp;
-       unsigned char *foo;
-       int ccur, cmax, i, j;
+       int ccur, cmax, i;
        struct caller cp [1024];
 
        cmax = 1024;
@@ -494,7 +493,9 @@ void omapi_print_dmalloc_usage_by_caller ()
        for (i = 0; i < ccur; i++) {
                printf ("%d\t%s:%d\t%d\n", i,
                        cp [i].dp -> file, cp [i].dp -> line, cp [i].count);
+#if defined(DUMP_RC_HISTORY)
                dump_rc_history (cp [i].dp + 1);
+#endif
        }
 }
 #endif /* DEBUG_MEMORY_LEAKAGE || DEBUG_MALLOC_POOL */
index 5b16bca75f9892084770ec34f02e8e628b950ec5..add200064ad3ace87f1292b6b3b81828e9e99050 100644 (file)
@@ -364,7 +364,7 @@ omapi_message_process_internal (omapi_object_t *, omapi_object_t *);
 isc_result_t omapi_message_process (omapi_object_t *mo, omapi_object_t *po)
 {
        isc_result_t status;
-#if defined (DEBUG_MEMORY_LEAKAGE)
+#if defined (DEBUG_MEMORY_LEAKAGE) && 0
        unsigned long previous_outstanding = dmalloc_outstanding;
 #endif
 
index ec1c2ef19d018c94e05b5ca3b100b47c3200a222..39edf24b5667d50a965eab52251304df27f365c8 100644 (file)
@@ -2955,7 +2955,7 @@ relinquish_ackqueue(void)
 {
        struct leasequeue *q, *n;
        
-       for (q = ackqueue ; q ; q = n) {
+       for (q = ackqueue_head ; q ; q = n) {
                n = q->next;
                dfree(q, MDL);
        }
index 5e1f3dff096b83f252ae5f0d9b51c558444bfffe..3f4b2fb6b7be5b98373fbbb80b005b45e75aae52 100644 (file)
@@ -5729,6 +5729,8 @@ int load_balance_mine (struct packet *packet, dhcp_failover_state_t *state)
                                   packet -> options, (struct option_state *)0,
                                   &global_scope, oc, MDL)) {
                hbaix = loadb_p_hash (ds.data, ds.len);
+
+               data_string_forget(&ds, MDL);
        } else {
                hbaix = loadb_p_hash (packet -> raw -> chaddr,
                                      packet -> raw -> hlen);
index 004e94ad3dc036fe0578df3e1e7ea2ab2645c3c7..2f04aa3c4103df4955126630c902f352ae9b4a8f 100644 (file)
@@ -714,7 +714,9 @@ void new_address_range (cfile, low, high, subnet, pool, lpchain)
        struct pool *pool;
        struct lease **lpchain;
 {
+#if defined(COMPACT_LEASES)
        struct lease *address_range;
+#endif
        unsigned min, max, i;
        char lowbuf [16], highbuf [16], netbuf [16];
        struct shared_network *share = subnet -> shared_network;
@@ -2614,7 +2616,7 @@ extern int end;
 extern struct lease *lease_hunks;
 #endif
 
-void free_everything ()
+void free_everything(void)
 {
        struct subnet *sc = (struct subnet *)0, *sn = (struct subnet *)0;
        struct shared_network *nc = (struct shared_network *)0,
@@ -2625,12 +2627,8 @@ void free_everything ()
                *in = (struct interface_info *)0;
        struct class *cc = (struct class *)0, *cn = (struct class *)0;
        struct collection *lp;
-       void *st = (shared_networks
-                   ? (shared_networks -> next
-                      ? shared_networks -> next -> next : 0) : 0);
        int i;
 
-
        /* Get rid of all the hash tables. */
        if (host_hw_addr_hash)
                host_free_hash_table (&host_hw_addr_hash, MDL);
@@ -2639,13 +2637,13 @@ void free_everything ()
                host_free_hash_table (&host_uid_hash, MDL);
        host_uid_hash = 0;
        if (lease_uid_hash)
-               lease_free_hash_table (&lease_uid_hash, MDL);
+               lease_id_free_hash_table (&lease_uid_hash, MDL);
        lease_uid_hash = 0;
        if (lease_ip_addr_hash)
-               lease_free_hash_table (&lease_ip_addr_hash, MDL);
+               lease_ip_free_hash_table (&lease_ip_addr_hash, MDL);
        lease_ip_addr_hash = 0;
        if (lease_hw_addr_hash)
-               lease_free_hash_table (&lease_hw_addr_hash, MDL);
+               lease_id_free_hash_table (&lease_hw_addr_hash, MDL);
        lease_hw_addr_hash = 0;
        if (host_name_hash)
                host_free_hash_table (&host_name_hash, MDL);
@@ -2751,7 +2749,15 @@ void free_everything ()
        }
 
        /* So are shared networks. */
+       /* XXX: this doesn't work presently, but i'm ok just filtering
+        * it out of the noise (you get a bigger spike on the real leaks).
+        * It would be good to fix this, but it is not a "real bug," so not
+        * today.  This hack is incomplete, it doesn't trim out sub-values.
+        */
        if (shared_networks) {
+               shared_network_dereference (&shared_networks, MDL);
+       /* This is the old method (tries to free memory twice, broken) */
+       } else if (0) {
            shared_network_reference (&nn, shared_networks, MDL);
            do {
                if (nn) {
@@ -2848,14 +2854,21 @@ void free_everything ()
 
        universe_free_hash_table (&universe_hash, MDL);
        for (i = 0; i < universe_count; i++) {
+#if 0
                union {
                        const char *c;
                        char *s;
                } foo;
+#endif
                if (universes [i]) {
-                       if (universes [i] -> hash)
-                           option_free_hash_table (&universes [i] -> hash,
-                                                   MDL);
+                       if (universes[i]->name_hash)
+                           option_name_free_hash_table(
+                                               &universes[i]->name_hash,
+                                               MDL);
+                       if (universes[i]->code_hash)
+                           option_code_free_hash_table(
+                                               &universes[i]->code_hash,
+                                               MDL);
 #if 0
                        if (universes [i] -> name > (char *)&end) {
                                foo.c = universes [i] -> name;
@@ -2874,7 +2887,9 @@ void free_everything ()
        relinquish_free_binding_values ();
        relinquish_free_option_caches ();
        relinquish_free_packets ();
+#if defined(COMPACT_LEASES)
        relinquish_lease_hunks ();
+#endif
        relinquish_hash_bucket_hunks ();
        omapi_type_relinquish ();
 }