Skip to content

Commit

Permalink
Clear waitFor earlier. Avoid multiple stream.notify() calls and timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jun 4, 2019
1 parent dacb1bc commit 1174ecc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions java/org/apache/coyote/http2/WindowAllocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ private void waitFor(int waitTarget, long timeout) throws InterruptedException {
} else {
stream.wait(timeout);
}

waitingFor = NONE;
}
}

Expand Down Expand Up @@ -163,6 +161,12 @@ private void notify(int notifyTarget) {

synchronized (stream) {
if ((notifyTarget & waitingFor) > NONE) {
// Reset this here so multiple notifies (possible with a
// backlog containing multiple streams and small window updates)
// are handled correctly (only the first should trigger a call
// to stream.notify(). Additional notify() calls may trigger
// unexpected timeouts.
waitingFor = NONE;
if (stream.getCoyoteResponse().getWriteListener() == null) {
// Blocking, so use notify to release StreamOutputBuffer
if (log.isDebugEnabled()) {
Expand All @@ -171,7 +175,6 @@ private void notify(int notifyTarget) {
}
stream.notify();
} else {
waitingFor = NONE;
// Non-blocking so dispatch
if (log.isDebugEnabled()) {
log.debug(sm.getString("windowAllocationManager.dispatched",
Expand Down

0 comments on commit 1174ecc

Please sign in to comment.