- 43479: Memory leak cleaning up sendfile connections (submitted by the bug reporter).
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Oct 2007 00:29:00 +0000 (00:29 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Oct 2007 00:29:00 +0000 (00:29 +0000)
- 42925: No timeout for sendfile (fix TODO item that had been forgotten).

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@583650 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/STATUS b/STATUS
index e1c7a8b..9ea00d8 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -30,16 +30,6 @@ PATCHES PROPOSED TO BACKPORT:
   +1: remm, pero, funkman
   -1: 
 
-* 43479: Memory leak cleaning up sendfile connections (submitted by the bug reporter)
-  http://issues.apache.org/bugzilla/attachment.cgi?id=20883
-  +1: remm, pero, funkman
-  -1: 
-
-* 42925: No timeout for sendfile
-  http://issues.apache.org/bugzilla/attachment.cgi?id=20930
-  +1: remm, pero, funkman
-  -1: 
-
 * Use newer eclipse jdt - old location is gone (reported by Jason Britian via email)
   update to jdt.loc=http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.3.1-200709211145/eclipse-JDT-3.3.1.zip
   +1: pero, funkman, remm
@@ -47,9 +37,9 @@ PATCHES PROPOSED TO BACKPORT:
 
 * Call StopAwait at StandardServer.stop as port==-1
   +1: pero
-  -1: 
+  -1: remm (would like clarification on the sleep value, currently 100s)
 
 * Arrange doc of connectors.
   http://people.apache.org/~jfclere/patches/tc.docs.patch
-  +1: jfclere
+  +1: jfclere, remm
   -1:
index 4e0161b..cebe158 100644 (file)
@@ -1695,7 +1695,7 @@ public class AprEndpoint {
             if (rv == Status.APR_SUCCESS) {
                 sendfileCount--;
             }
-            sendfileData.remove(data);
+            sendfileData.remove(new Long(data.socket));
         }
 
         /**
@@ -1704,6 +1704,7 @@ public class AprEndpoint {
          */
         public void run() {
 
+            long maintainTime = 0;
             // Loop until we receive a shutdown command
             while (running) {
 
@@ -1717,6 +1718,8 @@ public class AprEndpoint {
                 }
 
                 while (sendfileCount < 1 && addS.size() < 1) {
+                    // Reset maintain time.
+                    maintainTime = 0;
                     try {
                         synchronized (this) {
                             this.wait();
@@ -1745,6 +1748,8 @@ public class AprEndpoint {
                             addS.clear();
                         }
                     }
+
+                    maintainTime += pollTime;
                     // Pool for the specified interval
                     int rv = Poll.poll(sendfilePollset, pollTime, desc, false);
                     if (rv > 0) {
@@ -1810,7 +1815,22 @@ public class AprEndpoint {
                             continue;
                         }
                     }
-                    /* TODO: See if we need to call the maintain for sendfile poller */
+                    // Call maintain for the sendfile poller
+                    if (soTimeout > 0 && maintainTime > 1000000L && running) {
+                        rv = Poll.maintain(sendfilePollset, desc, true);
+                        maintainTime = 0;
+                        if (rv > 0) {
+                            for (int n = 0; n < rv; n++) {
+                                // Get the sendfile state
+                                SendfileData state = sendfileData.get(new Long(desc[n]));
+                                // Close socket and clear pool
+                                remove(state);
+                                // Destroy file descriptor pool, which should close the file
+                                // Close the socket, as the response would be incomplete
+                                Socket.destroy(state.socket);
+                            }
+                        }
+                    }
                 } catch (Throwable t) {
                     log.error(sm.getString("endpoint.poll.error"), t);
                 }
index 6dd2c12..cc35143 100644 (file)
       <update>
         Cookie parser refactoring, submitted by John Kew. (remm)
       </update>
+      <fix>
+        <bug>43479</bug>: Memory leak cleaning up sendfile connections, submitted by Chris Elving. (remm)
+      </fix>
+      <fix>
+        <bug>42925</bug>: Add maintain for sendfile. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">