Author: remy.maucherat(a)jboss.com
Date: 2008-10-31 10:37:01 -0400 (Fri, 31 Oct 2008)
New Revision: 834
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/webapps/docs/changelog.xml
Log:
- Redo maintain in a simpler way, as trying to call maintain only when needed cannot
possibly work.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-10-31 04:48:24 UTC (rev
833)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-10-31 14:37:01 UTC (rev
834)
@@ -1366,7 +1366,14 @@
*/
protected SocketTimeouts timeouts = null;
+
/**
+ * Last run of maintain. Maintain will run usually every 5s.
+ */
+ protected long lastMaintain = System.currentTimeMillis();
+
+
+ /**
* Amount of connections inside this poller.
*/
protected int connectionCount = 0;
@@ -1577,6 +1584,12 @@
protected void maintain() {
long date = System.currentTimeMillis();
+ // Maintain runs at most once every 5s, although it will likely get called
more
+ if ((date - lastMaintain) < 5000L) {
+ return;
+ } else {
+ lastMaintain = date;
+ }
long socket = timeouts.check(date);
while (socket != 0) {
removeFromPoller(socket);
@@ -1612,7 +1625,7 @@
*/
public void run() {
- long maintainTime = 0;
+ int maintain = 0;
// Loop until we receive a shutdown command
while (running) {
@@ -1627,14 +1640,13 @@
// Check timeouts for suspended connections if the poller is empty
while (connectionCount < 1 && addList.size() < 1) {
// Reset maintain time.
- maintainTime = 1;
try {
+ if (soTimeout > 0 && running) {
+ maintain();
+ }
synchronized (this) {
this.wait(10000);
}
- if (soTimeout > 0 && connectionCount < 1 &&
addList.size() < 1 && running) {
- maintain();
- }
} catch (InterruptedException e) {
// Ignore
} catch (Throwable t) {
@@ -1695,8 +1707,6 @@
}
}
- maintainTime += pollTime;
-
// Poll for the specified interval
for (int i = 0; i < pollers.length; i++) {
@@ -1798,16 +1808,15 @@
}
// Process socket timeouts
- if (soTimeout > 0 && maintainTime > 1000000L &&
running) {
+ if (soTimeout > 0 && maintain++ > 1000 &&
running) {
// This works and uses only one timeout mechanism for everything,
but the
// non Comet poller might be a bit faster by using the old
maintain.
- maintainTime = 0;
+ maintain = 0;
maintain();
- maintainTime = 1;
}
} catch (Throwable t) {
- if (maintainTime == 0) {
+ if (maintain == 0) {
log.error(sm.getString("endpoint.maintain.error"), t);
} else {
log.error(sm.getString("endpoint.poll.error"), t);
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-10-31 04:48:24 UTC (rev 833)
+++ trunk/webapps/docs/changelog.xml 2008-10-31 14:37:01 UTC (rev 834)
@@ -100,7 +100,7 @@
Allow AJP to read large body packets, up to the configured packet size. (remm)
</fix>
<fix>
- Remote date tool class, since it has sync issues. (markt, remm)
+ Remove date tool class, since it has sync issues. (markt, remm)
</fix>
<add>
Add AJP support for certificate chains. (billbarker)
@@ -112,7 +112,7 @@
Handling for invalid AJP messages. (remm)
</fix>
<fix>
- New maxThreads default to 200, up from 40. (remm)
+ New maxThreads default to 200, up from 40. (remm, fhanik)
</fix>
<fix>
<bug>46077</bug>: Add configuration for deferAccept flag. (remm)
@@ -126,6 +126,12 @@
<fix>
Refactor generation of the READ event which follows a BEGIN into the HTTP
protocol handler. (remm)
</fix>
+ <fix>
+ <jira>124</jira>: Comet instability fixes. (remm)
+ </fix>
+ <fix>
+ Fix timeout processing in many cases. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
@@ -158,7 +164,7 @@
<subsection name="Others">
<changelog>
<fix>
- <jboss-jira>JBWEB-122</jboss-jira>: Fix exception when using SSL and
HTTP variables. (jfclere)
+ <jira>122</jira>: Fix exception when using SSL and HTTP variables.
(jfclere)
</fix>
</changelog>
</subsection>
Show replies by date