]> git.proxmox.com Git - mirror_qemu.git/commit - util/log.c
util/log: Close per-thread log file on thread termination
authorGreg Kurz <groug@kaod.org>
Fri, 21 Oct 2022 10:57:34 +0000 (12:57 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 31 Oct 2022 08:46:34 +0000 (09:46 +0100)
commiteff3de52f265df39c6fc668415ad317ec1f24051
treef5cf5a9ca592a20a5361813de78d9bb1a403443c
parent19e2a9fb9da067acba95b3be83588bda5a3f6a99
util/log: Close per-thread log file on thread termination

When `-D ${logfile} -d tid` is passed, qemu_log_trylock() creates
a dedicated log file for the current thread and opens it. The
corresponding file descriptor is cached in a __thread variable.
Nothing is done to close the corresponding file descriptor when the
thread terminates though and the file descriptor is leaked.

The issue was found during code inspection and reproduced manually.

Fix that with an atexit notifier.

Fixes: 4e51069d6793 ("util/log: Support per-thread log files")
Cc: richard.henderson@linaro.org
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20221021105734.555797-1-groug@kaod.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/log.c