Author: fhanik
Date: Tue Oct 24 15:31:51 2006
New Revision: 467513
URL: http://svn.apache.org/viewvc?view=rev&rev=467513
Log:
Make the buffer pool configurable, still need to make it configurable based on
size
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?view=diff&rev=467513&r1=467512&r2=467513
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue
Oct 24 15:31:51 2006
@@ -46,6 +46,7 @@
import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.tomcat.util.net.SecureNioChannel.ApplicationBufferHandler;
import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment;
/**
* NIO tailored thread pool, providing the following services:
@@ -149,11 +150,21 @@
protected ConcurrentLinkedQueue<NioChannel> nioChannels = new
ConcurrentLinkedQueue<NioChannel>() {
- public boolean offer(NioChannel o) {
+ public boolean offer(NioChannel socket) {
+ Poller pol = socket.getPoller();
+ Selector sel = pol!=null?pol.getSelector():null;
+ SelectionKey key =
sel!=null?socket.getIOChannel().keyFor(sel):null;
+ KeyAttachment att = key!=null?(KeyAttachment)key.attachment():null;
+ if ( att!=null ) att.reset();
+ if ( key!=null ) key.cancel();
//avoid over growing our cache or add after we have stopped
- if ( running && (!paused) && (size() < curThreads) ) return
super.offer(o);
+ if ( running && (!paused) && (size() <
socketProperties.getDirectBufferPool()) ) return super.offer(socket);
else return false;
}
+
+ public NioChannel poll() {
+ return super.poll();
+ }
};
@@ -1199,6 +1210,16 @@
public KeyAttachment(Poller poller) {
this.poller = poller;
}
+ public void reset() {
+ //mutex = new Object();
+ wakeUp = false;
+ lastAccess = System.currentTimeMillis();
+ currentAccess = false;
+ comet = false;
+ timeout = -1;
+ error = false;
+ channel = null;
+ }
public Poller getPoller() { return poller;}
public void setPoller(Poller poller){this.poller = poller;}
public long getLastAccess() { return lastAccess; }
@@ -1364,7 +1385,6 @@
if ((status != null) && (handler.event(socket,
status) == Handler.SocketState.CLOSED)) {
// Close socket and pool
try {
-
try {socket.close();}catch (Exception
ignore){}
if ( socket.isOpen() ) socket.close(true);
nioChannels.offer(socket);
@@ -1374,7 +1394,6 @@
} else if ((status == null) &&
(handler.process(socket) == Handler.SocketState.CLOSED)) {
// Close socket and pool
try {
-
try {socket.close();}catch (Exception
ignore){}
if ( socket.isOpen() ) socket.close(true);
nioChannels.offer(socket);
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/SocketProperties.java?view=diff&rev=467513&r1=467512&r2=467513
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
Tue Oct 24 15:31:51 2006
@@ -7,6 +7,8 @@
protected boolean directBuffer = true;
protected int rxBufSize = 25188;
protected int txBufSize = 43800;
+ protected int directBufferPool = 500;
+
protected boolean tcpNoDelay = false;
protected boolean soKeepAlive = false;
protected boolean ooBInline = true;
@@ -18,7 +20,7 @@
protected int performanceConnectionTime = 1;
protected int performanceLatency = 0;
protected int performanceBandwidth = 1;
- private Socket properties;
+
public void setProperties(Socket socket) throws SocketException{
socket.setReceiveBufferSize(rxBufSize);
@@ -53,10 +55,6 @@
return performanceLatency;
}
- public Socket getProperties() {
- return properties;
- }
-
public int getRxBufSize() {
return rxBufSize;
}
@@ -93,6 +91,10 @@
return txBufSize;
}
+ public int getDirectBufferPool() {
+ return directBufferPool;
+ }
+
public void setPerformanceConnectionTime(int performanceConnectionTime) {
this.performanceConnectionTime = performanceConnectionTime;
}
@@ -147,6 +149,10 @@
public void setSoLingerOn(boolean soLingerOn) {
this.soLingerOn = soLingerOn;
+ }
+
+ public void setDirectBufferPool(int directBufferPool) {
+ this.directBufferPool = directBufferPool;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]