From 16a57bc885e212839f1d717b94b01d154a36943a Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Georgieva Date: Tue, 29 Nov 2016 08:38:39 +0000 Subject: [PATCH] Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=60409 When unable to complete sendfile request, ensure the Processor will be added to the cache only once. Patch by markt. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.5.x/trunk@1771857 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/net/NioEndpoint.java | 5 ----- test/org/apache/catalina/connector/TestSendFile.java | 2 -- webapps/docs/changelog.xml | 4 ++++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index e2e23ea18331..34e8a69d4798 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -888,7 +888,6 @@ public SendfileState processSendfile(SelectionKey sk, NioSocketWrapper socketWra // Setup the file channel File f = new File(sd.fileName); if (!f.exists()) { - cancelledKey(sk); return SendfileState.ERROR; } @SuppressWarnings("resource") // Closed when channel is closed @@ -962,16 +961,12 @@ public SendfileState processSendfile(SelectionKey sk, NioSocketWrapper socketWra if (log.isDebugEnabled()) log.debug("Unable to complete sendfile request:", x); if (!calledByProcessor && sc != null) { close(sc, sk); - } else { - cancelledKey(sk); } return SendfileState.ERROR; } catch (Throwable t) { log.error("", t); if (!calledByProcessor && sc != null) { close(sc, sk); - } else { - cancelledKey(sk); } return SendfileState.ERROR; } diff --git a/test/org/apache/catalina/connector/TestSendFile.java b/test/org/apache/catalina/connector/TestSendFile.java index e7c74d10032c..47b32092393b 100644 --- a/test/org/apache/catalina/connector/TestSendFile.java +++ b/test/org/apache/catalina/connector/TestSendFile.java @@ -39,7 +39,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.junit.Ignore; import org.junit.Test; import org.apache.catalina.Context; @@ -157,7 +156,6 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) } - @Ignore @Test public void testBug60409() throws Exception { Tomcat tomcat = getTomcatInstance(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 56efa99fb097..ccfb524d212a 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -140,6 +140,10 @@ removing closed streams from the priority tree to ensure that the tree does not grow too large. (markt) + + 60409: When unable to complete sendfile request, ensure the + Processor will be added to the cache only once. (markt/violetagg) +