tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/service/connector JNIConnectionHandler.java
Date Fri, 05 May 2000 17:25:58 GMT
costin      00/05/05 10:25:57

  Modified:    src/share/org/apache/tomcat/service/connector
                        JNIConnectionHandler.java
  Log:
  Initial attempt to reuse Request/Response in JNI connector. It does improve the performance
  with ~30%, and seems to resolve some other problems. I still have problems with JDK1.3/Linux,
  but JDK1.2.2 seems to be better.
  
  Revision  Changes    Path
  1.5       +30 -6     jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java
  
  Index: JNIConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JNIConnectionHandler.java	2000/05/01 12:29:26	1.4
  +++ JNIConnectionHandler.java	2000/05/05 17:25:56	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java,v
1.4 2000/05/01 12:29:26 shachor Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/05/01 12:29:26 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java,v
1.5 2000/05/05 17:25:56 costin Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/05/05 17:25:56 $
    *
    * ====================================================================
    *
  @@ -68,6 +68,7 @@
   import org.apache.tomcat.util.*;
   import javax.servlet.*;
   import javax.servlet.http.*;
  +import java.util.*;
   
   public class JNIConnectionHandler {
   
  @@ -96,12 +97,35 @@
           System.out.println("Library " + lib + " loaded");
       }
   
  +    static Vector pool=new Vector();
  +    static boolean reuse=true;
  +    
       public void processConnection(long s, long l) {
   
           try {
  -    	    JNIRequestAdapter reqA = new JNIRequestAdapter(contextM, this);
  -    	    JNIResponseAdapter resA =new JNIResponseAdapter(this);
  -	    contextM.initRequest( reqA , resA );
  +	    JNIRequestAdapter reqA=null;
  +	    JNIResponseAdapter resA=null;
  +	    
  +	    if( reuse ) {
  +		synchronized( this ) {
  +		    if( pool.size()==0 ) {
  +			reqA=new JNIRequestAdapter( contextM, this);
  +			resA=new JNIResponseAdapter( this );
  +			contextM.initRequest( reqA, resA );
  +			pool.addElement( reqA );
  +		    } else {
  +			reqA = (JNIRequestAdapter)pool.lastElement();
  +			resA=(JNIResponseAdapter)reqA.getResponse();
  +			pool.removeElement( reqA );
  +		    }
  +		}
  +		reqA.recycle();
  +		resA.recycle();
  +	    } else  {
  +		reqA = new JNIRequestAdapter(contextM, this);
  +		resA =new JNIResponseAdapter(this);
  +		contextM.initRequest( reqA , resA );
  +	    }
   	    
               resA.setRequestAttr(s, l);
       	    reqA.readNextRequest(s, l);
  
  
  

Mime
View raw message