diff mbox

[ovs-dev,38/40] datapath-windows: Fix shared variables which use Interlocked functions

Message ID 20170714044033.15196-39-aserdean@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Alin Serdean July 14, 2017, 4:40 a.m. UTC
Instead of assigning a value directly to the variable use `InterlockedAdd`
with 0.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
 datapath-windows/ovsext/Switch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

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,