Skip to content

Commit

Permalink
lib: Cleanup memory associated with modules on shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Aug 8, 2024
1 parent bc16c8c commit db986ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/libfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ void frr_fini(void)
/* frrmod_init -> nothing needed / hooks */
rcu_shutdown();

frrmod_terminate();

/* also log memstats to stderr when stderr goes to a file*/
if (debug_memstats_at_exit || !isatty(STDERR_FILENO))
have_leftovers = log_memstats(stderr, di->name);
Expand Down
12 changes: 12 additions & 0 deletions lib/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,15 @@ void frrmod_unload(struct frrmod_runtime *module)
{
}
#endif

void frrmod_terminate(void)
{
struct frrmod_runtime *rtinfo = frrmod_list;

while (rtinfo) {
XFREE(MTYPE_MODULE_LOADNAME, rtinfo->load_name);
XFREE(MTYPE_MODULE_LOADARGS, rtinfo->load_args);

rtinfo = rtinfo->next;
}
}
1 change: 1 addition & 0 deletions lib/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extern union _frrmod_runtime_u _frrmod_this_module;
extern struct frrmod_runtime *frrmod_list;

extern void frrmod_init(struct frrmod_runtime *modinfo);
extern void frrmod_terminate(void);
extern struct frrmod_runtime *frrmod_load(const char *spec, const char *dir,
void (*pFerrlog)(const void *,
const char *),
Expand Down

0 comments on commit db986ad

Please sign in to comment.