remm2005/04/18 09:47:48
Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
http11/src/java/org/apache/coyote/http11
Http11AprProtocol.java Http11AprProcessor.java
Log:
- Add the basis for sendfile (not used yet).
- Bugfixes to poll handling.
- The processor will now send the socket to the poller by itself (allows
future similar use of sendfile), while the boolean will only
indicate if the socket should be closed or not.
is only used to indicate if the socket is to be closed.
Revision ChangesPath
1.9 +254 -34
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java
Index: AprEndpoint.java
===
RCS file:
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AprEndpoint.java 18 Apr 2005 13:57:12 - 1.8
+++ AprEndpoint.java 18 Apr 2005 16:47:47 - 1.9
@@ -17,6 +17,7 @@
package org.apache.tomcat.util.net;
import java.net.InetAddress;
+import java.util.HashMap;
import java.util.Stack;
import java.util.Vector;
@@ -24,6 +25,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.jni.Address;
import org.apache.tomcat.jni.Error;
+import org.apache.tomcat.jni.File;
import org.apache.tomcat.jni.Library;
import org.apache.tomcat.jni.Poll;
import org.apache.tomcat.jni.Pool;
@@ -73,12 +75,6 @@
/**
- * The socket poller.
- */
-protected Poller poller = null;
-
-
-/**
* The socket poller thread.
*/
protected Thread pollerThread = null;
@@ -87,7 +83,6 @@
/**
* The sendfile thread.
*/
-// FIXME: Add senfile support
protected Thread sendfileThread = null;
@@ -180,12 +175,20 @@
/**
* Size of the socket poller.
*/
-protected int pollerSize = 512;
+protected int pollerSize = 768;
public void setPollerSize(int pollerSize) { this.pollerSize =
pollerSize; }
public int getPollerSize() { return pollerSize; }
/**
+ * Size of the sendfile (= concurrent files which can be served).
+ */
+protected int sendfileSize = 256;
+public void setSendfileSize(int sendfileSize) { this.sendfileSize =
sendfileSize; }
+public int getSendfileSize() { return sendfileSize; }
+
+
+/**
* Server socket port.
*/
protected int port;
@@ -283,10 +286,30 @@
*/
protected int keepAliveCount = 0;
public int getKeepAliveCount() { return keepAliveCount; }
-public void setKeepAliveCount(int keepAliveCount) { this.keepAliveCount
= keepAliveCount; }
+
+
+/**
+ * Number of sendfile sockets.
+ */
+protected int sendfileCount = 0;
+public int getSendfileCount() { return sendfileCount; }
+
+
+/**
+ * The socket poller.
+ */
+protected Poller poller = null;
+public Poller getPoller() { return poller; }
/**
+ * The static file sender.
+ */
+protected Sendfile sendfile = null;
+public Sendfile getSendfile() { return sendfile; }
+
+
+/**
* Dummy maxSpareThreads property.
*/
public int getMaxSpareThreads() { return 0; }
@@ -412,14 +435,20 @@
acceptorThread.start();
// Start poller thread
-poller = new Poller(pollerSize);
+poller = new Poller();
+poller.init();
pollerThread = new Thread(poller, getName() + -Poller);
pollerThread.setPriority(getThreadPriority());
pollerThread.setDaemon(true);
pollerThread.start();
// Start sendfile thread
-// FIXME: Implement sendfile support
+sendfile = new Sendfile();
+sendfile.init();
+sendfileThread = new Thread(sendfile, getName() + -Sendfile);
+sendfileThread.setPriority(getThreadPriority());
+sendfileThread.setDaemon(true);
+sendfileThread.start();
}
}
@@ -441,6 +470,8 @@
if (running) {
running = false;
unlockAccept();
+poller.destroy();
+sendfile.destroy();
acceptorThread = null;
pollerThread = null;
sendfileThread = null;
@@ -519,14 +550,14 @@
}
-protected boolean processSocket(long s) {
+protected boolean processSocket(long socket, long pool) {
// Process the connection
int step = 1;
boolean result = true;
try {
// 1: Set socket