Author: markt Date: Wed Oct 7 21:39:19 2015 New Revision: 1707398 URL: http://svn.apache.org/viewvc?rev=1707398&view=rev Log: Fix Gump reported test failure in 5_3. If a stream isn't fully allocated keep it in the backlog so if a window update arrives while the stream is writing it will still get an allocation.
Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1707398&r1=1707397&r2=1707398&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Wed Oct 7 21:39:19 2015 @@ -570,11 +570,8 @@ public class Http2UpgradeHandler extends long windowSize = getWindowSize(); if (windowSize < 1 || backLogSize > 0) { // Has this stream been granted an allocation - int[] value = backLogStreams.remove(stream); - if (value != null && value[1] > 0) { - allocation = value[1]; - decrementWindowSize(allocation); - } else { + int[] value = backLogStreams.get(stream); + if (value == null) { value = new int[] { reservation, 0 }; backLogStreams.put(stream, value); backLogSize += reservation; @@ -583,6 +580,23 @@ public class Http2UpgradeHandler extends while (parent != null && backLogStreams.putIfAbsent(parent, new int[2]) == null) { parent = parent.getParentStream(); } + } else { + if (value[1] > 0) { + allocation = value[1]; + decrementWindowSize(allocation); + if (value[0] == 0) { + // The reservation has been fully allocated + // so this stream can be removed from the + // backlog. + backLogStreams.remove(stream); + } else { + // This allocation has been used. Reset the + // allocation to zero. Leave the stream on + // the backlog as it still has more bytes to + // write. + value[1] = 0; + } + } } } else if (windowSize < reservation) { allocation = (int) windowSize; @@ -612,7 +626,7 @@ public class Http2UpgradeHandler extends protected synchronized void incrementWindowSize(int increment) throws Http2Exception { long windowSize = getWindowSize(); if (windowSize < 1 && windowSize + increment > 0) { - releaseBackLog(increment); + releaseBackLog((int) (windowSize +increment)); } super.incrementWindowSize(increment); } @@ -662,7 +676,7 @@ public class Http2UpgradeHandler extends int[] value = backLogStreams.get(stream); if (value[0] >= allocation) { value[0] -= allocation; - value[1] = allocation; + value[1] += allocation; return 0; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org