diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2022-11-09 21:09:16 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2022-11-09 21:54:45 +0100 |
commit | 371eb49043d225d2bab8149187b813a14b4b86d2 (patch) | |
tree | 4b25595f3d68b2d0a64cbfbf2ab2987e9b8b163e /conf/conf.c | |
parent | 84545a26cc3f7ce68408a663c1ad4a50edccdacc (diff) |
Conf: Free stored old config before parsing new one
BIRD keeps a previous (old) configuration for the purpose of undo. The
existing code frees it after a new configuration is successfully parsed
during reconfiguration. That causes memory usage spikes as there are
temporarily three configurations (old, current, and new). The patch
changes it to free the old one before parsing the new one (as user
already requested a new config). The disadvantage is that undo is
not available after failed reconfiguration.
Diffstat (limited to 'conf/conf.c')
-rw-r--r-- | conf/conf.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/conf/conf.c b/conf/conf.c index 11c136e7..4e31de29 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -201,6 +201,23 @@ config_free(struct config *c) rfree(c->pool); } +/** + * config_free_old - free stored old configuration + * + * This function frees the old configuration (%old_config) that is saved for the + * purpose of undo. It is useful before parsing a new config when reconfig is + * requested, to avoid keeping three (perhaps memory-heavy) configs together. + */ +void +config_free_old(void) +{ + tm_stop(config_timer); + undo_available = 0; + + config_free(old_config); + old_config = NULL; +} + void config_add_obstacle(struct config *c) { |