From: rjung Date: Fri, 29 Oct 2010 17:54:27 +0000 (+0000) Subject: Simplify JSP limiter: X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c3fcbb926f0d837f7d8c4bf00d0fb70eefa53fdd;p=tomcat7.0 Simplify JSP limiter: - inline getJspForUnload It is only used privately and only in one place plus the code gets easier to understand. - remove compilation interval check from background method checkUnload(). Better to run on every iteration of the background job. - Do not check JSP count against the size of the wrapper list (jsps). Instead check against the queue length. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1028863 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java b/java/org/apache/jasper/compiler/JspRuntimeContext.java index 9e1085277..5185df6a0 100644 --- a/java/org/apache/jasper/compiler/JspRuntimeContext.java +++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java @@ -500,23 +500,6 @@ public final class JspRuntimeContext { return new SecurityHolder(source, permissions); } - /** Returns a JspServletWrapper that should be destroyed. Default strategy: Least recently used. */ - public JspServletWrapper getJspForUnload(final int maxLoadedJsps) { - if( jsps.size() > maxLoadedJsps ) { - synchronized( jsps ) { - JspServletWrapper oldest; - synchronized(jspQueue) { - oldest = jspQueue.pop(); - } - if (oldest != null) { - removeWrapper(oldest.getJspUri()); - return oldest; - } - } - } - return null; - } - /** * Method used by background thread to check if any JSP's should be destroyed. * If JSP's to be unloaded are found, they will be destroyed. @@ -524,10 +507,7 @@ public final class JspRuntimeContext { */ public void checkUnload() { if (options.getMaxLoadedJsps() > 0) { - long now = System.currentTimeMillis(); - if (now > (lastCheck + (options.getCheckInterval() * 1000L))) { - while (unloadJsp()); - } + while (unloadJsp()) {} } } @@ -535,8 +515,14 @@ public final class JspRuntimeContext { * Checks whether there is a jsp to unload, if one is found, it is destroyed. * */ public boolean unloadJsp() { - JspServletWrapper jsw = getJspForUnload(options.getMaxLoadedJsps()); - if( null != jsw ) { + JspServletWrapper jsw = null; + synchronized(jspQueue) { + if(jspQueue.getSize() > options.getMaxLoadedJsps()) { + jsw = jspQueue.pop(); + } + } + if (jsw != null) { + removeWrapper(jsw.getJspUri()); synchronized(jsw) { jsw.destroy(); return true;