monitor: release the lock before calling close()
As per comment, presumably to avoid syscall in critical section.
Fixes: 0210c3b39b
("monitor: Use LOCK_GUARD macros")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230306122751.2355515-7-marcandre.lureau@redhat.com>
This commit is contained in:
parent
bf5de8c5d6
commit
78ae0e2613
@ -80,7 +80,8 @@ void qmp_getfd(const char *fdname, Error **errp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QEMU_LOCK_GUARD(&cur_mon->mon_lock);
|
/* See close() call below. */
|
||||||
|
qemu_mutex_lock(&cur_mon->mon_lock);
|
||||||
QLIST_FOREACH(monfd, &cur_mon->fds, next) {
|
QLIST_FOREACH(monfd, &cur_mon->fds, next) {
|
||||||
if (strcmp(monfd->name, fdname) != 0) {
|
if (strcmp(monfd->name, fdname) != 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -88,6 +89,7 @@ void qmp_getfd(const char *fdname, Error **errp)
|
|||||||
|
|
||||||
tmp_fd = monfd->fd;
|
tmp_fd = monfd->fd;
|
||||||
monfd->fd = fd;
|
monfd->fd = fd;
|
||||||
|
qemu_mutex_unlock(&cur_mon->mon_lock);
|
||||||
/* Make sure close() is outside critical section */
|
/* Make sure close() is outside critical section */
|
||||||
close(tmp_fd);
|
close(tmp_fd);
|
||||||
return;
|
return;
|
||||||
@ -98,6 +100,7 @@ void qmp_getfd(const char *fdname, Error **errp)
|
|||||||
monfd->fd = fd;
|
monfd->fd = fd;
|
||||||
|
|
||||||
QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next);
|
QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next);
|
||||||
|
qemu_mutex_unlock(&cur_mon->mon_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qmp_closefd(const char *fdname, Error **errp)
|
void qmp_closefd(const char *fdname, Error **errp)
|
||||||
|
Loading…
Reference in New Issue
Block a user