From nobody Mon Feb 9 08:55:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1586527014; cv=none; d=zohomail.com; s=zohoarc; b=PPu17ODqjQIJ/FUNdAD5kZ/v01uc21f6NY2LmD5mdv7xBy4NOpr0wnl/lTFT9/GJzi8HqQugx4eqRspCm0MT0bGFVShjzct+bM4lvJMo6d710RVHCnJIXGwYpyqkr810A5gRKz+f0EWKvSt3q2SFIG11mU9eNakiZsUNyo8KbDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586527014; 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=hbESINIZ7qWJ583eMCgQEwxqf2ZZnorU6hScM/s3ghw=; b=oDnKJvF0a2txdu77bIROTl/41CBgtb/aAi5cKixk8HEzSe/XN7Vsi9cNe0dcMoCT48JZYogdikvLChjIS1yMjw0WNyiE7uqq837ngBja/tau+4d7t5/s5Cxw+2DiQhLwJRMjz7UdiSryU5fRy0idUBCalmAJRaqxhZ9SBOWNxew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1586527014473273.7863747759591; Fri, 10 Apr 2020 06:56:54 -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-463-v_R7On4uNwWDmCuwBEYHwg-1; Fri, 10 Apr 2020 09:56:50 -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 09D8718B5F82; Fri, 10 Apr 2020 13:56:44 +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 D1128272C4; Fri, 10 Apr 2020 13:56:43 +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 81CED180203B; Fri, 10 Apr 2020 13:56:43 +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 03ADuNd6023371 for ; Fri, 10 Apr 2020 09:56:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F873127513; Fri, 10 Apr 2020 13:56:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B288127518 for ; Fri, 10 Apr 2020 13:56:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 343A21019E0D for ; Fri, 10 Apr 2020 13:56:21 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-y3V1NmtmNaWDdMVXuLB5NA-1; Fri, 10 Apr 2020 09:56:19 -0400 Received: by mail-wm1-f67.google.com with SMTP id y24so2806037wma.4 for ; Fri, 10 Apr 2020 06:56:18 -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.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 06:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586527013; 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=hbESINIZ7qWJ583eMCgQEwxqf2ZZnorU6hScM/s3ghw=; b=ECI6l7tP4uyv/BuulrSuecIq1jNA3uxZTVjROpvcMAbZr7X8wvWrfocvWbVNR7hWzg8YvT vEQuRHta1L+QxttarYbO25pAwmo0Gp9knF7XXsv1coapdWmfwiX9onupQhWQMenJlE5yKv 47bQiH5/SDkKIE7rqVQQqhRQYc6uGlE= X-MC-Unique: v_R7On4uNwWDmCuwBEYHwg-1 X-MC-Unique: y3V1NmtmNaWDdMVXuLB5NA-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=xCDj5XZUnFpSQhUS+Y6ctpJwMJXCS0X4LE+i9i6IocA=; b=lYJG64Ommr2YSO+/Cv+TCLSo4KXK2JnE9vw7yjtrMum+L8W7v126jkGofugNjLJDJv s02J/Tt03uZdeAx3Of4gdFHGILHDfaxLQpib7dTeraDuGhX7uKufgUZNqiI2Vg8fUKug YFJWo7kZTzpFx5lA1ISEhhuhdJd05lVcqKmX7Nk8Kd2toIF3Z+ubXpzUV0z9aaQewGVl y8VpV7wl+5SWJpL9hpDbfl7YjB3s0fB9tejNzU+QlieISI8G87S0KKAuIAqlYGDIOEvU fADAThAEpqwNfztIUZ68pLia4MwNXsFx8Tdf1IZY6OnV7A7uWYPfLiNsYT0h6IpjTNo7 xrdA== X-Gm-Message-State: AGi0Pua8LI4Z95Rc0A2eW8CsPng1+e+mItnMz/TrPfBQmzmw/yOGrd3/ kCurnpEyBwiiNVLoflv40QznjaFjA/0= X-Google-Smtp-Source: APiQypKb/X5nzhiNtecMe6IAPN1MXZkCofBoz3SGrAkmDT0PnkyQ8HHyxyx70kz4Qgr3uR35Ri0gYw== X-Received: by 2002:a1c:7d4b:: with SMTP id y72mr5398292wmc.11.1586526977047; Fri, 10 Apr 2020 06:56:17 -0700 (PDT) From: Rafael Fonseca To: libvir-list@redhat.com Subject: [PATCH 38/43] nwfilter: nwfilter_learnipaddr: convert virMutex to GMutex Date: Fri, 10 Apr 2020 15:55:05 +0200 Message-Id: <20200410135510.2148319-39-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 03ADuNd6023371 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_learnipaddr.c | 43 +++++++++++++---------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 4ce8d5ba03..c46fbca40d 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -111,17 +111,17 @@ struct ether_vlan_header } ATTRIBUTE_PACKED; =20 =20 -static virMutex pendingLearnReqLock =3D VIR_MUTEX_INITIALIZER; +G_LOCK_DEFINE_STATIC(pendingLearnReqLock); static virHashTablePtr pendingLearnReq; =20 -static virMutex ifaceMapLock =3D VIR_MUTEX_INITIALIZER; +G_LOCK_DEFINE_STATIC(ifaceMapLock); static virHashTablePtr ifaceLockMap; =20 typedef struct _virNWFilterIfaceLock virNWFilterIfaceLock; typedef virNWFilterIfaceLock *virNWFilterIfaceLockPtr; struct _virNWFilterIfaceLock { char ifname[IF_NAMESIZE]; - virMutex lock; + GRecMutex lock; int refctr; }; =20 @@ -147,19 +147,14 @@ virNWFilterLockIface(const char *ifname) { virNWFilterIfaceLockPtr ifaceLock; =20 - virMutexLock(&ifaceMapLock); + G_LOCK(ifaceMapLock); =20 ifaceLock =3D virHashLookup(ifaceLockMap, ifname); if (!ifaceLock) { if (VIR_ALLOC(ifaceLock) < 0) goto err_exit; =20 - if (virMutexInitRecursive(&ifaceLock->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("mutex initialization failed")); - VIR_FREE(ifaceLock); - goto err_exit; - } + g_rec_mutex_init(&ifaceLock->lock); =20 if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -180,14 +175,14 @@ virNWFilterLockIface(const char *ifname) =20 ifaceLock->refctr++; =20 - virMutexUnlock(&ifaceMapLock); + G_UNLOCK(ifaceMapLock); =20 - virMutexLock(&ifaceLock->lock); + g_rec_mutex_lock(&ifaceLock->lock); =20 return 0; =20 err_exit: - virMutexUnlock(&ifaceMapLock); + G_UNLOCK(ifaceMapLock); =20 return -1; } @@ -198,19 +193,19 @@ virNWFilterUnlockIface(const char *ifname) { virNWFilterIfaceLockPtr ifaceLock; =20 - virMutexLock(&ifaceMapLock); + G_LOCK(ifaceMapLock); =20 ifaceLock =3D virHashLookup(ifaceLockMap, ifname); =20 if (ifaceLock) { - virMutexUnlock(&ifaceLock->lock); + g_rec_mutex_unlock(&ifaceLock->lock); =20 ifaceLock->refctr--; if (ifaceLock->refctr =3D=3D 0) virHashRemoveEntry(ifaceLockMap, ifname); } =20 - virMutexUnlock(&ifaceMapLock); + G_UNLOCK(ifaceMapLock); } =20 =20 @@ -234,12 +229,12 @@ virNWFilterRegisterLearnReq(virNWFilterIPAddrLearnReq= Ptr req) int res =3D -1; g_autofree char *ifindex_str =3D g_strdup_printf("%d", req->ifindex); =20 - virMutexLock(&pendingLearnReqLock); + G_LOCK(pendingLearnReqLock); =20 if (!virHashLookup(pendingLearnReq, ifindex_str)) res =3D virHashAddEntry(pendingLearnReq, ifindex_str, req); =20 - virMutexUnlock(&pendingLearnReqLock); + G_UNLOCK(pendingLearnReqLock); =20 return res; } @@ -270,7 +265,7 @@ virNWFilterTerminateLearnReq(const char *ifname) =20 ifindex_str =3D g_strdup_printf("%d", ifindex); =20 - virMutexLock(&pendingLearnReqLock); + G_LOCK(pendingLearnReqLock); =20 req =3D virHashLookup(pendingLearnReq, ifindex_str); if (req) { @@ -278,7 +273,7 @@ virNWFilterTerminateLearnReq(const char *ifname) req->terminate =3D true; } =20 - virMutexUnlock(&pendingLearnReqLock); + G_UNLOCK(pendingLearnReqLock); =20 return rc; } @@ -290,11 +285,11 @@ virNWFilterHasLearnReq(int ifindex) void *res; g_autofree char *ifindex_str =3D g_strdup_printf("%d", ifindex); =20 - virMutexLock(&pendingLearnReqLock); + G_LOCK(pendingLearnReqLock); =20 res =3D virHashLookup(pendingLearnReq, ifindex_str); =20 - virMutexUnlock(&pendingLearnReqLock); + G_UNLOCK(pendingLearnReqLock); =20 return res !=3D NULL; } @@ -315,11 +310,11 @@ virNWFilterDeregisterLearnReq(int ifindex) virNWFilterIPAddrLearnReqPtr res; g_autofree char *ifindex_str =3D g_strdup_printf("%d", ifindex); =20 - virMutexLock(&pendingLearnReqLock); + G_LOCK(pendingLearnReqLock); =20 res =3D virHashSteal(pendingLearnReq, ifindex_str); =20 - virMutexUnlock(&pendingLearnReqLock); + G_UNLOCK(pendingLearnReqLock); =20 return res; } --=20 2.25.2