2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-02 23:35:23 +00:00

- A memory leak when using omapi has been fixed. [ISC-Bugs #17560]

This commit is contained in:
David Hankins
2008-03-18 18:28:14 +00:00
parent 507fe25f11
commit 4619c0a2fb
6 changed files with 98 additions and 44 deletions

View File

@@ -75,6 +75,8 @@ work on other platforms. Please report any problems and suggested fixes to
- Add DHCPv6 files in configure. - Add DHCPv6 files in configure.
- A memory leak when using omapi has been fixed.
Changes since 4.0.0 (new features) Changes since 4.0.0 (new features)
- Added DHCPv6 rapid commit support. - Added DHCPv6 rapid commit support.

View File

@@ -214,6 +214,8 @@ static void lpf_gen_filter_setup (info)
{ {
struct sock_fprog p; struct sock_fprog p;
memset(&p, 0, sizeof(p));
/* Set up the bpf filter program structure. This is defined in /* Set up the bpf filter program structure. This is defined in
bpf.c */ bpf.c */
p.len = dhcp_bpf_filter_len; p.len = dhcp_bpf_filter_len;

View File

@@ -498,6 +498,28 @@ isc_result_t omapi_disconnect (omapi_object_t *h,
/* If whatever created us registered a signal handler, send it /* If whatever created us registered a signal handler, send it
a disconnect signal. */ a disconnect signal. */
omapi_signal (h, "disconnect", h); omapi_signal (h, "disconnect", h);
/* Disconnect from protocol object, if any. */
if (h->inner != NULL) {
if (h->inner->outer != NULL) {
omapi_object_dereference(&h->inner->outer, MDL);
}
omapi_object_dereference(&h->inner, MDL);
}
/* XXX: the code to free buffers should be in the dereference
function, but there is no special-purpose function to
dereference connections, so these just get leaked */
/* Free any buffers */
if (c->inbufs != NULL) {
omapi_buffer_dereference(&c->inbufs, MDL);
}
c->in_bytes = 0;
if (c->outbufs != NULL) {
omapi_buffer_dereference(&c->outbufs, MDL);
}
c->out_bytes = 0;
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }

View File

@@ -162,6 +162,8 @@ isc_result_t omapi_register_io_object (omapi_object_t *h,
obj -> reader = reader; obj -> reader = reader;
obj -> writer = writer; obj -> writer = writer;
obj -> reaper = reaper; obj -> reaper = reaper;
omapi_io_dereference(&obj, MDL);
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }
@@ -273,7 +275,7 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo,
int count; int count;
int desc; int desc;
struct timeval now, to; struct timeval now, to;
omapi_io_object_t *io, *prev; omapi_io_object_t *io, *prev, *next;
omapi_waiter_object_t *waiter; omapi_waiter_object_t *waiter;
omapi_object_t *tmp = (omapi_object_t *)0; omapi_object_t *tmp = (omapi_object_t *)0;
@@ -483,44 +485,71 @@ isc_result_t omapi_one_dispatch (omapi_object_t *wo,
/* Now check for I/O handles that are no longer valid, /* Now check for I/O handles that are no longer valid,
and remove them from the list. */ and remove them from the list. */
prev = (omapi_io_object_t *)0; prev = NULL;
for (io = omapi_io_states.next; io; io = io -> next) { io = NULL;
if (io -> reaper) { if (omapi_io_states.next != NULL) {
if (!io -> inner || omapi_io_reference(&io, omapi_io_states.next, MDL);
((*(io -> reaper)) (io -> inner) != }
ISC_R_SUCCESS)) { while (io != NULL) {
omapi_io_object_t *tmp = if ((io->inner == NULL) ||
(omapi_io_object_t *)0; ((io->reaper != NULL) &&
/* Save a reference to the next ((io->reaper)(io->inner) != ISC_R_SUCCESS)))
pointer, if there is one. */ {
if (io -> next)
omapi_io_reference (&tmp, omapi_io_object_t *tmp = NULL;
io -> next, MDL); /* Save a reference to the next
if (prev) { pointer, if there is one. */
omapi_io_dereference (&prev -> next, if (io->next != NULL) {
MDL); omapi_io_reference(&tmp, io->next, MDL);
if (tmp) omapi_io_dereference(&io->next, MDL);
omapi_io_reference
(&prev -> next,
tmp, MDL);
} else {
omapi_io_dereference
(&omapi_io_states.next, MDL);
if (tmp)
omapi_io_reference
(&omapi_io_states.next,
tmp, MDL);
else
omapi_signal_in
((omapi_object_t *)
&omapi_io_states,
"ready");
}
if (tmp)
omapi_io_dereference (&tmp, MDL);
} }
if (prev != NULL) {
omapi_io_dereference(&prev->next, MDL);
if (tmp != NULL)
omapi_io_reference(&prev->next,
tmp, MDL);
} else {
omapi_io_dereference(&omapi_io_states.next,
MDL);
if (tmp != NULL)
omapi_io_reference
(&omapi_io_states.next,
tmp, MDL);
else
omapi_signal_in(
(omapi_object_t *)
&omapi_io_states,
"ready");
}
if (tmp != NULL)
omapi_io_dereference(&tmp, MDL);
} else {
if (prev != NULL) {
omapi_io_dereference(&prev, MDL);
}
omapi_io_reference(&prev, io, MDL);
} }
prev = io;
/*
* Equivalent to:
* io = io->next
* But using our reference counting voodoo.
*/
next = NULL;
if (io->next != NULL) {
omapi_io_reference(&next, io->next, MDL);
}
omapi_io_dereference(&io, MDL);
if (next != NULL) {
omapi_io_reference(&io, next, MDL);
omapi_io_dereference(&next, MDL);
}
}
if (prev != NULL) {
omapi_io_dereference(&prev, MDL);
} }
return ISC_R_SUCCESS; return ISC_R_SUCCESS;

View File

@@ -410,7 +410,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
dmalloc_dump_outstanding (); dmalloc_dump_outstanding ();
#endif #endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history (); dump_rc_history (h);
#endif #endif
for (m = omapi_registered_messages; m; m = m -> next) { for (m = omapi_registered_messages; m; m = m -> next) {
if (m -> protocol_object == p) { if (m -> protocol_object == p) {
@@ -418,6 +418,9 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
omapi_signal (m -> object, "disconnect"); omapi_signal (m -> object, "disconnect");
} }
} }
/* XXX */
return ISC_R_SUCCESS;
} }
/* Not a signal we recognize? */ /* Not a signal we recognize? */
@@ -492,7 +495,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
dmalloc_dump_outstanding (); dmalloc_dump_outstanding ();
#endif #endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history (); dump_rc_history (h);
#endif #endif
#if defined (DEBUG_MEMORY_LEAKAGE) #if defined (DEBUG_MEMORY_LEAKAGE)
} }
@@ -750,7 +753,7 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
dmalloc_dump_outstanding (); dmalloc_dump_outstanding ();
#endif #endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history (); dump_rc_history (h);
#endif #endif
#if defined (DEBUG_MEMORY_LEAKAGE) #if defined (DEBUG_MEMORY_LEAKAGE)
previous_outstanding = 0xDEADBEEF; previous_outstanding = 0xDEADBEEF;

View File

@@ -831,10 +831,6 @@ main(int argc, char **argv) {
dmalloc_outstanding = 0; dmalloc_outstanding = 0;
#endif #endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
dump_rc_history ();
#endif
omapi_set_int_value ((omapi_object_t *)dhcp_control_object, omapi_set_int_value ((omapi_object_t *)dhcp_control_object,
(omapi_object_t *)0, "state", server_running); (omapi_object_t *)0, "state", server_running);