packet: add cleanup routines support
Currently reassembly tables are not freed on shutdown. This makes memleak debugging more difficult due to noise. Support cleanup routines that can do smarter things. After this change, "init" routines are not called anymore when closing files. Further changes should split init routines to cleanup routines as needed. Change-Id: Ib0b2cef6dd9c16905259063ac2c2fdfb7e066be6 Reviewed-on: https://code.wireshark.org/review/9135 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
fdb85029fd
commit
d52837d10d
|
@ -1102,6 +1102,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
register_giop_user_module@Base 1.9.1
|
||||
register_heur_dissector_list@Base 1.9.1
|
||||
register_init_routine@Base 1.9.1
|
||||
register_cleanup_routine@Base 1.99.8
|
||||
register_postdissector@Base 1.9.1
|
||||
register_postseq_cleanup_routine@Base 1.9.1
|
||||
register_rtd_table@Base 1.99.8
|
||||
|
|
|
@ -193,11 +193,11 @@ set_actual_length(tvbuff_t *tvb, const guint specified_len)
|
|||
}
|
||||
}
|
||||
|
||||
/* Allow protocols to register "init" routines, which are called before
|
||||
we make a pass through a capture file and dissect all its packets
|
||||
(e.g., when we read in a new capture file, or run a "filter packets"
|
||||
or "colorize packets" pass over the current capture file). */
|
||||
/* List of routines that are called before we make a pass through a capture file
|
||||
* and dissect all its packets. See register_init_routine and
|
||||
* register_cleanup_routine in packet.h */
|
||||
static GSList *init_routines;
|
||||
static GSList *cleanup_routines;
|
||||
|
||||
void
|
||||
register_init_routine(void (*func)(void))
|
||||
|
@ -205,24 +205,22 @@ register_init_routine(void (*func)(void))
|
|||
init_routines = g_slist_prepend(init_routines, (gpointer)func);
|
||||
}
|
||||
|
||||
void
|
||||
register_cleanup_routine(void (*func)(void))
|
||||
{
|
||||
cleanup_routines = g_slist_prepend(cleanup_routines, (gpointer)func);
|
||||
}
|
||||
|
||||
typedef void (*void_func_t)(void);
|
||||
|
||||
/* Initialize all data structures used for dissection. */
|
||||
static void
|
||||
call_init_routine(gpointer routine, gpointer dummy _U_)
|
||||
call_routine(gpointer routine, gpointer dummy _U_)
|
||||
{
|
||||
void_func_t func = (void_func_t)routine;
|
||||
(*func)();
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX - for now, these are the same; the "init" routines free whatever
|
||||
* stuff is left over from any previous dissection, and then initialize
|
||||
* their tables.
|
||||
*
|
||||
* We should probably split that into "init" and "cleanup" routines, for
|
||||
* cleanliness' sake.
|
||||
*/
|
||||
void
|
||||
init_dissection(void)
|
||||
{
|
||||
|
@ -241,7 +239,7 @@ init_dissection(void)
|
|||
epan_circuit_init();
|
||||
|
||||
/* Initialize protocol-specific variables. */
|
||||
g_slist_foreach(init_routines, &call_init_routine, NULL);
|
||||
g_slist_foreach(init_routines, &call_routine, NULL);
|
||||
|
||||
/* Initialize the stream-handling tables */
|
||||
stream_init();
|
||||
|
@ -261,9 +259,8 @@ cleanup_dissection(void)
|
|||
/* Cleanup the table of circuits. */
|
||||
epan_circuit_cleanup();
|
||||
|
||||
/* TODO: Introduce cleanup_routines */
|
||||
/* Cleanup protocol-specific variables. */
|
||||
g_slist_foreach(init_routines, &call_init_routine, NULL);
|
||||
g_slist_foreach(cleanup_routines, &call_routine, NULL);
|
||||
|
||||
/* Cleanup the stream-handling tables */
|
||||
stream_cleanup();
|
||||
|
|
|
@ -563,12 +563,24 @@ extern void dissect_cleanup(void);
|
|||
*/
|
||||
WS_DLL_PUBLIC void set_actual_length(tvbuff_t *tvb, const guint specified_len);
|
||||
|
||||
/* Allow protocols to register "init" routines, which are called before
|
||||
we make a pass through a capture file and dissect all its packets
|
||||
(e.g., when we read in a new capture file, or run a "filter packets"
|
||||
or "colorize packets" pass over the current capture file). */
|
||||
/**
|
||||
* Allow protocols to register "init" routines, which are called before
|
||||
* we make a pass through a capture file and dissect all its packets
|
||||
* (e.g., when we read in a new capture file, or run a "filter packets"
|
||||
* or "colorize packets" pass over the current capture file or when the
|
||||
* preferences are changed).
|
||||
*/
|
||||
WS_DLL_PUBLIC void register_init_routine(void (*func)(void));
|
||||
|
||||
/**
|
||||
* Allows protocols to register "cleanup" routines which are called
|
||||
* after closing a capture file (or when preferences are changed, in
|
||||
* that case these routines are called before the init routines are
|
||||
* executed). It can be used to release resources that are allocated in
|
||||
* register_init_routine.
|
||||
*/
|
||||
WS_DLL_PUBLIC void register_cleanup_routine(void (*func)(void));
|
||||
|
||||
/* Initialize all data structures used for dissection. */
|
||||
void init_dissection(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue