Bug 56910 - when maxConnections="-1" AprEndpoint init error
when maxConnections="-1" AprEndpoint init error
Product: Tomcat 7
Classification: Unclassified
Component: Connectors
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
: 56909 (view as bug list)
Depends on:
  Show dependency tree
Reported: 2014-09-04 04:18 UTC by hongjiang
Modified: 2014-09-05 14:54 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description hongjiang 2014-09-04 04:18:16 UTC
use apr connector
set maxConnections="-1" in server.xml

when start tomcat, exceptions occur:

	at org.apache.tomcat.util.net.AprEndpoint$SocketTimeouts.<init>(AprEndpoint.java:1145)
	at org.apache.tomcat.util.net.AprEndpoint$Poller.init(AprEndpoint.java:1382)
	at org.apache.tomcat.util.net.AprEndpoint.startInternal(AprEndpoint.java:602)
	at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:650)
	at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

In AprEndpoint.init() method:

        protected void init() {

            pool = Pool.create(serverSockPool);

            // Single poller by default
            int defaultPollerSize = getMaxConnections();

            if ((OS.IS_WIN32 || OS.IS_WIN64) && (defaultPollerSize > 1024)) {
                // The maximum per poller to get reasonable performance is 1024
                // Adjust poller size so that it won't reach the limit. This is
                // a limitation of XP / Server 2003 that has been fixed in
                // Vista / Server 2008 onwards.
                actualPollerSize = 1024;
            } else {
                actualPollerSize = defaultPollerSize;

            timeouts = new SocketTimeouts(defaultPollerSize); //here !!!

did not check getMaxConnections() maybe return -1.
Comment 1 Konstantin Kolinko 2014-09-04 09:31:08 UTC
*** Bug 56909 has been marked as a duplicate of this bug. ***
Comment 2 Mark Thomas 2014-09-04 13:59:29 UTC
The way the APR Poller works, an unlimited number of connections isn't possible. I see two options if maxConnections is specified as -1.
a) Log an error and don't let the connector start
b) Use a high number (e.g. 64k), log a warning and start the connector.

I'm leaning towards b).
Comment 3 Mark Thomas 2014-09-05 14:54:27 UTC
In the end I decided to ignore values of -1, log a warning and continue using the current value.

Fixed in 8.0.x for 8.0.13 onwards and in 7.0.x for 7.0.56 onwards.