From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEY2J-0006BU-02 for qemu-devel@nongnu.org; Wed, 28 Aug 2013 01:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEY2E-00051w-05 for qemu-devel@nongnu.org; Wed, 28 Aug 2013 01:11:18 -0400 From: Amit Shah Date: Wed, 28 Aug 2013 10:40:44 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 2/9] char: introduce tcp_chr_detach() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: qemu-stable@nongnu.org, Hans de Goede , Gerd Hoffmann , Anthony Liguori , Amit Shah , Paolo Bonzini Remove any registered callbacks if a frontend is detached. CC: Signed-off-by: Amit Shah --- 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