From nobody Mon Feb 9 08:55:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1586526991; cv=none; d=zohomail.com; s=zohoarc; b=Oq8UqsM1KnVX5p63iU+lkfgBMynZ3qzZKUq/WveKuhBIGlyKTiuW4AfTBW/AXjgafx4w3g+ef3CfGQiWKpKQdGdsW8eLDKRfyzr4ygzfTrzNpz6dSVxYHTPAxBprGQ1fKLyz+BetscY5Abnxr/ZEcgg+K7/f8+v9a9x6bUR8B9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586526991; 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=Lm/fsL20zepyvWyq3dzIuiowBGEW55+4Rm52Y2g81EI=; b=YFeLiCj3M71cFo5A/oJX7Odc9twbODSSN4K3i20Kr8/nN0d92SZHz3n10a+2h/r5V1ScVbBYKl9aQB4H21WktjyaSyli8TTOkEge+75lw2yQXo2S6QyaQL0pDkKAxFsXmxQ7cCSvCZWhJzRjJpdNeCq+bFEDJbycuZW1brU80Ck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15865269919361004.7852767210849; Fri, 10 Apr 2020 06:56:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-fygKr3DFMUi48xmTlCpcsQ-1; Fri, 10 Apr 2020 09:56:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B0A28018B4; Fri, 10 Apr 2020 13:56:21 +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 E3B90272A5; Fri, 10 Apr 2020 13:56:20 +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 9228D93091; Fri, 10 Apr 2020 13:56:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03ADtwd1023093 for ; Fri, 10 Apr 2020 09:55:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0796127512; Fri, 10 Apr 2020 13:55:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCD4F12750F for ; Fri, 10 Apr 2020 13:55:58 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD2A08FF67D for ; Fri, 10 Apr 2020 13:55:58 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-FZhjcaaQMhSIb2OJeL2CoA-1; Fri, 10 Apr 2020 09:55:51 -0400 Received: by mail-wr1-f67.google.com with SMTP id p10so2382170wrt.6 for ; Fri, 10 Apr 2020 06:55:51 -0700 (PDT) Received: from localhost.localdomain (public-gprs377075.centertel.pl. [37.47.104.52]) by smtp.gmail.com with ESMTPSA id c11sm3066319wrt.24.2020.04.10.06.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 06:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586526990; 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=Lm/fsL20zepyvWyq3dzIuiowBGEW55+4Rm52Y2g81EI=; b=eN4+hwoH4N3Nj0zDCvrPetWlIHOfv3vC11RZQuL/k5KSs2QugEy3XUuh1QUFiADzdkvVPG Pwdv6fZpJT52UMNoQCL4r8pRmLgdRdJbbz0CbUnXNCAfEoiRfWBWHFcNj8Mn3Cxe1vzEuk 0R1ImQTxrRjuEMbEE+i8vfWw3U6xdbQ= X-MC-Unique: fygKr3DFMUi48xmTlCpcsQ-1 X-MC-Unique: FZhjcaaQMhSIb2OJeL2CoA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6z+Ua2XzysMGFmvpL1wEJ44ndDGR7OLAfopTfBb85Pg=; b=phSCgscuRUQIfKHJRQSJveXLKQk3WuUL+v2l0EYimd0P/G8Z9bP5zQLsxieKkh+aar zkZ+Ng+qLmkmcf8ruJAJgDrhFVY8phGiMfKXWjGW2N8Su1ZIf/jb/WDY1+UQuaIdCsrh R7K+peakK01y1bYhA5b2Oi4xnJYLcGoJixcojHOHnePkTbwQ/GOqCc5M6Hu+2lKPSd5V wOGkggMDkoHrU+w3G+T3Qk8EFkwppde7hh0j4PQ3Xruk+33KGDrMmyoSiwsBYY0lBby+ uzz3ASsaNR/XTgU9w+T/1IdaQNObkbzV0aaSSFcIXVekBwIPHG2h76dRxZXYIEl0q0MH fCjA== X-Gm-Message-State: AGi0PuY/BuFQAJwTJeQFLcX4IVWIu4YYPv/tLOPgvvrKVOcEoTtz11Ev FkvW2IY0bm50XF5lHa71Dv68aycIprY= X-Google-Smtp-Source: APiQypIppB3746FOJPOxe9ZHQABE8eVsB3ZCJvZUx2sUWMm+eakI+YfkKPGGGdOFa+VpdmRrqC5OqA== X-Received: by 2002:a5d:6850:: with SMTP id o16mr4574851wrw.309.1586526950257; Fri, 10 Apr 2020 06:55:50 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH 17/43] nwfilter: nwfilter_gentech_driver: convert virMutex to GRecMutex Date: Fri, 10 Apr 2020 15:54:44 +0200 Message-Id: <20200410135510.2148319-18-r4f4rfs@gmail.com> In-Reply-To: <20200410135510.2148319-1-r4f4rfs@gmail.com> References: <20200410135510.2148319-1-r4f4rfs@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03ADtwd1023093 X-loop: libvir-list@redhat.com Cc: Rafael Fonseca 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Rafael Fonseca --- src/nwfilter/nwfilter_gentech_driver.c | 38 ++++++++------------------ 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 4b369e5b1a..fd98d7f07e 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -69,14 +69,12 @@ static virNWFilterTechDriverPtr filter_tech_drivers[] = =3D { * hash table as is done for virDomainObjList. You can then get * lockless lookup of objects by name. */ -static virMutex updateMutex; +static GRecMutex updateMutex; =20 int virNWFilterTechDriversInit(bool privileged) { size_t i =3D 0; VIR_DEBUG("Initializing NWFilter technology drivers"); - if (virMutexInitRecursive(&updateMutex) < 0) - return -1; =20 while (filter_tech_drivers[i]) { if (!(filter_tech_drivers[i]->flags & TECHDRV_FLAG_INITIALIZED)) @@ -95,7 +93,6 @@ void virNWFilterTechDriversShutdown(void) filter_tech_drivers[i]->shutdown(); i++; } - virMutexDestroy(&updateMutex); } =20 =20 @@ -753,9 +750,7 @@ virNWFilterInstantiateFilterInternal(virNWFilterDriverS= tatePtr driver, bool *foundNewFilter) { int ifindex; - int rc; - - virMutexLock(&updateMutex); + g_autoptr(GRecMutexLocker) locker =3D g_rec_mutex_locker_new(&updateMu= tex); =20 /* after grabbing the filter update lock check for the interface; if it's not there anymore its filters will be or are being removed @@ -765,20 +760,14 @@ virNWFilterInstantiateFilterInternal(virNWFilterDrive= rStatePtr driver, /* interfaces / VMs can disappear during filter instantiation; don't mark it as an error */ virResetLastError(); - rc =3D 0; - goto cleanup; + return 0; } =20 - rc =3D virNWFilterInstantiateFilterUpdate(driver, teardownOld, - binding, - ifindex, - useNewFilter, - false, foundNewFilter); - - cleanup: - virMutexUnlock(&updateMutex); - - return rc; + return virNWFilterInstantiateFilterUpdate(driver, teardownOld, + binding, + ifindex, + useNewFilter, + false, foundNewFilter); } =20 =20 @@ -789,9 +778,10 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverStat= ePtr driver, { int rc; bool foundNewFilter =3D false; + g_autoptr(GRecMutexLocker) locker =3D NULL; =20 virNWFilterReadLockFilterUpdates(); - virMutexLock(&updateMutex); + locker =3D g_rec_mutex_locker_new(&updateMutex); =20 rc =3D virNWFilterInstantiateFilterUpdate(driver, true, binding, ifindex, @@ -808,7 +798,6 @@ virNWFilterInstantiateFilterLate(virNWFilterDriverState= Ptr driver, } =20 virNWFilterReadUnlockFilterUpdates(); - virMutexUnlock(&updateMutex); =20 return rc; } @@ -930,11 +919,8 @@ _virNWFilterTeardownFilter(const char *ifname) int virNWFilterTeardownFilter(virNWFilterBindingDefPtr binding) { - int ret; - virMutexLock(&updateMutex); - ret =3D _virNWFilterTeardownFilter(binding->portdevname); - virMutexUnlock(&updateMutex); - return ret; + g_autoptr(GRecMutexLocker) locker =3D g_rec_mutex_locker_new(&updateMu= tex); + return _virNWFilterTeardownFilter(binding->portdevname); } =20 enum { --=20 2.25.2