Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | From 86842df8bff5c97e44fc55d2fb7fc6c10f56ab84 Mon Sep 17 00:00:00 2001 |
| 2 | From: Gergely Nagy <algernon@balabit.hu> |
| 3 | Date: Fri, 13 Dec 2013 13:46:15 +0100 |
| 4 | Subject: [PATCH] mainloop: Deinit the new config when reverting to the old one |
| 5 | |
| 6 | Upstream-Status: Backport |
| 7 | |
| 8 | When reloading, and the new config fails, deinit it before initializing |
| 9 | the old config. This is so that conflicting things do not remain held by |
| 10 | the half-initialized new config, while the old tries to take it |
| 11 | over. (It also removed a couple of memory leaks, most likely.) |
| 12 | |
| 13 | The reason we can do this, is because cfg_tree_stop() (called by |
| 14 | cfg_deinit()) goes over all the known nodes, and log_pipe_deinit() is |
| 15 | also smart enough to not deinit a node that has not been inited before. |
| 16 | |
| 17 | Signed-off-by: Gergely Nagy <algernon@balabit.hu> |
| 18 | --- |
| 19 | lib/mainloop.c | 1 + |
| 20 | 1 file changed, 1 insertion(+) |
| 21 | |
| 22 | diff --git a/lib/mainloop.c b/lib/mainloop.c |
| 23 | index 34655fa..e6fbb59 100644 |
| 24 | --- a/lib/mainloop.c |
| 25 | +++ b/lib/mainloop.c |
| 26 | @@ -510,6 +510,7 @@ main_loop_reload_config_apply(void) |
| 27 | { |
| 28 | msg_error("Error initializing new configuration, reverting to old config", NULL); |
| 29 | cfg_persist_config_move(main_loop_new_config, main_loop_old_config); |
| 30 | + cfg_deinit(main_loop_new_config); |
| 31 | if (!cfg_init(main_loop_old_config)) |
| 32 | { |
| 33 | /* hmm. hmmm, error reinitializing old configuration, we're hosed. |
| 34 | -- |
| 35 | 1.8.4.1 |
| 36 | |