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 2019/10/02 13:06:43 UTC
[tomcat] branch master updated: Fix memory leak with HTTP/2 and
WebSocket
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
The following commit(s) were added to refs/heads/master by this push:
new 069be70 Fix memory leak with HTTP/2 and WebSocket
069be70 is described below
commit 069be707125fa4391dd6221e36c710d8bc8e3963
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Oct 2 12:19:44 2019 +0100
Fix memory leak with HTTP/2 and WebSocket
---
java/org/apache/coyote/AbstractProtocol.java | 23 ++++++++++++++++------
.../http11/upgrade/UpgradeProcessorInternal.java | 5 +++++
webapps/docs/changelog.xml | 4 ++++
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java
index 9753447..748be34 100644
--- a/java/org/apache/coyote/AbstractProtocol.java
+++ b/java/org/apache/coyote/AbstractProtocol.java
@@ -40,6 +40,7 @@ import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.WebConnection;
import org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler;
+import org.apache.coyote.http11.upgrade.UpgradeProcessorInternal;
import org.apache.juli.logging.Log;
import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.util.ExceptionUtils;
@@ -1053,12 +1054,22 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler,
private void release(Processor processor) {
if (processor != null) {
processor.recycle();
- // After recycling, only instances of UpgradeProcessorBase will
- // return true for isUpgrade().
- // Instances of UpgradeProcessorBase should not be added to
- // recycledProcessors since that pool is only for AJP or HTTP
- // processors
- if (!processor.isUpgrade()) {
+ if (processor.isUpgrade()) {
+ // UpgradeProcessorInternal instances can utilise AsyncIO.
+ // If they do, the processor will not pass through the
+ // process() method and be removed from waitingProcessors
+ // so do that here.
+ if (processor instanceof UpgradeProcessorInternal) {
+ if (((UpgradeProcessorInternal) processor).hasAsyncIO()) {
+ getProtocol().removeWaitingProcessor(processor);
+ }
+ }
+ } else {
+ // After recycling, only instances of UpgradeProcessorBase
+ // will return true for isUpgrade().
+ // Instances of UpgradeProcessorBase should not be added to
+ // recycledProcessors since that pool is only for AJP or
+ // HTTP processors
recycledProcessors.push(processor);
getLog().debug("Pushed Processor [" + processor + "]");
}
diff --git a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
index f0f5460..0e99265 100644
--- a/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
+++ b/java/org/apache/coyote/http11/upgrade/UpgradeProcessorInternal.java
@@ -79,6 +79,11 @@ public class UpgradeProcessorInternal extends UpgradeProcessorBase {
}
+ public boolean hasAsyncIO() {
+ return internalHttpUpgradeHandler.hasAsyncIO();
+ }
+
+
// --------------------------------------------------- AutoCloseable methods
@Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b3093a2..4ed78e0 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -69,6 +69,10 @@
an HTTP upgrade connection that terminates before processing switches to
the Processor for the upgraded protocol. (markt)
</fix>
+ <fix>
+ Fix a memory leak introduced by the HTTP/2 timeout refactoring in 9.0.23
+ that could occur when HTTP/2 or WebSocket was used. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org