Merge the close from the changed_name block with the close from the !need_to_open_file block.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- util/log.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index f1f6d09c90..596de0050f 100644 --- a/util/log.c +++ b/util/log.c @@ -166,12 +166,6 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, g_free(global_filename); global_filename = newname; filename = newname; - - if (logfile) { - qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - logfile = NULL; - } } else { filename = global_filename; } @@ -191,11 +185,12 @@ static void qemu_set_log_internal(const char *filename, bool changed_name, daemonized = is_daemonized(); need_to_open_file = log_flags && (!daemonized || filename); - if (logfile && !need_to_open_file) { + if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - return; + logfile = NULL; } + if (!logfile && need_to_open_file) { FILE *fd; -- 2.25.1