This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 6232d82  Make sure timeout elapses before calling a timeout
6232d82 is described below

commit 6232d82cc5db73e5da5392d6ec6d9d01ce65c85e
Author: remm <r...@apache.org>
AuthorDate: Sun May 5 10:37:05 2019 +0200

    Make sure timeout elapses before calling a timeout
    
    It seems there are extra stream notify as although 0 bytes have been
    allocated only a few ms have passed when there is a failure.
---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 65c9fe6..97644c4 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -752,6 +752,7 @@ class Http2UpgradeHandler extends AbstractStream implements 
InternalHttpUpgradeH
         // this thread until after this thread enters wait()
         int allocation = 0;
         synchronized (stream) {
+            long writeTimeout = protocol.getWriteTimeout();
             do {
                 synchronized (this) {
                     if (!stream.canWrite()) {
@@ -804,17 +805,18 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
                             // Connection level window is empty. Although this
                             // request is for a stream, use the connection
                             // timeout
-                            long writeTimeout = protocol.getWriteTimeout();
                             if (writeTimeout < 0) {
                                 stream.wait();
                             } else {
+                                long t1 = System.currentTimeMillis();
                                 stream.wait(writeTimeout);
+                                writeTimeout -= (System.currentTimeMillis() - 
t1);
                             }
                             // Has this stream been granted an allocation
                             // Note: If the stream in not in this Map then the
                             //       requested write has been fully allocated
                             int[] value = backLogStreams.get(stream);
-                            if (value != null && value[1] == 0) {
+                            if (writeTimeout <= 0 && value != null && value[1] 
== 0) {
                                 if (log.isDebugEnabled()) {
                                     
log.debug(sm.getString("upgradeHandler.noAllocation",
                                             connectionId));


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to