From nobody Sun Feb 8 15:29:24 2026 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 1491316310097815.4152619882117; Tue, 4 Apr 2017 07:31:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 135A27AE9E; Tue, 4 Apr 2017 14:31:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D924F94480; Tue, 4 Apr 2017 14:31:47 +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 8435018521CB; Tue, 4 Apr 2017 14:31:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34EVkVP025010 for ; Tue, 4 Apr 2017 10:31:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6AEED8D15D; Tue, 4 Apr 2017 14:31:46 +0000 (UTC) Received: from dhcp-17-113.lcy.redhat.com (unknown [10.42.17.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEDE090C67; Tue, 4 Apr 2017 14:31:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 135A27AE9E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 135A27AE9E From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 15:31:30 +0100 Message-Id: <20170404143134.12141-4-berrange@redhat.com> In-Reply-To: <20170404143134.12141-1-berrange@redhat.com> References: <20170404143134.12141-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Wojtek Porczyk Subject: [libvirt] [PATCH v3 3/7] event-test: free opaque data when removing callbacks 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 04 Apr 2017 14:31:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The pure python event loop impl has to call libvirt.virEventInvokeFreeCallback to free the event opaque data from a clean stack context Signed-off-by: Daniel P. Berrange --- examples/event-test.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/event-test.py b/examples/event-test.py index a1105a3..851c09b 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -107,6 +107,7 @@ class virEventLoopPure: self.nextTimerID =3D 1 self.handles =3D [] self.timers =3D [] + self.cleanup =3D [] self.quit =3D False =20 # The event loop can be used from multiple threads at once. @@ -178,6 +179,11 @@ class virEventLoopPure: def run_once(self): sleep =3D -1 self.runningPoll =3D True + + for opaque in self.cleanup: + libvirt.virEventInvokeFreeCallback(opaque) + self.cleanup =3D [] + try: next =3D self.next_timeout() debug("Next timeout due at %d" % next) @@ -300,8 +306,9 @@ class virEventLoopPure: handles =3D [] for h in self.handles: if h.get_id() =3D=3D handleID: - self.poll.unregister(h.get_fd()) debug("Remove handle %d fd %d" % (handleID, h.get_fd())) + self.poll.unregister(h.get_fd()) + self.cleanup.append(h.opaque) else: handles.append(h) self.handles =3D handles @@ -313,7 +320,9 @@ class virEventLoopPure: for h in self.timers: if h.get_id() !=3D timerID: timers.append(h) + else: debug("Remove timer %d" % timerID) + self.cleanup.append(h.opaque) self.timers =3D timers self.interrupt() =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list