Revert "Don't lock the MVar closure on tryReadMVar"
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 4 Jul 2018 14:05:56 +0000 (17:05 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Wed, 4 Jul 2018 14:05:56 +0000 (17:05 +0300)
This reverts commit 6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223.

See discussion in D4905.

rts/PrimOps.cmm

index 058fe1e..6081fab 100644 (file)
@@ -1825,14 +1825,18 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ )
 
 stg_tryReadMVarzh ( P_ mvar, /* :: MVar a */ )
 {
-    W_ val;
+    W_ val, info, tso, q;
 
-    val = StgMVar_value(mvar);
+    LOCK_CLOSURE(mvar, info);
 
-    if (val == stg_END_TSO_QUEUE_closure) {
+    if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
+        unlockClosure(mvar, info);
         return (0, stg_NO_FINALIZER_closure);
     }
 
+    val = StgMVar_value(mvar);
+
+    unlockClosure(mvar, info);
     return (1, val);
 }