Remove any registered callbacks if a frontend is detached. CC: <qemu-sta...@nongnu.org> Signed-off-by: Amit Shah <amit.s...@redhat.com> --- qemu-char.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/qemu-char.c b/qemu-char.c index f27fdb6..e235334 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2321,6 +2321,16 @@ typedef struct { int msgfd; } TCPCharDriver; +static void tcp_chr_detach(CharDriverState *chr) +{ + TCPCharDriver *s = chr->opaque; + + if (s->tag) { + io_remove_watch_poll(s->tag); + s->tag = 0; + } +} + static gboolean tcp_chr_accept(GIOChannel *chan, GIOCondition cond, void *opaque); static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) @@ -2689,6 +2699,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay, chr->opaque = s; chr->chr_write = tcp_chr_write; chr->chr_close = tcp_chr_close; + chr->chr_detach = tcp_chr_detach; chr->get_msgfd = tcp_get_msgfd; chr->chr_add_client = tcp_chr_add_client; chr->chr_add_watch = tcp_chr_add_watch; -- 1.8.3.1