summaryrefslogtreecommitdiff
path: root/chardev/char-io.c
diff options
context:
space:
mode:
authorzhanghailiang <zhang.zhanghailiang@huawei.com>2017-02-17 10:53:13 +0800
committerJason Wang <jasowang@redhat.com>2017-03-06 11:46:02 +0800
commit8487ce45f890cab208541f01e79579d7b25e1615 (patch)
tree0013e431aa3a34e0da0e3a9c5eb898e11314d619 /chardev/char-io.c
parentdfd917a9c2bed578c31043126c9f558190bf21e4 (diff)
downloadqemu-8487ce45f890cab208541f01e79579d7b25e1615.tar.gz
char: remove the right fd been watched in qemu_chr_fe_set_handlers()
We can call qemu_chr_fe_set_handlers() to add/remove fd been watched in 'context' which can be either default main context or other explicit context. But the original logic is not correct, we didn't remove the right fd because we call g_main_context_find_source_by_id(NULL, tag) which always try to find the Gsource from default context. Fix it by passing the right context to g_main_context_find_source_by_id(). Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'chardev/char-io.c')
-rw-r--r--chardev/char-io.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/chardev/char-io.c b/chardev/char-io.c
index 7dfc3f22ba..b4bb094ea3 100644
--- a/chardev/char-io.c
+++ b/chardev/char-io.c
@@ -127,14 +127,14 @@ guint io_add_watch_poll(Chardev *chr,
return tag;
}
-static void io_remove_watch_poll(guint tag)
+static void io_remove_watch_poll(guint tag, GMainContext *context)
{
GSource *source;
IOWatchPoll *iwp;
g_return_if_fail(tag > 0);
- source = g_main_context_find_source_by_id(NULL, tag);
+ source = g_main_context_find_source_by_id(context, tag);
g_return_if_fail(source != NULL);
iwp = io_watch_poll_from_source(source);
@@ -146,10 +146,10 @@ static void io_remove_watch_poll(guint tag)
g_source_destroy(&iwp->parent);
}
-void remove_fd_in_watch(Chardev *chr)
+void remove_fd_in_watch(Chardev *chr, GMainContext *context)
{
if (chr->fd_in_tag) {
- io_remove_watch_poll(chr->fd_in_tag);
+ io_remove_watch_poll(chr->fd_in_tag, context);
chr->fd_in_tag = 0;
}
}