7011859: java/util/concurrent/Semaphore/RacingReleases.java failing
Reviewed-by: alanb, dholmes
--- 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();