tryGrabCapability should be using TRY_ACQUIRE_LOCK
authorSimon Marlow <marlowsd@gmail.com>
Thu, 15 Sep 2016 10:34:05 +0000 (11:34 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 15 Sep 2016 12:23:36 +0000 (13:23 +0100)
rts/Capability.c

index 6979c63..6ca34f8 100644 (file)
@@ -973,8 +973,10 @@ prodCapability (Capability *cap, Task *task)
 rtsBool
 tryGrabCapability (Capability *cap, Task *task)
 {
+    int r;
     if (cap->running_task != NULL) return rtsFalse;
-    ACQUIRE_LOCK(&cap->lock);
+    r = TRY_ACQUIRE_LOCK(&cap->lock);
+    if (r != 0) return rtsFalse;
     if (cap->running_task != NULL) {
         RELEASE_LOCK(&cap->lock);
         return rtsFalse;