diff src/org/eclipse/jetty/server/Connector.java @ 954:a021c4c9c244

use just one SelectSet per SelectorManager
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 13 Oct 2016 00:54:10 -0600
parents f5aefdc4a81a
children 1094975d013b
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/Connector.java	Wed Oct 12 22:16:36 2016 -0600
+++ b/src/org/eclipse/jetty/server/Connector.java	Thu Oct 13 00:54:10 2016 -0600
@@ -54,7 +54,7 @@
  * <li>Optional reverse proxy headers checking</li>
  * </ul>
  */
-public abstract class Connector extends AggregateLifeCycle implements HttpBuffers, Dumpable
+public abstract class Connector extends AggregateLifeCycle implements HttpBuffers, Dumpable, Runnable
 {
 	private static final Logger LOG = LoggerFactory.getLogger(Connector.class);
 
@@ -63,7 +63,6 @@
 	public final Server server;
 	private String _host;
 	public final int port;
-	private int _acceptors = 1;
 
 	protected final int _maxIdleTime = 200000;
 	protected int _soLingerTime = -1;
@@ -137,27 +136,6 @@
 
 	/* ------------------------------------------------------------ */
 	/**
-	 * @return Returns the number of acceptor threads.
-	 */
-	public int getAcceptors()
-	{
-		return _acceptors;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @param acceptors
-	 *            The number of acceptor threads to set.
-	 */
-	public void setAcceptors(int acceptors)
-	{
-		if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
-			LOG.warn("Acceptors should be <=2*availableProcessors: " + this);
-		_acceptors = acceptors;
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
 	 * @param soLingerTime
 	 *            The soLingerTime to set or -1 to disable.
 	 */
@@ -173,8 +151,7 @@
 
 		// Start selector thread
 		ThreadPoolExecutor _threadPool = server.threadPool;
-		for (int i = 0; i < _acceptors; i++)
-			_threadPool.execute(new Acceptor());
+		_threadPool.execute(this);
 		if (server.isLowOnThreads())
 			LOG.warn("insufficient threads configured for {}",this);
 
@@ -322,46 +299,42 @@
 	}
 
 
-	private class Acceptor implements Runnable
+	public void run()
 	{
+		Thread current = Thread.currentThread();
+		String name = current.getName();
+		current.setName(name + " Acceptor" + " " + Connector.this);
 
-		public void run()
+		try
 		{
-			Thread current = Thread.currentThread();
-			String name = current.getName();
-			current.setName(name + " Acceptor" + " " + Connector.this);
-
-			try
+			while (isRunning() && _acceptChannel != null)
 			{
-				while (isRunning() && _acceptChannel != null)
+				try
 				{
-					try
-					{
-						accept();
-					}
-					catch (EofException e)
-					{
-						LOG.trace("",e);
-					}
-					catch (IOException e)
-					{
-						LOG.trace("",e);
-					}
-					catch (InterruptedException x)
-					{
-						// Connector has been stopped
-						LOG.trace("",x);
-					}
-					catch (Throwable e)
-					{
-						LOG.warn("",e);
-					}
+					accept();
+				}
+				catch (EofException e)
+				{
+					LOG.trace("",e);
+				}
+				catch (IOException e)
+				{
+					LOG.trace("",e);
+				}
+				catch (InterruptedException x)
+				{
+					// Connector has been stopped
+					LOG.trace("",x);
+				}
+				catch (Throwable e)
+				{
+					LOG.warn("",e);
 				}
 			}
-			finally
-			{
-				current.setName(name);
-			}
+		}
+		finally
+		{
+			current.setName(name);
 		}
 	}