Author: remy.maucherat(a)jboss.com
Date: 2008-03-12 12:24:28 -0400 (Wed, 12 Mar 2008)
New Revision: 496
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
Log:
- Correctly update the individual poller space.
- Rename Poller.keepAliveCount and fix its updates (it is used to avoid loops when the
poller is empty).
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-03-12 15:50:16 UTC (rev
495)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-03-12 16:24:28 UTC (rev
496)
@@ -467,7 +467,7 @@
if (poller == null) {
return 0;
} else {
- return poller.getKeepAliveCount();
+ return poller.getConnectionsCount();
}
}
@@ -1260,10 +1260,10 @@
protected SocketTimeouts timeouts = null;
/**
- * Amount of kept alive connections inside this poller.
+ * Amount of connections inside this poller.
*/
- protected int keepAliveCount = 0;
- public int getKeepAliveCount() { return keepAliveCount; }
+ protected int connectionsCount = 0;
+ public int getConnectionsCount() { return connectionsCount; }
public Poller(boolean comet) {
this.comet = comet;
@@ -1317,7 +1317,7 @@
}
desc = new long[actualPollerSize * 2];
- keepAliveCount = 0;
+ connectionsCount = 0;
addList = new SocketList(pollerSize);
localAddList = new SocketList(pollerSize);
@@ -1362,7 +1362,7 @@
}
}
Pool.destroy(pool);
- keepAliveCount = 0;
+ connectionsCount = 0;
}
/**
@@ -1445,6 +1445,7 @@
rv = Poll.add(pollers[i], socket, events);
if (rv == Status.APR_SUCCESS) {
pollerSpace[i]--;
+ connectionsCount++;
return true;
}
}
@@ -1462,6 +1463,7 @@
rv = Poll.remove(pollers[i], socket);
if (rv != Status.APR_NOTFOUND) {
pollerSpace[i]++;
+ connectionsCount--;
break;
}
}
@@ -1506,14 +1508,14 @@
}
}
- while (keepAliveCount < 1 && addList.size() < 1) {
+ while (connectionsCount < 1 && addList.size() < 1) {
// Reset maintain time.
maintainTime = 1;
try {
synchronized (this) {
this.wait(10000);
}
- if (soTimeout > 0 && keepAliveCount < 1 &&
addList.size() < 1 && running) {
+ if (soTimeout > 0 && connectionsCount < 1
&& addList.size() < 1 && running) {
maintain();
}
} catch (InterruptedException e) {
@@ -1554,8 +1556,6 @@
} else {
Socket.destroy(info.socket);
}
- } else {
- keepAliveCount++;
}
}
} else {
@@ -1590,7 +1590,8 @@
rv = Poll.poll(pollers[i], pollerTime, desc, true);
}
if (rv > 0) {
- keepAliveCount -= rv;
+ pollerSpace[i] += rv;
+ connectionsCount -= rv;
for (int n = 0; n < rv; n++) {
timeouts.remove(desc[n*2+1]);
// Check for failed sockets and hand this socket off to a
worker
Show replies by date