summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2023-02-19 03:59:10 +0100
committerMaria Matejka <mq@ucw.cz>2023-04-04 17:00:58 +0200
commit6899ba2232f232e44c4e45d06036409f173fbe23 (patch)
tree06e378deebbd48184fddd4f9b653e321f061fa4d
parentb8a230e478d41def757344bbe1eee7fa886682e5 (diff)
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).
-rw-r--r--conf/conf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/conf/conf.c b/conf/conf.c
index fc8e3c46..daac85c1 100644
--- a/conf/conf.c
+++ b/conf/conf.c
@@ -195,8 +195,12 @@ cleanup:
void
config_free(struct config *c)
{
- if (c)
- rfree(c->pool);
+ if (!c)
+ return;
+
+ ASSERT(!c->obstacle_count);
+
+ rfree(c->pool);
}
/**
@@ -205,10 +209,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;