From nobody Fri May 16 05:24:00 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.zohomail.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 1501156073067315.9295931969896; Thu, 27 Jul 2017 04:47:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 512234024E; Thu, 27 Jul 2017 11:47:51 +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 2E78E4FA0A; Thu, 27 Jul 2017 11:47:51 +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 D64C714B27; Thu, 27 Jul 2017 11:47:50 +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 v6RBlaT8028583 for ; Thu, 27 Jul 2017 07:47:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id B26245D72E; Thu, 27 Jul 2017 11:47:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A8BD5D72D for ; Thu, 27 Jul 2017 11:47:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 512234024E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 27 Jul 2017 13:47:26 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] virConnect: Derive from virObjectRWLockable 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 27 Jul 2017 11:47:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no reason why two threads trying to copy error from connection should mutually exclude each other. Utilize new virObjectRWLockable that was just introduced. Signed-off-by: Michal Privoznik --- src/datatypes.c | 6 ++++-- src/datatypes.h | 2 +- src/util/virerror.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index 46414ae29..c3e143c7e 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -83,8 +83,10 @@ virDataTypesOnceInit(void) DECLARE_CLASS_COMMON(basename, virClassForObject()) #define DECLARE_CLASS_LOCKABLE(basename) \ DECLARE_CLASS_COMMON(basename, virClassForObjectLockable()) +#define DECLARE_CLASS_RWLOCKABLE(basename) \ + DECLARE_CLASS_COMMON(basename, virClassForObjectRWLockable()) =20 - DECLARE_CLASS_LOCKABLE(virConnect); + DECLARE_CLASS_RWLOCKABLE(virConnect); DECLARE_CLASS_LOCKABLE(virConnectCloseCallbackData); DECLARE_CLASS(virDomain); DECLARE_CLASS(virDomainSnapshot); @@ -124,7 +126,7 @@ virGetConnect(void) if (virDataTypesInitialize() < 0) return NULL; =20 - return virObjectLockableNew(virConnectClass); + return virObjectRWLockableNew(virConnectClass); } =20 /** diff --git a/src/datatypes.h b/src/datatypes.h index 8a0399cd0..7076c2b8d 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -453,7 +453,7 @@ struct _virAdmConnectCloseCallbackData { * Internal structure associated to a connection */ struct _virConnect { - virObjectLockable object; + virObjectRWLockable object; =20 /* All the variables from here, until declared otherwise in one of * the following comments, are setup at time of connection open diff --git a/src/util/virerror.c b/src/util/virerror.c index ef17fb5e6..fead92d67 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -482,7 +482,7 @@ virConnCopyLastError(virConnectPtr conn, virErrorPtr to) =20 if (conn =3D=3D NULL) return -1; - virObjectLock(conn); + virObjectLockRead(conn); if (conn->err.code =3D=3D VIR_ERR_OK) virResetError(to); else --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list