From 8487ce45f890cab208541f01e79579d7b25e1615 Mon Sep 17 00:00:00 2001 From: zhanghailiang Date: Fri, 17 Feb 2017 10:53:13 +0800 Subject: char: remove the right fd been watched in qemu_chr_fe_set_handlers() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Cc: Marc-André Lureau Signed-off-by: zhanghailiang Reviewed-by: Marc-André Lureau Signed-off-by: Jason Wang --- chardev/char-socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chardev/char-socket.c') diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 865c52762e..d7e92e1bd3 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -328,7 +328,7 @@ static void tcp_chr_free_connection(Chardev *chr) } tcp_set_msgfds(chr, NULL, 0); - remove_fd_in_watch(chr); + remove_fd_in_watch(chr, NULL); object_unref(OBJECT(s->sioc)); s->sioc = NULL; object_unref(OBJECT(s->ioc)); @@ -498,7 +498,7 @@ static void tcp_chr_update_read_handler(Chardev *chr, return; } - remove_fd_in_watch(chr); + remove_fd_in_watch(chr, NULL); if (s->ioc) { chr->fd_in_tag = io_add_watch_poll(chr, s->ioc, tcp_chr_read_poll, -- cgit v1.2.1