Author: markt
Date: Fri Jun 12 16:41:30 2015
New Revision: 1685126

URL: http://svn.apache.org/r1685126
Log:
Fix an edge case bug
- Window size may go negative due to handling of rounding errors

Fix a nasty type s/=-/-=/ that was causing strange allocation effects

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
    tomcat/trunk/java/org/apache/coyote/http2/Stream.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=1685126&r1=1685125&r2=1685126&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Fri Jun 
12 16:41:30 2015
@@ -540,7 +540,7 @@ public class Http2UpgradeHandler extends
     @Override
     protected void incrementWindowSize(int increment) throws Http2Exception {
         synchronized (backLogLock) {
-            if (getWindowSize() == 0) {
+            if (getWindowSize() < 1) {
                 releaseBackLog(increment);
             }
             super.incrementWindowSize(increment);
@@ -566,7 +566,7 @@ public class Http2UpgradeHandler extends
             for (Entry<AbstractStream,int[]> entry : 
backLogStreams.entrySet()) {
                 int allocation = entry.getValue()[1];
                 if (allocation > 0) {
-                    backLogSize =- allocation;
+                    backLogSize -= allocation;
                     synchronized (entry.getKey()) {
                         entry.getKey().notifyAll();
                     }

Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Stream.java?rev=1685126&r1=1685125&r2=1685126&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Fri Jun 12 16:41:30 
2015
@@ -134,7 +134,7 @@ public class Stream extends AbstractStre
     }
 
 
-    private int reserveWindowSize(int reservation) {
+    private int checkWindowSize(int reservation) {
         long windowSize = getWindowSize();
         if (reservation > windowSize) {
             return (int) windowSize;
@@ -318,7 +318,7 @@ public class Stream extends AbstractStre
             while (left > 0) {
                 // Flow control for the Stream
                 do {
-                    thisWriteStream = reserveWindowSize(left);
+                    thisWriteStream = checkWindowSize(left);
                     if (thisWriteStream < 1) {
                         // Need to block until a WindowUpdate message is
                         // processed for this stream
@@ -349,6 +349,9 @@ public class Stream extends AbstractStre
                     }
                 } while (thisWrite < 1);
 
+                // Stream.checkWindowSize() doesn't reduce the flow control
+                // window (reserveWindowSize() does) so the Stream's window
+                // needs to be reduced here.
                 decrementWindowSize(thisWrite);
 
                 // Do the write



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to