[ofw] [patch][IPoIB_NDIS6_CM] Shutter patch #2

Alex Naslednikov xalex at mellanox.co.il
Mon Jan 31 05:46:36 PST 2011


Fix a bug in the shutter code.
Signed off by: Tzachi Dar (tzachid at mellanox.co.il),  Alexander Naslednikov (xalex at mellanox.co.il)
Index: B:/users/xalex/MLNX_VPI_trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_adapter.cpp
Index: inc/kernel/shutter.h
===================================================================
--- inc/kernel/shutter.h                (revision 3080)
+++ inc/kernel/shutter.h             (working copy)
@@ -61,16 +61,26 @@
 // if RC == true, one can proceed
 static inline BOOLEAN shutter_add(shutter_t * p_shutter,long Val)
 {
-    long res = 0;
+    long res = 0, int_res;
+
     ASSERT(Val > 0);
-              res = InterlockedExchangeAdd(&p_shutter->cnt,Val);
-              ASSERT(res <= MAX_OPERATIONS);
-              if (res < 0 )
-              {
-                              shutter_sub(p_shutter, -Val);
-                              return FALSE;
+
+             for(;;) {
+                             res = p_shutter->cnt;
+                             if (res < 0) {
+                                             return FALSE;
+                             }
+
+                             int_res = InterlockedCompareExchange(&p_shutter->cnt, res+Val, res );
+                             if (int_res == res) {
+                                             return TRUE;
+                             }
+                             if (int_res < 0) {
+                                             return FALSE;
+                             }
+
                }
-              return TRUE;
+
 }

 static inline void shutter_loose(shutter_t * p_shutter)
@@ -83,11 +93,10 @@
 // if RC > 0, one can proceed
 static inline int shutter_use(shutter_t * p_shutter)
 {
-              long res = InterlockedIncrement( &p_shutter->cnt );
-              ASSERT(res <= MAX_OPERATIONS);
-              if (res <= 0 )
-                              shutter_loose( p_shutter ); // The object is in shutdown
-              return res;
+             BOOLEAN ret = shutter_add(p_shutter, 1);
+             if (ret) return 1;
+             return -1;
+
 }

 Alexander (XaleX) Naslednikov
SW Networking Team
Mellanox Technologies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20110131/b7af4382/attachment.html>


More information about the ofw mailing list