Author: remm
Date: Thu Jan 17 21:46:32 2019
New Revision: 1851587
URL: http://svn.apache.org/viewvc?rev=1851587&view=rev
Log:
Use Runtime.getRuntime().availableProcessors() again as the base value for
utility thread counts, it has been used that way for too long and shouldn't
have been changed.
Modified:
tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
tomcat/trunk/webapps/docs/changelog.xml
tomcat/trunk/webapps/docs/config/server.xml
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardServer.java?rev=1851587&r1=1851586&r2=1851587&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Thu Jan 17
21:46:32 2019
@@ -416,29 +416,24 @@ public final class StandardServer extend
*/
private static int getUtilityThreadsInternal(int utilityThreads) {
int result = utilityThreads;
- if (result > 0) {
- return result;
- }
-
- // Zero == Runtime.getRuntime().availableProcessors() / 2
- // -ve == Runtime.getRuntime().availableProcessors() / 2 + value
- // These two are the same
- result = (Runtime.getRuntime().availableProcessors() / 2) + result;
- if (result < 1) {
- result = 1;
+ if (result <= 0) {
+ result = Runtime.getRuntime().availableProcessors() + result;
+ if (result < 1) {
+ result = 1;
+ }
}
return result;
}
+
@Override
public void setUtilityThreads(int utilityThreads) {
- if (getUtilityThreadsInternal(utilityThreads) <
getUtilityThreadsInternal(this.utilityThreads)) {
+ // Use local copies to ensure thread safety
+ int oldUtilityThreads = this.utilityThreads;
+ if (getUtilityThreadsInternal(utilityThreads) <
getUtilityThreadsInternal(oldUtilityThreads)) {
return;
}
- int oldUtilityThreads = this.utilityThreads;
this.utilityThreads = utilityThreads;
-
- // Use local copies to ensure thread safety
if (oldUtilityThreads != utilityThreads && utilityExecutor != null) {
reconfigureUtilityExecutor(getUtilityThreadsInternal(utilityThreads));
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1851587&r1=1851586&r2=1851587&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Jan 17 21:46:32 2019
@@ -88,6 +88,10 @@
Log a message when using a Connector that requires Apr without enabling
the AprLifecycleListener first. (csutherl)
</fix>
+ <fix>
+ Utility thread count for special negative or zero values will again be
+ based on Runtime.getRuntime().availableProcessors(). (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Modified: tomcat/trunk/webapps/docs/config/server.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/server.xml?rev=1851587&r1=1851586&r2=1851587&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/server.xml (original)
+++ tomcat/trunk/webapps/docs/config/server.xml Thu Jan 17 21:46:32 2019
@@ -90,9 +90,9 @@
<p>The number of threads this <strong>Service</strong> will use for
various utility tasks, including recurring ones. The special value
of 0 will result in the value of
- <code>Runtime.getRuntime().availableProcessors()/2</code> being
+ <code>Runtime.getRuntime().availableProcessors()</code> being
used. Negative values will result in
- <code>Runtime.getRuntime().availableProcessors()/2 + value</code> being
+ <code>Runtime.getRuntime().availableProcessors() + value</code> being
used unless this is less than 1 in which case 1 thread will be used.
The default value is 1.
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]