From nobody Tue Feb 10 01:19:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644575539; cv=none; d=zohomail.com; s=zohoarc; b=IQlz68jobkOr/XfwKuvAhQuAc8aPCdSvrnGX4HTpu7Ubo8O0L1ofd19vHH8SnnRuDyUaCW9e43XPte5LTC2EFjlcHwUVJvhmq5yBhfbsd6qwRfEFbo+wOVObzbriQbywAZGmSngPHJLzPHWVnnFYJfIeclyXbL+3lVFphZzO3hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644575539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Asp6kNCoxIfQlmGLK5P2I9yJGCpGArw9g5G03FXvXg4=; b=D99YRsPM0F0vuGh7ggsR84hvsOpixw49FUJcYTJ4WaQbUpEBCLqpV8YxXbwOQzetVcLpJgmSwYY4k81sfrdHnWiLGXNVkmcxbcSjdIf+oGhj5KiZmWm+ChZ9O96COolxegvalii3ubYvklL0J0HubS1ffiqlXR6dPo2Ua5/pchM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 164457553978538.13987766744253; Fri, 11 Feb 2022 02:32:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-wehZ_LzONw6fXMqUVPe-dw-1; Fri, 11 Feb 2022 05:32:15 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C80A28ED51; Fri, 11 Feb 2022 10:31:00 +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 812F06C1A6; Fri, 11 Feb 2022 10:31:00 +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 4C0194BB7C; Fri, 11 Feb 2022 10:31:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21BAUpoA031719 for ; Fri, 11 Feb 2022 05:30:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id BDB957C0DA; Fri, 11 Feb 2022 10:30:51 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5A1E7BB4A; Fri, 11 Feb 2022 10:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644575538; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Asp6kNCoxIfQlmGLK5P2I9yJGCpGArw9g5G03FXvXg4=; b=W/6xXeO/mZ7tLExvJPiqbjl40Arg78DYUb6YmXDq4GGEW46kRinDKxupp6sYglyIjKyTDs RT0DWKPJvJ3QvYugZkrfiBTxFsfxwaB0Twq2c9PDnSUd9kbEcuL+aSQsa8bXLxw6+Owmu2 /+HbzJxjVcAMA2Pc3y2qpAmXjtdUVIo= X-MC-Unique: wehZ_LzONw6fXMqUVPe-dw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] secret: Factor out mutex Date: Fri, 11 Feb 2022 11:30:39 +0100 Message-Id: <20220211103046.34651-4-twiederh@redhat.com> In-Reply-To: <20220211103046.34651-1-twiederh@redhat.com> References: <20220211103046.34651-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644575540339100001 Content-Type: text/plain; charset="utf-8" If the mutex is part of the `driver` object, it cannot guard that object's creation and destruction perfectly. Signed-off-by: Tim Wiederhake --- src/secret/secret_driver.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 0220f394ef..d0e819809b 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -52,9 +52,10 @@ enum { SECRET_MAX_XML_FILE =3D 10*1024*1024 }; =20 /* Internal driver state */ =20 +static virMutex mutex =3D VIR_MUTEX_INITIALIZER; + typedef struct _virSecretDriverState virSecretDriverState; struct _virSecretDriverState { - virMutex lock; bool privileged; /* readonly */ char *embeddedRoot; /* readonly */ int embeddedRefs; @@ -74,14 +75,14 @@ static virSecretDriverState *driver; static void secretDriverLock(void) { - virMutexLock(&driver->lock); + virMutexLock(&mutex); } =20 =20 static void secretDriverUnlock(void) { - virMutexUnlock(&driver->lock); + virMutexUnlock(&mutex); } =20 =20 @@ -463,7 +464,6 @@ secretStateCleanup(void) =20 VIR_FREE(driver->stateDir); secretDriverUnlock(); - virMutexDestroy(&driver->lock); VIR_FREE(driver); =20 return 0; @@ -479,10 +479,6 @@ secretStateInitialize(bool privileged, driver =3D g_new0(virSecretDriverState, 1); =20 driver->lockFD =3D -1; - if (virMutexInit(&driver->lock) < 0) { - VIR_FREE(driver); - return VIR_DRV_STATE_INIT_ERROR; - } secretDriverLock(); =20 driver->secretEventState =3D virObjectEventStateNew(); --=20 2.31.1