balabit/syslog-ng — pull request #41 by algernon (2013-12-13 12:55:37+00:00)
Title: cfg-tree tests & partial deinit on a reverting reload

This set adds two patches: a few simple cfg-tree test cases I used to verify my assumptions, and a bugfix/improvement to `main_loop_reload_config_apply()`, which deinits the new, failed configuration before initing the old one. We can do this safely, because both `cfg_tree_stop()` and `log_pipe_deinit()` are smart enough to only deinit those parts of the pipeline that have been inited before.

We need this so that we don't crash when we reload a config like this:

```
source s_src {
internal();
tcp(port(22));
};

source s_system {
system();
};

destination d_null { };

log {
#source(s_src);
source(s_system);
destination(d_null);
};
```

When run with with this config, if we enable the `s_src` source and reload, it will crash because the internal source was not deinited. This also happens in other cases, and has been seen in the wild too. This patch corrects the crash by deiniting the failed config before bringing the old one back up.