From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEY2M-0006CV-QQ for qemu-devel@nongnu.org; Wed, 28 Aug 2013 01:11:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEY2H-00053H-PU for qemu-devel@nongnu.org; Wed, 28 Aug 2013 01:11:22 -0400 From: Amit Shah Date: Wed, 28 Aug 2013 10:40:46 +0530 Message-Id: <9807d5cb755dfc5e231cac33b4e4518dd3cdae06.1377666450.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH 4/9] char: introduce pty_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 91ae1da..befecf2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1036,6 +1036,16 @@ typedef struct { static void pty_chr_update_read_handler(CharDriverState *chr); static void pty_chr_state(CharDriverState *chr, int connected); +static void pty_chr_detach(struct CharDriverState *chr) +{ + PtyCharDriver *s = chr->opaque; + + if (s->fd_tag) { + io_remove_watch_poll(s->fd_tag); + s->fd_tag = 0; + } +} + static gboolean pty_chr_timer(gpointer opaque) { struct CharDriverState *chr = opaque; @@ -1215,6 +1225,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id, chr->chr_update_read_handler = pty_chr_update_read_handler; chr->chr_close = pty_chr_close; chr->chr_add_watch = pty_chr_add_watch; + chr->chr_detach = pty_chr_detach; chr->explicit_be_open = true; s->fd = io_channel_from_fd(master_fd); -- 1.8.3.1