7011859: java/util/concurrent/Semaphore/RacingReleases.java failing

Reviewed-by: alanb, dholmes
This commit is contained in:
Doug Lea 2013-10-10 09:57:50 +01:00
parent 5c2cfd8db4
commit 2acaedb538
2 changed files with 8 additions and 4 deletions

View File

@ -489,7 +489,8 @@ public abstract class AbstractQueuedLongSynchronizer
/*
* 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 @@ public abstract class AbstractQueuedLongSynchronizer
* 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();

View File

@ -711,7 +711,8 @@ public abstract class AbstractQueuedSynchronizer
/*
* 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 @@ public abstract class AbstractQueuedSynchronizer
* 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();