mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-08 16:07:39 -06:00
util/log: Rename qemu_log_lock to qemu_log_trylock
This function can fail, which makes it more like ftrylockfile or pthread_mutex_trylock than flockfile or pthread_mutex_lock, so rename it. To closer match the other trylock functions, release rcu_read_lock along the failure path, so that qemu_log_unlock need not be called on failure. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-8-richard.henderson@linaro.org>
This commit is contained in:
parent
c59fe6e536
commit
c60f599bcb
12 changed files with 18 additions and 16 deletions
|
@ -36,15 +36,17 @@ static GArray *debug_regions;
|
|||
|
||||
/* Lock/unlock output. */
|
||||
|
||||
FILE *qemu_log_lock(void)
|
||||
FILE *qemu_log_trylock(void)
|
||||
{
|
||||
QemuLogFile *logfile;
|
||||
|
||||
rcu_read_lock();
|
||||
logfile = qatomic_rcu_read(&qemu_logfile);
|
||||
if (logfile) {
|
||||
qemu_flockfile(logfile->fd);
|
||||
return logfile->fd;
|
||||
} else {
|
||||
rcu_read_unlock();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +55,8 @@ void qemu_log_unlock(FILE *fd)
|
|||
{
|
||||
if (fd) {
|
||||
qemu_funlockfile(fd);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
/* Return the number of characters emitted. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue