From patchwork Wed Aug 28 05:10:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 270330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 077332C007B for ; Wed, 28 Aug 2013 15:11:56 +1000 (EST) Received: from localhost ([::1]:60358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEY2s-0006Ei-50 for incoming@patchwork.ozlabs.org; Wed, 28 Aug 2013 01:11:54 -0400 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 Received: from mx1.redhat.com ([209.132.183.28]:34491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEY2D-00051s-P7; Wed, 28 Aug 2013 01:11:13 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7S5BBIg004431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Aug 2013 01:11:11 -0400 Received: from localhost (dhcp193-119.pnq.redhat.com [10.65.193.119]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7S5B9E3018797; Wed, 28 Aug 2013 01:11:10 -0400 From: Amit Shah To: qemu list Date: Wed, 28 Aug 2013 10:40:44 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-stable@nongnu.org, Hans de Goede , Gerd Hoffmann , Anthony Liguori , Amit Shah , Paolo Bonzini Subject: [Qemu-devel] [PATCH 2/9] char: introduce tcp_chr_detach() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;