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

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 77caf7ec15f0e381869349698531a30622c2ebe9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Sep 14 18:47:17 2020 +0100

    Don't send an HTTP/2 ping when the connection is known to be closing
---
 java/org/apache/coyote/http2/Http2UpgradeHandler.java | 13 +++++++++++--
 webapps/docs/changelog.xml                            |  8 ++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 7b95592..4bc31fb 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -312,10 +312,15 @@ public class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpU
         SocketState result = SocketState.CLOSED;
 
         try {
-            pingManager.sendPing(false);
-
             switch(status) {
             case OPEN_READ:
+                synchronized (socketWrapper) {
+                    if (!socketWrapper.canWrite()) {
+                        // Only send a ping if there is no other data waiting 
to be sent.
+                        // Ping manager will ensure they aren't sent too 
frequently.
+                        pingManager.sendPing(false);
+                    }
+                }
                 try {
                     // There is data to read so use the read timeout while
                     // reading frames ...
@@ -824,6 +829,10 @@ public class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpU
         synchronized (socketWrapper) {
             if (socketWrapper.flush(false)) {
                 socketWrapper.registerWriteInterest();
+            } else {
+                // Only send a ping if there is no other data waiting to be 
sent.
+                // Ping manager will ensure they aren't sent too frequently.
+                pingManager.sendPing(false);
             }
         }
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 19cef68..f17503e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -45,6 +45,14 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 8.5.59 (markt)" rtext="in development">
+  <subsection name="Coyote">
+    <changelog>
+      <fix>
+        Do not send an HTTP/2 PING frame to measure round-trip time when it is
+        known that the HTTP/2 connection is not in a good state. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Other">
     <changelog>
       <update>


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

Reply via email to