From: Ondrej Zajicek Date: Sun, 19 Feb 2023 02:59:10 +0000 (+0100) Subject: Conf: Fix too early free of old configuration X-Git-Tag: v3.0-alpha1~10^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eefb29679957fed3724e6d5db2ddf112e28f646f;p=thirdparty%2Fbird.git Conf: Fix too early free of old configuration The change 371eb49043d225d2bab8149187b813a14b4b86d2 introduced early free of old_config. Unfortunately, it did not properly check whether it is not still in use (blocked by obstacle during reconfiguration). Fix that. It also means that we still could have a short peak when three configs are in use (when a new reconfig is requeste while the previous one is still active). --- diff --git a/conf/conf.c b/conf/conf.c index 4e31de293..7ef729b33 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -197,8 +197,12 @@ cleanup: void config_free(struct config *c) { - if (c) - rfree(c->pool); + if (!c) + return; + + ASSERT(!c->obstacle_count); + + rfree(c->pool); } /** @@ -207,10 +211,14 @@ config_free(struct config *c) * 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. + * Configuration is not freed when it is still active during reconfiguration. */ void config_free_old(void) { + if (!old_config || old_config->obstacle_count) + return; + tm_stop(config_timer); undo_available = 0;