From patchwork Fri Jul 14 04:40:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alin Serdean X-Patchwork-Id: 788105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x80s31rCfz9s7m for ; Fri, 14 Jul 2017 15:01:27 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 42FF9D25; Fri, 14 Jul 2017 04:42:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D07B4D05 for ; Fri, 14 Jul 2017 04:42:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.cloudbasesolutions.com (mail.cloudbasesolutions.com [91.232.152.5]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 684883CE for ; Fri, 14 Jul 2017 04:42:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id 379D143356 for ; Fri, 14 Jul 2017 07:41:59 +0300 (EEST) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from mail.cloudbasesolutions.com ([127.0.0.1]) by localhost (mail.cloudbasesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MiTfI-X_vywZ for ; Fri, 14 Jul 2017 07:41:59 +0300 (EEST) Received: from mail.cloudbasesolutions.com (unknown [10.77.78.3]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id 5D10143490 for ; Fri, 14 Jul 2017 07:41:58 +0300 (EEST) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0361.001; Fri, 14 Jul 2017 06:41:58 +0200 From: Alin Serdean To: "dev@openvswitch.org" Thread-Topic: [PATCH 38/40] datapath-windows: Fix shared variables which use Interlocked functions Thread-Index: AQHS/FtjRXYQdCx0sk2Mn8qIL/6uxA== Date: Fri, 14 Jul 2017 04:40:58 +0000 Message-ID: <20170714044033.15196-39-aserdean@cloudbasesolutions.com> References: <20170714044033.15196-1-aserdean@cloudbasesolutions.com> In-Reply-To: <20170714044033.15196-1-aserdean@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 38/40] datapath-windows: Fix shared variables which use Interlocked functions X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Instead of assigning a value directly to the variable use `InterlockedAdd` with 0. Signed-off-by: Alin Gabriel Serdean --- datapath-windows/ovsext/Switch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c index 28c8ecf..1ac4fa7 100644 --- a/datapath-windows/ovsext/Switch.c +++ b/datapath-windows/ovsext/Switch.c @@ -143,7 +143,7 @@ OvsExtAttach(NDIS_HANDLE ndisFilterHandle, KeMemoryBarrier(); cleanup: - gOvsInAttach = FALSE; + InterlockedExchange(&gOvsInAttach, 0); if (status != NDIS_STATUS_SUCCESS) { if (switchContext != NULL) { OvsDeleteSwitch(switchContext); @@ -516,7 +516,7 @@ OvsReleaseSwitchContext(POVS_SWITCH_CONTEXT switchContext) LONG icxRef = 0; do { - ref = gOvsSwitchContextRefCount; + ref = InterlockedAdd(&gOvsSwitchContextRefCount, 0); newRef = (0 == ref) ? 0 : ref - 1; icxRef = InterlockedCompareExchange(&gOvsSwitchContextRefCount, newRef, @@ -538,7 +538,7 @@ OvsAcquireSwitchContext(VOID) BOOLEAN ret = FALSE; do { - ref = gOvsSwitchContextRefCount; + ref = InterlockedAdd(&gOvsSwitchContextRefCount, 0); newRef = (0 == ref) ? 0 : ref + 1; icxRef = InterlockedCompareExchange(&gOvsSwitchContextRefCount, newRef,