mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
monitor: Drop monitor_fdset_dup_fd_find/_remove()
Those functions are not needed, one remove function should already work. Clean it up. Here the code doesn't really care about whether we need to keep that dupfd around if close() failed: when that happens something got very wrong, keeping the dup_fd around the fdsets may not help that situation so far. Cc: Dr. David Alan Gilbert <dave@treblig.org> Cc: Markus Armbruster <armbru@redhat.com> Cc: Philippe Mathieu-Daudé <philmd@linaro.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> [add missing return statement, removal during traversal is not safe] Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
parent
926554c0bf
commit
1cd93fb0bf
4 changed files with 7 additions and 42 deletions
|
@ -458,7 +458,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int64_t monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)
|
||||
void monitor_fdset_dup_fd_remove(int dup_fd)
|
||||
{
|
||||
MonFdset *mon_fdset;
|
||||
MonFdsetFd *mon_fdset_fd_dup;
|
||||
|
@ -467,31 +467,15 @@ static int64_t monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)
|
|||
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
|
||||
QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {
|
||||
if (mon_fdset_fd_dup->fd == dup_fd) {
|
||||
if (remove) {
|
||||
QLIST_REMOVE(mon_fdset_fd_dup, next);
|
||||
g_free(mon_fdset_fd_dup);
|
||||
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
|
||||
monitor_fdset_cleanup(mon_fdset);
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
return mon_fdset->id;
|
||||
QLIST_REMOVE(mon_fdset_fd_dup, next);
|
||||
g_free(mon_fdset_fd_dup);
|
||||
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
|
||||
monitor_fdset_cleanup(mon_fdset);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t monitor_fdset_dup_fd_find(int dup_fd)
|
||||
{
|
||||
return monitor_fdset_dup_fd_find_remove(dup_fd, false);
|
||||
}
|
||||
|
||||
void monitor_fdset_dup_fd_remove(int dup_fd)
|
||||
{
|
||||
monitor_fdset_dup_fd_find_remove(dup_fd, true);
|
||||
}
|
||||
|
||||
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue