Commits

Anonymous committed aad1902 Draft

fixed ReaderWriterLock timed Acquire bug

Comments (0)

Files changed (1)

Cineraria.Concurrency/ReaderWriterLock.cs

                 return false;
             }
 
+            bool acquired = this.ReadPermission.Acquire(milliseconds);
             this.Turnstile.Release();
-
-            // Don't have to attempt here because it is guaranteed that no
-            // other thread is attempting to acquire WritePermission.
-            this.ReadPermission.Acquire();
-            return true;
+            return acquired;
         }
 
         /// <summary>
                 return false;
             }
 
-            // Don't have to attempt here because it is guaranteed that no
-            // other thread is attempting to acquire WritePermission.
-            this.WritePermission.Acquire();
+            if (!this.WritePermission.Acquire(milliseconds))
+            {
+                this.Turnstile.Release();
+                return false;
+            }
+
             return true;
         }