diff src/org/eclipse/jetty/server/Connector.java @ 1011:4e7208df7741

remove PooledBuffers
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Oct 2016 23:59:08 -0600
parents b664624a4423
children 8c13b9224cff
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 22:23:50 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Sun Oct 23 23:59:08 2016 -0600
@@ -28,10 +28,12 @@
 
 import javax.servlet.ServletRequest;
 
+import org.eclipse.jetty.io.Buffer;
 import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.PooledBuffers;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.io.EofException;
+import org.eclipse.jetty.io.nio.DirectNIOBuffer;
+import org.eclipse.jetty.io.nio.IndirectNIOBuffer;
 import org.eclipse.jetty.util.component.AggregateLifeCycle;
 import org.eclipse.jetty.util.component.Dumpable;
 import org.slf4j.Logger;
@@ -132,8 +134,6 @@
 		if (server.isLowOnThreads())
 			LOG.warn("insufficient threads configured for {}",this);
 
-		startBuffers();
-
 		LOG.info("Started {}",this);
 	}
 
@@ -151,8 +151,6 @@
 			LOG.warn("",e);
 		}
 
-		stopBuffers();
-
 		super.doStop();
 	}
 
@@ -236,41 +234,51 @@
 
 	// from HttpBuffersImpl
 
+	protected int _requestHeaderSize = 6*1024;
 	protected int _requestBufferSize = 16*1024;
-	protected int _requestHeaderSize = 6*1024;
-	private final int _responseBufferSize = 32*1024;
 	private final int _responseHeaderSize = 6*1024;
-	private final int _maxBuffers = 1024;
-	
-	protected Buffers.Type _requestBufferType = Buffers.Type.DIRECT;
-	protected Buffers.Type _responseBufferType = Buffers.Type.DIRECT;
+	private final int _responseBufferSize = 32*1024;
 	
-	private Buffers _requestBuffers;
-	private Buffers _responseBuffers;
-
-	private void startBuffers()
-		throws Exception
-	{
-		_requestBuffers = new PooledBuffers(Buffers.Type.INDIRECT,_requestHeaderSize,_requestBufferType,_requestBufferSize,_maxBuffers);
-		_responseBuffers = new PooledBuffers(Buffers.Type.INDIRECT,_responseHeaderSize,_responseBufferType,_responseBufferSize,_maxBuffers);
-		super.doStart();
-	}
-	
-	private void stopBuffers()
-		throws Exception
-	{
-		_requestBuffers = null;
-		_responseBuffers = null;
-	}
-
 	public final Buffers getRequestBuffers()
 	{
-		return _requestBuffers;
+		return new MyBuffers(_requestHeaderSize,_requestBufferSize);
 	}
 	
 	public final Buffers getResponseBuffers()
 	{
-		return _responseBuffers;
+		return new MyBuffers(_responseHeaderSize,_responseBufferSize);
+	}
+
+
+	// my own buffers
+
+	protected Buffer newBuffer(int size) {
+		return new DirectNIOBuffer(size);
 	}
 
+	private class MyBuffers implements Buffers {
+		private final int headerSize;
+		private final int bufferSize;
+
+		MyBuffers(int headerSize,int bufferSize) {
+			this.headerSize = headerSize;
+			this.bufferSize = bufferSize;
+		}
+
+		public Buffer getHeader() {
+			return new IndirectNIOBuffer(headerSize);
+		}
+
+		public Buffer getBuffer() {
+			return newBuffer(bufferSize);
+		}
+
+		public Buffer getBuffer(int size) {
+			return newBuffer(size);
+		}
+		
+		public void returnBuffer(Buffer buffer) {
+			// like I care
+		}
+	}
 }