You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/09/14 18:47:04 UTC
[tomcat] 01/02: Don't send an HTTP/2 ping when the connection is
known to be closing
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 58c072aecbe99a4025308f9e2e6be2b6cf0866ff
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 b4b6fda..0d72451 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -316,10 +316,15 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
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 ...
@@ -827,6 +832,10 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
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 895fa31..b840206 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -53,6 +53,14 @@
</update>
</changelog>
</subsection>
+ <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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org