Improve error handling for APR connector if sendfile fails
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Jul 2011 17:12:42 +0000 (17:12 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Jul 2011 17:12:42 +0000 (17:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1151930 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AprEndpoint.java
webapps/docs/changelog.xml

index 024a08e..4bc9a9a 100644 (file)
@@ -1448,6 +1448,13 @@ public class AprEndpoint extends AbstractEndpoint {
             // Initialize fd from data given
             try {
                 data.fdpool = Socket.pool(data.socket);
+            } catch (Exception e) {
+                // Pool not created so no need to destroy it.
+                log.error(sm.getString("endpoint.sendfile.error"), e);
+                data.socket = 0;
+                return false;
+            }
+            try {
                 data.fd = File.open
                     (data.fileName, File.APR_FOPEN_READ
                      | File.APR_FOPEN_SENDFILE_ENABLED | File.APR_FOPEN_BINARY,
@@ -1482,6 +1489,8 @@ public class AprEndpoint extends AbstractEndpoint {
                 }
             } catch (Exception e) {
                 log.error(sm.getString("endpoint.sendfile.error"), e);
+                Pool.destroy(data.fdpool);
+                data.socket = 0;
                 return false;
             }
             // Add socket to the list. Newly added sockets will wait
index 788f850..2a36164 100644 (file)
         <bug>51557</bug>: Ignore HTTP headers that do not comply with RFC 2616
         and use header names that are not tokens. (markt)
       </fix>
+      <add>
+        Improve error handling for HTTP APR if an error occurs while using
+        sendfile. (markt) 
+      </add>
     </changelog>
   </subsection>
   <subsection name="Jasper">