You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/09/26 05:49:55 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/threads Expirer.java

costin      00/09/25 20:49:55

  Modified:    src/etc  server.xml
               src/facade22/org/apache/tomcat/modules/facade22
                        JspInterceptor.java
               src/native/mod_jk/apache2.0 Makefile.linux mod_jk.c
               src/share/org/apache/tomcat/core Handler.java
               src/share/org/apache/tomcat/session
                        ServerSessionManager.java
               src/share/org/apache/tomcat/util/threads Expirer.java
  Log:
  - fix a bug in the new Expirer
  
  - make sure servlet's init() is called only once ( synchronization )
  
  - make sure jsp interceptor is sync., only one compile even if multiple
  threads call the page at the same time
  
  - enable JspInterceptor by default. It worked with almost no change after
  many changes in core, I'm much more confident it is solid enough, and with
  the changes in jasper it'll be more clear in future.
  
  We can revert to JspServlet later ( if we can't get JspInterceptor to
  work as it should )
  
  Revision  Changes    Path
  1.45      +6 -0      jakarta-tomcat/src/etc/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- server.xml	2000/09/25 07:42:51	1.44
  +++ server.xml	2000/09/26 03:49:52	1.45
  @@ -146,6 +146,12 @@
               className="org.apache.tomcat.request.InvokerInterceptor" 
               debug="0" />
   
  +        <!-- "jsp" handler 
  +          -->
  +        <RequestInterceptor 
  +            className="org.apache.tomcat.modules.facade22.JspInterceptor" 
  +            debug="0"  />
  +        
           <!-- "default" handler - static files and dirs
             -->
           <RequestInterceptor 
  
  
  
  1.4       +14 -12    jakarta-tomcat/src/facade22/org/apache/tomcat/modules/facade22/JspInterceptor.java
  
  Index: JspInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/modules/facade22/JspInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JspInterceptor.java	2000/09/26 01:06:00	1.3
  +++ JspInterceptor.java	2000/09/26 03:49:53	1.4
  @@ -94,6 +94,7 @@
       public void addContext(ContextManager cm, Context ctx)
   	throws TomcatException 
       {
  +	JspFactory.setDefaultFactory(new JspFactoryImpl());
   	try {
   	    URL url=new URL( "file", null,
   			     ctx.getWorkDir().getAbsolutePath() + "/");
  @@ -103,12 +104,6 @@
   	}
       }
   
  -    public void contextInit(Context ctx)
  -	throws TomcatException 
  -    {
  -	JspFactory.setDefaultFactory(new JspFactoryImpl());
  -    }
  -
       public void preServletInit( Context ctx, Handler sw )
   	throws TomcatException
       {
  @@ -154,11 +149,19 @@
   	    
   	    // jump version number - the file needs to
   	    // be recompiled, and we don't want a reload
  -	    if( debug>0 )
  -		log( "Compiling " + jspInfo );
  -	    jspInfo.nextVersion();
  -	    compile( req, jspInfo );
  -	    mapJspPage( req , jspInfo, jspInfo.uri, jspInfo.fullClassN);
  +	    log( "Before sync block  " + jspInfo );
  +	    synchronized( jspInfo ) {
  +		//		if( debug>0 )
  +		if( jspInfo.jspSource.lastModified() 
  +		    > jspInfo.compileTime ) {
  +		    log( "Compiling " + jspInfo );
  +		
  +		    jspInfo.nextVersion();
  +		    compile( req, jspInfo );
  +		    mapJspPage( req , jspInfo, jspInfo.uri,
  +				jspInfo.fullClassN);
  +		}
  +	    } 
   	}
   
   	return 0;
  @@ -195,7 +198,6 @@
   		     " path=" + servletPath );
   	    }
   	    wrapper.setServletClass( classN );
  -	    wrapper.getServlet();
   	    wrapper.setNote( jspInfoNOTE, jspInfo );
   	} catch( TomcatException ex ) {
   	    log("mapJspPage: request=" + req + ", jspInfo=" + jspInfo + ", servletName=" + servletName + ", classN=" + classN, ex);
  
  
  
  1.2       +2 -2      jakarta-tomcat/src/native/mod_jk/apache2.0/Makefile.linux
  
  Index: Makefile.linux
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/apache2.0/Makefile.linux,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.linux	2000/08/26 01:21:40	1.1
  +++ Makefile.linux	2000/09/26 03:49:53	1.2
  @@ -1,7 +1,7 @@
   ## You need to edit this file - configure later :-)
   
  -APACHE_HOME=/home/shachor/jakarta/apache2.0a3
  -AP20_SRC=/home/shachor/jakarta/apache_2.0a3/src
  +APACHE_HOME=/usr/local/apache2.0
  +AP20_SRC=/home/costin/src/jakarta/apache-2.0/src
   OS=linux
   
   ## I assume this one is set up already
  
  
  
  1.2       +2 -2      jakarta-tomcat/src/native/mod_jk/apache2.0/mod_jk.c
  
  Index: mod_jk.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/apache2.0/mod_jk.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mod_jk.c	2000/08/26 01:21:41	1.1
  +++ mod_jk.c	2000/09/26 03:49:54	1.2
  @@ -220,8 +220,8 @@
   
           if(l) {
               BUFF *bf = p->r->connection->client;
  -            ap_size_t w = (ap_size_t)l;
  -            ap_size_t r = 0;
  +            size_t w = (size_t)l;
  +            size_t r = 0;
   
               if(!p->response_started) {
                   if(!s->start_response(s, 200, NULL, NULL, NULL, 0)) {
  
  
  
  1.15      +5 -1      jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Handler.java	2000/09/24 18:02:05	1.14
  +++ Handler.java	2000/09/26 03:49:54	1.15
  @@ -278,7 +278,11 @@
       {
   	if( ! initialized ) {
   	    try {
  -		init();
  +		synchronized( this ) {
  +		    // we may be initialized when we enter the sync block
  +		    if( ! initialized )
  +			init();
  +		}
   	    } catch( Exception ex ) {
   		initialized=false;
   		if( ex instanceof ClassNotFoundException ) {
  
  
  
  1.9       +7 -1      jakarta-tomcat/src/share/org/apache/tomcat/session/ServerSessionManager.java
  
  Index: ServerSessionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/ServerSessionManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServerSessionManager.java	2000/09/25 07:21:27	1.8
  +++ ServerSessionManager.java	2000/09/26 03:49:54	1.9
  @@ -68,6 +68,8 @@
   import org.apache.tomcat.util.threads.*;
   import org.apache.tomcat.helper.*;
   import org.apache.tomcat.core.*;
  +import org.apache.tomcat.logging.Logger.Helper;
  +import org.apache.tomcat.logging.Logger;
   
   /**
    *
  @@ -75,6 +77,8 @@
    */
   public final class ServerSessionManager  
   {
  +    protected Logger.Helper loghelper = new Logger.Helper("tc_log", this);
  +    
       /** The set of previously recycled Sessions for this Manager.
        */
       protected SimplePool recycled = new SimplePool();
  @@ -165,8 +169,10 @@
   
       public ServerSession getNewSession() {
   	if ((maxActiveSessions >= 0) &&
  -	    (sessions.size() >= maxActiveSessions))
  +	    (sessions.size() >= maxActiveSessions)) {
  +	    loghelper.log( "Too many sessions " + maxActiveSessions );
   	    return null;
  +	}
   
   	// Recycle or create a Session instance
   	ServerSession session = (ServerSession)recycled.get();
  
  
  
  1.2       +4 -2      jakarta-tomcat/src/share/org/apache/tomcat/util/threads/Expirer.java
  
  Index: Expirer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/Expirer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Expirer.java	2000/09/25 06:10:53	1.1
  +++ Expirer.java	2000/09/26 03:49:55	1.2
  @@ -105,7 +105,7 @@
       
       public void addManagedObject( TimeStamp ts ) {
   	synchronized( managedObjs ) {
  -	    if( managedCount > managedLen ) {
  +	    if( managedCount >= managedLen ) {
   		// What happens if expire is on the way ? Nothing,
   		// expire will do it's job on the old array ( GC magic )
   		// and the expired object will be marked as such
  @@ -113,8 +113,10 @@
   		TimeStamp newA[]=new TimeStamp[ 2 * managedLen ];
   		System.arraycopy( managedObjs, 0, newA, 0, managedLen);
   		managedObjs = newA;
  +		managedLen = 2 * managedLen;
   	    }
  -	    managedObjs[managedCount++]=ts;
  +	    managedObjs[managedCount]=ts;
  +	    managedCount++;
   	}
       }