From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj9iY-00068g-Jz for qemu-devel@nongnu.org; Fri, 17 Apr 2015 13:06:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yj9iU-0005EK-FP for qemu-devel@nongnu.org; Fri, 17 Apr 2015 13:06:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj9iT-0005EG-Vx for qemu-devel@nongnu.org; Fri, 17 Apr 2015 13:06:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B29F28EA23 for ; Fri, 17 Apr 2015 17:06:09 +0000 (UTC) Message-ID: <55313D7C.8030804@redhat.com> Date: Fri, 17 Apr 2015 19:06:04 +0200 From: Paolo Bonzini MIME-Version: 1.0 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> <20150417161158.GL23619@redhat.com> In-Reply-To: <20150417161158.GL23619@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 RFC 25/34] io: add QIOTask class for async operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Gerd Hoffmann On 17/04/2015 18:11, Daniel P. Berrange wrote: >=20 > + task =3D qio_task_new(OBJECT(ioc), > + func, opaque, destroy); > + > + qio_channel_tls_handshake_task(ioc, task); > + > + object_unref(OBJECT(task)); >=20 > The second ref taken at time of qio_channel_add_watch_full() gets relea= sed > by the GDestroyNotify that is passed to that method. /me is blind. So this means you really do not need the reference counting; qio_channel_tls_handshake_task (which is static anyway) is what manages the lifetime of the QIOTask, it can take ownership of the task right after it is created. In effect QIOTask is just wrapping the (func, opaque, destroy) continuation. It makes sense that it doesn't need reference counting, because it has a well-defined point of death (just before the continuation is called, or just before you find out it will never be called). So I think it's okay to remove the reference counting and make it a simple heap-allocated struct. gio_channel_tls_handshake_task can free it after calling gio_task_{abort,complete}. Without the reference counting the GDestroyNotify also becomes unnecessary (and the fact that you're using QIOTask as a simple continuation explains why you didn't need GDestroyNotify), but it's okay if you want to leave it in. I would also have QIOTaskFunc take the "exploded" struct, i.e. typedef void QIOTaskFunc(QMyObject *, gpointer, Error *), and hide QIOTask entirely from the user. Paolo