From nobody Fri May 16 08:10:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496318937166737.4998435473113; Thu, 1 Jun 2017 05:08:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16345C04B30E; Thu, 1 Jun 2017 12:08:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88EC17E4C8; Thu, 1 Jun 2017 12:08:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 302AC97013; Thu, 1 Jun 2017 12:08:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v51C8iK7022649 for ; Thu, 1 Jun 2017 08:08:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B47CD53C6E; Thu, 1 Jun 2017 12:08:44 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CACE5279C for ; Thu, 1 Jun 2017 12:08:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16345C04B30E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 16345C04B30E From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 1 Jun 2017 14:08:34 +0200 Message-Id: <6cbc70d03d277d88e4f562b0f2ceac74e1085de0.1496318548.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] virStream: Remove callbacks on Abort/Finish X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 01 Jun 2017 12:08:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Users need to remove their callbacks before calling virStreamAbort() or virStreamFinish() even though that's not documented anywhere. Since it makes no sense to keep those callbacks, we can remove them when the stream is being aborted or finished. That way it is also more intuitive for developers as that removes some confusing errors being reported. Signed-off-by: Martin Kletzander --- src/remote/remote_driver.c | 1 + src/util/virfdstream.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 49909bf69747..0ab70a8761b5 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5870,6 +5870,7 @@ remoteStreamCloseInt(virStreamPtr st, bool streamAbor= t) priv->localUses--; cleanup: + virNetClientStreamEventRemoveCallback(privst, true); virNetClientRemoveStream(priv->client, privst); virObjectUnref(privst); st->privateData =3D NULL; diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 7ee58be136d1..ac1f4a24d60e 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -721,6 +721,15 @@ virFDStreamCloseInt(virStreamPtr st, bool streamAbort) st->privateData =3D NULL; + if (fdst->watch) + virEventRemoveHandle(fdst->watch); + + fdst->watch =3D 0; + fdst->ff =3D NULL; + fdst->cb =3D NULL; + fdst->events =3D 0; + fdst->opaque =3D NULL; + /* call the internal stream closing callback */ if (fdst->icbCb) { /* the mutex is not accessible anymore, as private data is null */ @@ -731,8 +740,11 @@ virFDStreamCloseInt(virStreamPtr st, bool streamAbort) if (fdst->dispatching) { fdst->closed =3D true; + fdst->cbRemoved =3D true; virObjectUnlock(fdst); } else { + if (fdst->ff) + (fdst->ff)(fdst->opaque); virObjectUnlock(fdst); virObjectUnref(fdst); } --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list