diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java index b2cc9ffa25a..b5a42262c40 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/proxy/FastCGIProxyServlet.java @@ -45,23 +45,23 @@ import org.eclipse.jetty.proxy.AsyncProxyServlet; * Specific implementation of {@link org.eclipse.jetty.proxy.AsyncProxyServlet.Transparent} for FastCGI. *

* This servlet accepts a HTTP request and transforms it into a FastCGI request - * that is sent to the FastCGI server specified in the proxyTo + * that is sent to the FastCGI server specified in the {@code proxyTo} * init-param. *

* This servlet accepts two additional init-params: *

* * @see TryFilesFilter @@ -111,7 +111,11 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent String scriptRoot = config.getInitParameter(SCRIPT_ROOT_INIT_PARAM); if (scriptRoot == null) throw new IllegalArgumentException("Mandatory parameter '" + SCRIPT_ROOT_INIT_PARAM + "' not configured"); - return new HttpClient(new ProxyHttpClientTransportOverFCGI(scriptRoot), null); + int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); + String value = config.getInitParameter("selectors"); + if (value != null) + selectors = Integer.parseInt(value); + return new HttpClient(new ProxyHttpClientTransportOverFCGI(selectors, scriptRoot), null); } @Override @@ -238,9 +242,9 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent private class ProxyHttpClientTransportOverFCGI extends HttpClientTransportOverFCGI { - public ProxyHttpClientTransportOverFCGI(String scriptRoot) + private ProxyHttpClientTransportOverFCGI(int selectors, String scriptRoot) { - super(scriptRoot); + super(selectors, false, scriptRoot); } @Override diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java index 5fc8e34813d..cda4db05d1d 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/AbstractProxyServlet.java @@ -258,6 +258,11 @@ public abstract class AbstractProxyServlet extends HttpServlet * HttpClient's default * The response buffer size, see {@link HttpClient#setResponseBufferSize(int)} * + * + * selectors + * cores / 2 + * The number of NIO selectors used by {@link HttpClient} + * * * * @see #newHttpClient() @@ -347,7 +352,7 @@ public abstract class AbstractProxyServlet extends HttpServlet */ protected HttpClient newHttpClient() { - int selectors = (Runtime.getRuntime().availableProcessors() + 1) / 2; + int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); String value = getServletConfig().getInitParameter("selectors"); if (value != null) selectors = Integer.parseInt(value);