[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/28] monitor: Simplify fdset and fd removal
From: |
Fabiano Rosas |
Subject: |
[PULL 08/28] monitor: Simplify fdset and fd removal |
Date: |
Fri, 21 Jun 2024 14:54:14 -0300 |
Remove fds right away instead of setting the ->removed flag. We don't
need the extra complexity of having a cleanup function reap the
removed entries at a later time.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
monitor/fds.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/monitor/fds.c b/monitor/fds.c
index 76199d4b3b..e7619a6103 100644
--- a/monitor/fds.c
+++ b/monitor/fds.c
@@ -43,7 +43,6 @@ struct mon_fd_t {
typedef struct MonFdsetFd MonFdsetFd;
struct MonFdsetFd {
int fd;
- bool removed;
char *opaque;
QLIST_ENTRY(MonFdsetFd) next;
};
@@ -193,20 +192,6 @@ static void monitor_fdset_fd_free(MonFdsetFd *mon_fdset_fd)
g_free(mon_fdset_fd);
}
-static void monitor_fdset_cleanup(MonFdset *mon_fdset)
-{
- MonFdsetFd *mon_fdset_fd;
- MonFdsetFd *mon_fdset_fd_next;
-
- QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_next)
{
- if (mon_fdset_fd->removed) {
- monitor_fdset_fd_free(mon_fdset_fd);
- }
- }
-
- monitor_fdset_free_if_empty(mon_fdset);
-}
-
void monitor_fdsets_cleanup(void)
{
MonFdset *mon_fdset;
@@ -281,7 +266,7 @@ void qmp_get_win32_socket(const char *infos, const char
*fdname, Error **errp)
void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **errp)
{
MonFdset *mon_fdset;
- MonFdsetFd *mon_fdset_fd;
+ MonFdsetFd *mon_fdset_fd, *mon_fdset_fd_next;
char fd_str[60];
QEMU_LOCK_GUARD(&mon_fdsets_lock);
@@ -289,21 +274,22 @@ void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t
fd, Error **errp)
if (mon_fdset->id != fdset_id) {
continue;
}
- QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) {
+ QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next,
+ mon_fdset_fd_next) {
if (has_fd) {
if (mon_fdset_fd->fd != fd) {
continue;
}
- mon_fdset_fd->removed = true;
+ monitor_fdset_fd_free(mon_fdset_fd);
break;
} else {
- mon_fdset_fd->removed = true;
+ monitor_fdset_fd_free(mon_fdset_fd);
}
}
if (has_fd && !mon_fdset_fd) {
goto error;
}
- monitor_fdset_cleanup(mon_fdset);
+ monitor_fdset_free_if_empty(mon_fdset);
return;
}
@@ -413,7 +399,6 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id,
int64_t fdset_id,
mon_fdset_fd = g_malloc0(sizeof(*mon_fdset_fd));
mon_fdset_fd->fd = fd;
- mon_fdset_fd->removed = false;
mon_fdset_fd->opaque = g_strdup(opaque);
QLIST_INSERT_HEAD(&mon_fdset->fds, mon_fdset_fd, next);
--
2.35.3
- [PULL 00/28] Migration patches for 2024-06-21, Fabiano Rosas, 2024/06/21
- [PULL 01/28] migration: Drop reference to QIOChannel if file seeking fails, Fabiano Rosas, 2024/06/21
- [PULL 02/28] migration: Fix file migration with fdset, Fabiano Rosas, 2024/06/21
- [PULL 03/28] tests/qtest/migration: Fix file migration offset check, Fabiano Rosas, 2024/06/21
- [PULL 05/28] monitor: Drop monitor_fdset_dup_fd_find/_remove(), Fabiano Rosas, 2024/06/21
- [PULL 04/28] tests/qtest/migration: Add a precopy file test with fdset, Fabiano Rosas, 2024/06/21
- [PULL 06/28] monitor: Introduce monitor_fdset_*free, Fabiano Rosas, 2024/06/21
- [PULL 07/28] monitor: Stop removing non-duplicated fds, Fabiano Rosas, 2024/06/21
- [PULL 08/28] monitor: Simplify fdset and fd removal,
Fabiano Rosas <=
- [PULL 09/28] monitor: Report errors from monitor_fdset_dup_fd_add, Fabiano Rosas, 2024/06/21
- [PULL 10/28] io: Stop using qemu_open_old in channel-file, Fabiano Rosas, 2024/06/21
- [PULL 11/28] migration: Add direct-io parameter, Fabiano Rosas, 2024/06/21
- [PULL 12/28] migration/multifd: Add direct-io support, Fabiano Rosas, 2024/06/21
- [PULL 13/28] tests/qtest/migration: Add tests for file migration with direct-io, Fabiano Rosas, 2024/06/21
- [PULL 14/28] monitor: fdset: Match against O_DIRECT, Fabiano Rosas, 2024/06/21
- [PULL 15/28] migration: Add documentation for fdset with multifd + file, Fabiano Rosas, 2024/06/21
- [PULL 16/28] tests/qtest/migration: Add a test for mapped-ram with passing of fds, Fabiano Rosas, 2024/06/21
- [PULL 17/28] migration/multifd: Avoid the final FLUSH in complete(), Fabiano Rosas, 2024/06/21
- [PULL 18/28] migration: Rename thread debug names, Fabiano Rosas, 2024/06/21