From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj8sA-0005KG-JZ for qemu-devel@nongnu.org; Fri, 17 Apr 2015 12:12:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yj8s7-0003ry-9e for qemu-devel@nongnu.org; Fri, 17 Apr 2015 12:12:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj8s7-0003rr-1n for qemu-devel@nongnu.org; Fri, 17 Apr 2015 12:12:03 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3HGC2Ru022971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 17 Apr 2015 12:12:02 -0400 Date: Fri, 17 Apr 2015 17:11:58 +0100 From: "Daniel P. Berrange" Message-ID: <20150417161158.GL23619@redhat.com> References: <1429280557-8887-1-git-send-email-berrange@redhat.com> <1429280557-8887-26-git-send-email-berrange@redhat.com> <553123CA.2090408@redhat.com> <20150417154955.GJ23619@redhat.com> <55312D64.4080307@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <55312D64.4080307@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1 RFC 25/34] io: add QIOTask class for async operations Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Gerd Hoffmann On Fri, Apr 17, 2015 at 05:57:24PM +0200, Paolo Bonzini wrote: > > > On 17/04/2015 17:49, Daniel P. Berrange wrote: > > > In this case I even think you're leaking the task. You do object_ref > > > twice (once at creation time, once before qio_channel_add_watch_full) > > > and only have one object_unref. I would just do without reference > > > counting, and add a qio_task_free() function that calls > > > qio_task_finalize() and frees the QIOTask. > > > > Are you referring to the qio_channel_tls_handshake() method in the > > next patch ? If so it does actually have two object_unref calls > > so shouldn't be leaking. In more complex scenarios I thnk the > > ref counting ability will come in useful. Of course I could add > > ref counting to a plain struct without using QOM, but it felt > > better to just use QOM and be done with it, so people don't have > > to remember which particular unref method they must use. > > I cannot find the second... O:-) I create & unref it in the same place: + task = qio_task_new(OBJECT(ioc), + func, opaque, destroy); + + qio_channel_tls_handshake_task(ioc, task); + + object_unref(OBJECT(task)); The second ref taken at time of qio_channel_add_watch_full() gets released by the GDestroyNotify that is passed to that method. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|