7011859: java/util/concurrent/Semaphore/RacingReleases.java failing
authordl
Thu, 10 Oct 2013 09:57:50 +0100
changeset 20766 d94cb38041e6
parent 20765 43ac7ab49d5a
child 20767 58e09973dcc1
7011859: java/util/concurrent/Semaphore/RacingReleases.java failing Reviewed-by: alanb, dholmes
jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
--- a/jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Thu Oct 10 04:57:29 2013 -0400
+++ b/jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Thu Oct 10 09:57:50 2013 +0100
@@ -489,7 +489,8 @@
         /*
          * Try to signal next queued node if:
          *   Propagation was indicated by caller,
-         *     or was recorded (as h.waitStatus) by a previous operation
+         *     or was recorded (as h.waitStatus either before
+         *     or after setHead) by a previous operation
          *     (note: this uses sign-check of waitStatus because
          *      PROPAGATE status may transition to SIGNAL.)
          * and
@@ -501,7 +502,8 @@
          * racing acquires/releases, so most need signals now or soon
          * anyway.
          */
-        if (propagate > 0 || h == null || h.waitStatus < 0) {
+        if (propagate > 0 || h == null || h.waitStatus < 0 ||
+            (h = head) == null || h.waitStatus < 0) {
             Node s = node.next;
             if (s == null || s.isShared())
                 doReleaseShared();
--- a/jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Thu Oct 10 04:57:29 2013 -0400
+++ b/jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Thu Oct 10 09:57:50 2013 +0100
@@ -711,7 +711,8 @@
         /*
          * Try to signal next queued node if:
          *   Propagation was indicated by caller,
-         *     or was recorded (as h.waitStatus) by a previous operation
+         *     or was recorded (as h.waitStatus either before
+         *     or after setHead) by a previous operation
          *     (note: this uses sign-check of waitStatus because
          *      PROPAGATE status may transition to SIGNAL.)
          * and
@@ -723,7 +724,8 @@
          * racing acquires/releases, so most need signals now or soon
          * anyway.
          */
-        if (propagate > 0 || h == null || h.waitStatus < 0) {
+        if (propagate > 0 || h == null || h.waitStatus < 0 ||
+            (h = head) == null || h.waitStatus < 0) {
             Node s = node.next;
             if (s == null || s.isShared())
                 doReleaseShared();