[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/25] monitor: release the lock before calling close()
From: |
marcandre . lureau |
Subject: |
[PULL 21/25] monitor: release the lock before calling close() |
Date: |
Mon, 13 Mar 2023 15:43:31 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
As per comment, presumably to avoid syscall in critical section.
Fixes: 0210c3b39bef08 ("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>
---
monitor/fds.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/monitor/fds.c b/monitor/fds.c
index 26b39a0ce6..7daf1064e1 100644
--- a/monitor/fds.c
+++ b/monitor/fds.c
@@ -80,7 +80,8 @@ void qmp_getfd(const char *fdname, Error **errp)
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) {
if (strcmp(monfd->name, fdname) != 0) {
continue;
@@ -88,6 +89,7 @@ void qmp_getfd(const char *fdname, Error **errp)
tmp_fd = monfd->fd;
monfd->fd = fd;
+ qemu_mutex_unlock(&cur_mon->mon_lock);
/* Make sure close() is outside critical section */
close(tmp_fd);
return;
@@ -98,6 +100,7 @@ void qmp_getfd(const char *fdname, Error **errp)
monfd->fd = fd;
QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next);
+ qemu_mutex_unlock(&cur_mon->mon_lock);
}
void qmp_closefd(const char *fdname, Error **errp)
--
2.39.2
- [PULL 11/25] slirp: unregister the win32 SOCKET, (continued)
- [PULL 11/25] slirp: unregister the win32 SOCKET, marcandre . lureau, 2023/03/13
- [PULL 12/25] slirp: open-code qemu_socket_(un)select(), marcandre . lureau, 2023/03/13
- [PULL 14/25] os-posix: remove useless ioctlsocket() define, marcandre . lureau, 2023/03/13
- [PULL 13/25] win32: avoid mixing SOCKET and file descriptor space, marcandre . lureau, 2023/03/13
- [PULL 15/25] win32: replace closesocket() with close() wrapper, marcandre . lureau, 2023/03/13
- [PULL 16/25] tests: fix path separator, use g_build_filename(), marcandre . lureau, 2023/03/13
- [PULL 17/25] char: do not double-close fd when failing to add client, marcandre . lureau, 2023/03/13
- [PULL 18/25] tests/docker: fix a win32 error due to portability, marcandre . lureau, 2023/03/13
- [PULL 19/25] osdep: implement qemu_socketpair() for win32, marcandre . lureau, 2023/03/13
- [PULL 20/25] qmp: 'add_client' actually expects sockets, marcandre . lureau, 2023/03/13
- [PULL 21/25] monitor: release the lock before calling close(),
marcandre . lureau <=
- [PULL 22/25] qmp: add 'get-win32-socket', marcandre . lureau, 2023/03/13
- [PULL 23/25] libqtest: make qtest_qmp_add_client work on win32, marcandre . lureau, 2023/03/13
- [PULL 25/25] QMP/HMP: only actually implement getfd on CONFIG_POSIX, marcandre . lureau, 2023/03/13
- [PULL 24/25] qtest: enable vnc-display test on win32, marcandre . lureau, 2023/03/13
- Re: [PULL 00/25] Win socket patches, Marc-André Lureau, 2023/03/13
- Re: [PULL 00/25] Win socket patches, Marc-André Lureau, 2023/03/13