mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 22:35:25 +00:00
- Move malloc debug information out of option_state_dereferencers.
- Dump reference count history after handling packet if DEBUG_RC_HISTORY is defined. - Use one macro to compute hash indices.
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: options.c,v 1.53 2000/01/26 17:22:26 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: options.c,v 1.54 2000/01/27 22:16:08 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#define DHCP_OPTION_DATA
|
#define DHCP_OPTION_DATA
|
||||||
@@ -884,7 +884,7 @@ struct option_cache *lookup_hashed_option (universe, options, code)
|
|||||||
|
|
||||||
hash = options -> universes [universe -> index];
|
hash = options -> universes [universe -> index];
|
||||||
|
|
||||||
hashix = ((code & 31) + ((code >> 5) & 31)) % 17;
|
hashix = compute_option_hash (code);
|
||||||
for (bptr = hash [hashix]; bptr; bptr = bptr -> cdr) {
|
for (bptr = hash [hashix]; bptr; bptr = bptr -> cdr) {
|
||||||
if (((struct option_cache *)(bptr -> car)) -> option -> code ==
|
if (((struct option_cache *)(bptr -> car)) -> option -> code ==
|
||||||
code)
|
code)
|
||||||
@@ -915,8 +915,7 @@ void save_hashed_option (universe, options, oc)
|
|||||||
pair *hash = options -> universes [universe -> index];
|
pair *hash = options -> universes [universe -> index];
|
||||||
|
|
||||||
/* Compute the hash. */
|
/* Compute the hash. */
|
||||||
hashix = ((oc -> option -> code & 31) +
|
hashix = compute_option_hash (oc -> option -> code);
|
||||||
((oc -> option -> code >> 5) & 31)) % 17;
|
|
||||||
|
|
||||||
/* If there's no hash table, make one. */
|
/* If there's no hash table, make one. */
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
@@ -987,8 +986,7 @@ void delete_hashed_option (universe, options, code)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Try to find an existing option matching the new one. */
|
/* Try to find an existing option matching the new one. */
|
||||||
hashix = ((code & 31) +
|
hashix = compute_option_hash (code);
|
||||||
((code >> 5) & 31)) % 17;
|
|
||||||
for (bptr = hash [hashix]; bptr; bptr = bptr -> cdr) {
|
for (bptr = hash [hashix]; bptr; bptr = bptr -> cdr) {
|
||||||
if (((struct option_cache *)(bptr -> car)) -> option -> code
|
if (((struct option_cache *)(bptr -> car)) -> option -> code
|
||||||
== code)
|
== code)
|
||||||
@@ -1053,9 +1051,11 @@ int option_cache_dereference (ptr, file, line)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hashed_option_state_dereference (universe, state)
|
int hashed_option_state_dereference (universe, state, file, line)
|
||||||
struct universe *universe;
|
struct universe *universe;
|
||||||
struct option_state *state;
|
struct option_state *state;
|
||||||
|
const char *file;
|
||||||
|
int line;
|
||||||
{
|
{
|
||||||
pair *heads;
|
pair *heads;
|
||||||
pair cp, next;
|
pair cp, next;
|
||||||
@@ -1072,19 +1072,21 @@ int hashed_option_state_dereference (universe, state)
|
|||||||
for (cp = heads [i]; cp; cp = next) {
|
for (cp = heads [i]; cp; cp = next) {
|
||||||
next = cp -> cdr;
|
next = cp -> cdr;
|
||||||
option_cache_dereference
|
option_cache_dereference
|
||||||
((struct option_cache **)&cp -> car, MDL);
|
((struct option_cache **)&cp -> car, file, line);
|
||||||
free_pair (cp, MDL);
|
free_pair (cp, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dfree (heads, MDL);
|
dfree (heads, file, line);
|
||||||
state -> universes [universe -> index] = (void *)0;
|
state -> universes [universe -> index] = (void *)0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int agent_option_state_dereference (universe, state)
|
int agent_option_state_dereference (universe, state, file, line)
|
||||||
struct universe *universe;
|
struct universe *universe;
|
||||||
struct option_state *state;
|
struct option_state *state;
|
||||||
|
const char *file;
|
||||||
|
int line;
|
||||||
{
|
{
|
||||||
struct agent_options *a, *na;
|
struct agent_options *a, *na;
|
||||||
struct option_tag *ot, *not;
|
struct option_tag *ot, *not;
|
||||||
@@ -1099,11 +1101,11 @@ int agent_option_state_dereference (universe, state)
|
|||||||
na = a -> next;
|
na = a -> next;
|
||||||
for (ot = a -> first; ot; ot = not) {
|
for (ot = a -> first; ot; ot = not) {
|
||||||
not = ot -> next;
|
not = ot -> next;
|
||||||
dfree (ot, MDL);
|
dfree (ot, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dfree (state -> universes [universe -> index], MDL);
|
dfree (state -> universes [universe -> index], file, line);
|
||||||
state -> universes [universe -> index] = (void *)0;
|
state -> universes [universe -> index] = (void *)0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1364,5 +1366,8 @@ void do_packet (interface, packet, len, from_port, from, hfrom)
|
|||||||
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)
|
#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)
|
||||||
dmalloc_dump_outstanding ();
|
dmalloc_dump_outstanding ();
|
||||||
#endif
|
#endif
|
||||||
|
#if defined (DEBUG_RC_HISTORY)
|
||||||
|
dump_rc_history ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user