costin      00/11/29 20:58:58

  Modified:    src/facade22/org/apache/tomcat/facade
                        HttpServletRequestFacade.java
                        HttpServletResponseFacade.java
               src/share/org/apache/tomcat/context ErrorHandler.java
               src/share/org/apache/tomcat/core ContextManager.java
                        Request.java
               src/share/org/apache/tomcat/helper RequestUtil.java
                        SessionUtil.java
               src/share/org/apache/tomcat/modules/server Ajp12.java
                        Ajp13.java Http10Interceptor.java
                        JNIConnectionHandler.java
               src/share/org/apache/tomcat/request AccessInterceptor.java
                        SimpleMapper1.java
               src/share/org/apache/tomcat/service/connector
                        Ajp12ConnectionHandler.java
                        Ajp13ConnectorRequest.java
                        JNIConnectionHandler.java
               src/share/org/apache/tomcat/service/http
                        HttpRequestAdapter.java
               src/share/org/apache/tomcat/util MessageBytes.java
                        PrefixMapper.java
  Log:
  A small round of optimizations - removed few dozens of un-needed allocations
  and GC.
  
  Now we are down to 11 objects per simple request - still not zero, but close
  enough. I think that concludes the memory tunning for the "common path"
  ( i.e. the overhead common to all requests ).
  
  We can now start doing "real" performance in 3.3 !!! ( from my point
  of view, nothing so far was more than removing garbage )
  
  ( of course, Cookies and Parameters have to be rewritten after the MimeHeaders
  model, plus a refactoring of MimeHeaders )
  
  ( BTW, all 11 objects are allocated in interceptors, no change in core
  will be needed to remove them - one is the Socket and it's not easy to
  reuse that - so probably we'll have 1 object per request instead of 0.
   )
  
  Details:
  
  - Continue the work on Request - now "serverName" ( the virtual host ) is
  a reusable MessageByte. There are only few Strings left, most of them not
  used in most cases.
  
  - small optimization in RequestUtil - no need to do the loop if the string
  is not encoded ( that saves few Strings/request + a loop )
  
  - small optimization in SessionUtil - the string allocation is not needed
  
  - small optimization in AccessInterceptor - avoid string allocation
  ( it'll be further optimized after we're done with the core, I'm working
  on few better tools for string manipulation )
  
  - small optimization in SimpleMapper1 - use/pass MessageBytes instead of
  converting to String.
  
  - same in PrefixMapper, use unsynchronized Hashtable ( SimpleHashtable - from
  crimson :-), pass strings
  
  - added getChars in MessageBytes
  
  Revision  Changes    Path
  1.9       +1 -1      
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpServletRequestFacade.java     2000/11/02 21:51:34     1.8
  +++ HttpServletRequestFacade.java     2000/11/30 04:58:36     1.9
  @@ -275,7 +275,7 @@
       }
   
       public String getServerName() {
  -     return request.getServerName();
  +     return request.serverName().toString();
       }
   
       public int getServerPort() {
  
  
  
  1.10      +1 -1      
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java
  
  Index: HttpServletResponseFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletResponseFacade.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpServletResponseFacade.java    2000/11/06 18:17:07     1.9
  +++ HttpServletResponseFacade.java    2000/11/30 04:58:38     1.10
  @@ -367,7 +367,7 @@
        // Does this URL match down to (and including) the context path?
        if (!request.scheme().equalsIgnoreCase(url.getProtocol()))
            return (false);
  -     if (!request.getServerName().equalsIgnoreCase(url.getHost()))
  +     if (!request.serverName().equalsIgnoreCase(url.getHost()))
            return (false);
           // Set the URL port to HTTP default if not available before comparing
           int urlPort = url.getPort();
  
  
  
  1.6       +1 -1      
jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java
  
  Index: ErrorHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ErrorHandler.java 2000/11/10 21:22:51     1.5
  +++ ErrorHandler.java 2000/11/30 04:58:39     1.6
  @@ -579,7 +579,7 @@
   
        url.append (scheme);            // http, https
        url.append ("://");
  -     url.append (req.getServerName());
  +     url.append (req.serverName().toString());
        if ((scheme.equals ("http") && port != 80)
                || (scheme.equals ("https") && port != 443)) {
            url.append (':');
  
  
  
  1.150     +1 -1      
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.149
  retrieving revision 1.150
  diff -u -r1.149 -r1.150
  --- ContextManager.java       2000/11/20 21:00:54     1.149
  +++ ContextManager.java       2000/11/30 04:58:40     1.150
  @@ -740,7 +740,7 @@
        lr.requestURI().setString( urlPath );
        lr.queryString().setString(queryString );
   
  -     if( host != null) lr.setServerName( host );
  +     if( host != null) lr.serverName().setString( host );
   
        return lr;
       }
  
  
  
  1.74      +22 -16    jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- Request.java      2000/11/20 21:00:54     1.73
  +++ Request.java      2000/11/30 04:58:41     1.74
  @@ -147,7 +147,7 @@
       protected int contentLength = -1;
       protected String contentType = null;
       protected String charEncoding = null;
  -    protected String serverName=null;
  +    protected MessageBytes serverNameMB=new MessageBytes();
   
       // auth infor
       protected String authType;
  @@ -273,19 +273,28 @@
        protoMB.setString(protocol);
       }
   
  -
  -    /** Return the server name. If none was set,
  -     *  extract it from the host header.
  -     *
  +    /** Return the buffer holding the server name, if
  +     *  any. Use isNull() to check if there is no value
  +     *  set.
  +     *  This is the "virtual host", derived from the
  +     *  Host: header.
        */
  -    public String getServerName() {
  -        return serverName;
  +    public MessageBytes serverName() {
  +     return serverNameMB;
       }
   
  -    /** Virtual host */
  -    public void setServerName(String serverName) {
  -     this.serverName = serverName;
  -    }
  +//     /** Return the server name. If none was set,
  +//      *  extract it from the host header.
  +//      *
  +//      */
  +//     public String getServerName() {
  +//         return serverName;
  +//     }
  +
  +//     /** Virtual host */
  +//     public void setServerName(String serverName) {
  +//   this.serverName = serverName;
  +//     }
   
       
       public int getServerPort() {
  @@ -567,10 +576,6 @@
            reqI[i].newSessionRequest( this, response );
        }
   
  -     if ( serverSession == null ) {
  -         return null;
  -     }
  -
        return serverSession;
       }
   
  @@ -842,7 +847,8 @@
           handler=null;
           jvmRoute = null;
           headers.clear(); // XXX use recycle pattern
  -        serverName=null;
  +        serverNameMB.recycle();
  +     //serverName=null;
           serverPort=-1;
           sessionIdSource = null;
        sessionId=null;
  
  
  
  1.6       +7 -1      
jakarta-tomcat/src/share/org/apache/tomcat/helper/RequestUtil.java
  
  Index: RequestUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/helper/RequestUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RequestUtil.java  2000/10/08 21:28:57     1.5
  +++ RequestUtil.java  2000/11/30 04:58:43     1.6
  @@ -137,7 +137,13 @@
        throws NumberFormatException, StringIndexOutOfBoundsException
       {
           if (str == null)  return  null;
  -
  +     
  +     // pay for what you use - unencoded requests will not get
  +     // less overhead
  +     // XXX this should be in the caller ?
  +     if( str.indexOf( '+' ) <0 && str.indexOf( '%' ) < 0 )
  +         return str;
  +     
           StringBuffer dec = new StringBuffer();    // decoded string output
           int strPos = 0;
           int strLen = str.length();
  
  
  
  1.4       +9 -5      
jakarta-tomcat/src/share/org/apache/tomcat/helper/SessionUtil.java
  
  Index: SessionUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/helper/SessionUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SessionUtil.java  2000/11/02 21:44:41     1.3
  +++ SessionUtil.java  2000/11/30 04:58:43     1.4
  @@ -68,7 +68,7 @@
    * <code>Session</code> implementations.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/11/02 21:44:41 $
  + * @version $Revision: 1.4 $ $Date: 2000/11/30 04:58:43 $
    */
   
   public final class SessionUtil {
  @@ -133,12 +133,16 @@
        }
   
        // Encode all absolute URLs that return to this hostname
  -     String serverName = req.getServerName();
  -     String match = "http://" + serverName;
  -     if (url.startsWith("http://" + serverName))
  +     String serverName = req.serverName().toString();
  +     if (url.startsWith("http://") &&
  +         url.indexOf( serverName )== 7 ) {
  +         // i.e. it starts with http://serverName
  +         // XXX should be "ignoreCase" and should also check for other
  +         // names. A lot of work to do to get this right
            return (encode(id, url));
  -     else
  +     } else {
            return (url);
  +     }
   
       }
   
  
  
  
  1.7       +2 -2      
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp12.java
  
  Index: Ajp12.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp12.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Ajp12.java        2000/11/02 21:44:47     1.6
  +++ Ajp12.java        2000/11/30 04:58:45     1.7
  @@ -135,7 +135,7 @@
                    dummy=readString(ajpin, null);
                    
                    //Server hostname
  -                 req.setServerName( readString(ajpin, null) );
  +                 req.serverName().setString(readString(ajpin, null) );
   
                    //Apache document root
                    dummy = readString(ajpin, null);               
  @@ -161,7 +161,7 @@
                    dummy = readString(ajpin, null);
                    //script name
                    dummy = readString(ajpin, null);                   
  -                 req.setServerName( readString(ajpin, ""));                
  +                 req.serverName().setString( readString(ajpin, ""));       
   
                    int serverPort=80;
                    try {
  
  
  
  1.5       +1 -1      
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java
  
  Index: Ajp13.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Ajp13.java        2000/11/15 11:37:25     1.4
  +++ Ajp13.java        2000/11/30 04:58:45     1.5
  @@ -193,7 +193,7 @@
   
           req.setRemoteAddr( msg.getString());
           req.setRemoteHost( msg.getString());
  -        req.setServerName( msg.getString());
  +        req.serverName().setString( msg.getString());
           req.setServerPort( msg.getInt());
   
        bsc        = msg.getByte();
  
  
  
  1.7       +10 -8     
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Http10Interceptor.java    2000/11/10 21:22:52     1.6
  +++ Http10Interceptor.java    2000/11/30 04:58:45     1.7
  @@ -250,10 +250,10 @@
        return localHost;
       }
   
  -    public String getServerName(){
  -        if(serverName!=null) return serverName;
  +    public MessageBytes serverName(){
  +        if(! serverNameMB.isNull()) return serverNameMB;
           parseHostHeader();
  -        return serverName;
  +        return serverNameMB;
       }
   
       public int getServerPort(){
  @@ -263,12 +263,14 @@
       }
   
       protected void parseHostHeader() {
  -     String hostHeader = this.getHeader("host");
  +     MessageBytes hH=getMimeHeaders().getValue("host");
           serverPort = socket.getLocalPort();
  -     if (hostHeader != null) {
  +     if (hH != null) {
  +         // XXX use MessageBytes
  +         String hostHeader = hH.toString();
            int i = hostHeader.indexOf(':');
            if (i > -1) {
  -             serverName = hostHeader.substring(0,i);
  +             serverNameMB.setString( hostHeader.substring(0,i));
                   hostHeader = hostHeader.substring(i+1);
                   try{
                       serverPort=Integer.parseInt(hostHeader);
  @@ -278,11 +280,11 @@
               return;
        }
        if( localHost != null ) {
  -         serverName = localHost;
  +         serverNameMB.setString( localHost );
        }
        // default to localhost - and warn
        //      log("No server name, defaulting to localhost");
  -        serverName=getLocalHost();
  +        serverNameMB.setString( getLocalHost() );
       }
   }
   
  
  
  
  1.4       +4 -4      
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/JNIConnectionHandler.java
  
  Index: JNIConnectionHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/JNIConnectionHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JNIConnectionHandler.java 2000/10/06 05:18:54     1.3
  +++ JNIConnectionHandler.java 2000/11/30 04:58:45     1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/JNIConnectionHandler.java,v
 1.3 2000/10/06 05:18:54 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/10/06 05:18:54 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/JNIConnectionHandler.java,v
 1.4 2000/11/30 04:58:45 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/11/30 04:58:45 $
    *
    * ====================================================================
    *
  @@ -305,7 +305,7 @@
                queryMB.setString( env[2] );
                remoteAddr  = env[3];
                remoteHost  = env[4];
  -             serverName  = env[5];
  +             serverNameMB.setString( env[5] );
               serverPort  = Integer.parseInt(env[6]);
               authType    = env[7];
               remoteUser  = env[8];
  
  
  
  1.23      +10 -1     
jakarta-tomcat/src/share/org/apache/tomcat/request/AccessInterceptor.java
  
  Index: AccessInterceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/AccessInterceptor.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- AccessInterceptor.java    2000/11/02 21:44:50     1.22
  +++ AccessInterceptor.java    2000/11/30 04:58:48     1.23
  @@ -299,7 +299,16 @@
        
        switch( ct.getMapType() ) {
        case Container.PREFIX_MAP:
  -         return path.startsWith( ctPath.substring(0, ctPathL - 2  ));
  +         // original code: 
  +         // return path.startsWith( ctPath.substring(0, ctPathL - 2  ));
  +         // changed to eliminate the allocation ( will be changed again
  +         // when MessageBytes will be used in intercepotrs, now they are
  +         // in core
  +         for( int i=0; i< ctPathL - 2 ; i++ ) {
  +             if( path.charAt( i ) != ctPath.charAt( i ))
  +                 return false;
  +         }
  +         return true;
        case Container.EXTENSION_MAP:
            return ctPath.substring( 1 ).equals( URLUtil.getExtension( path ));
        case Container.PATH_MAP:
  
  
  
  1.25      +17 -22    
jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper1.java
  
  Index: SimpleMapper1.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper1.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- SimpleMapper1.java        2000/11/02 21:44:51     1.24
  +++ SimpleMapper1.java        2000/11/30 04:58:48     1.25
  @@ -245,38 +245,33 @@
       /** First step of request porcessing is finding the Context.
        */
       public int contextMap( Request req ) {
  -     String path = req.requestURI().toString();
  -     if( path==null)
  +     MessageBytes pathMB = req.requestURI();
  +     if( pathMB.isNull())
            throw new RuntimeException("ASSERT: null path in request URI");
  -     if( path.indexOf("?") >=0 )
  -         throw new RuntimeException("ASSERT: ? in requestURI");
  +     //      if( path.indexOf("?") >=0 )
  +     //          throw new RuntimeException("ASSERT: ? in requestURI");
   
  -     if (path.indexOf('%') >= 0) {
  -             // XXX rewrite URLDecode to avoid allocation
  -             path = RequestUtil.URLDecode(path);
  +     if (pathMB.indexOf('%') >= 0 || pathMB.indexOf( '+' ) >= 0) {
  +         // XXX rewrite URLDecode to avoid allocation
  +         pathMB.setString( RequestUtil.URLDecode(pathMB.toString()) );
        }
        try {
  -         String host=null;
  +         //      String host=null;
  +         MessageBytes hostMB=req.serverName();
   
  -//       MimeHeaders headers=req.getMimeHeaders();
  -//       MimeHeaderField hostH=headers.find("host");
  +         //      host=req.serverName().toString();
   
  -         host=req.getServerName();
  +         if(debug>0) cm.log("Host = " + hostMB.toString());
   
  -//       if( hostH==null ) host=req.getLocalHost();
  -//       if(hostH==null) host="localhost";
  +         Container container =(Container)map.
  +             getLongestPrefixMatch(  hostMB, pathMB);
            
  -         if(debug>0) cm.log("Host = " + host);
  -
  -         Container container =(Container)map.getLongestPrefixMatch(  host,
  -                                                                     path );
  -         
            if( container == null )
                throw new RuntimeException( "Assertion failed: " +
                                            "container==null");
   
            if(debug>0)
  -             cm.log("SM: Prefix match " + path + " -> " +
  +             cm.log("SM: Prefix match " + pathMB.toString() + " -> " +
                       container.getPath() + " " + container.getHandler()  +
                       " " + container.getRoles());
   
  @@ -284,7 +279,7 @@
            // If cached - we don't need to do it again ( since it is the
            // final Container,
            // either prefix or extension )
  -         fixRequestPaths( path, req, container );
  +         fixRequestPaths( pathMB.toString() /*XXX*/, req, container );
        
   
            // if it's default container - try extension match
  @@ -295,7 +290,7 @@
                if( extC != null ) {
                    // change the handler
                    if( extC.getHandler() != null ) {
  -                     fixRequestPaths( path, req, extC );
  +                     fixRequestPaths( pathMB.toString(), req, extC );
                        container=extC;
                    }
                    if( debug > 0 )
  @@ -310,7 +305,7 @@
                Container ctxDef=req.getContext().getContainer();
                Container defC=(Container)ctxDef.getNote( defaultMapNOTE );
                if( defC != null && defC.getHandler() !=null ) {
  -                 fixRequestPaths( path, req, defC );
  +                 fixRequestPaths( pathMB.toString(), req, defC );
   
                    if( debug > 0 )
                        log("SM: Found default mapping " +
  
  
  
  1.43      +7 -4      
jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java
  
  Index: Ajp12ConnectionHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Ajp12ConnectionHandler.java       2000/11/02 21:44:56     1.42
  +++ Ajp12ConnectionHandler.java       2000/11/30 04:58:50     1.43
  @@ -250,9 +250,11 @@
                    
                    dummy = readString(ajpin, null);         //Servlet
                    
  -                 serverName = readString(ajpin, null);            //Server hostname
  -                 if( doLog ) d("AJP: serverName=" + serverName );
  +                 serverNameMB.setString(readString(ajpin, null));
  +                 //Server hostname
                    
  +                 if( doLog ) d("AJP: serverName=" +serverNameMB.toString());
  +                 
                    dummy = readString(ajpin, null);               //Apache document 
root
                    
                    pathInfoMB.setString( readString(ajpin, null));               
//Apache parsed path-info
  @@ -295,8 +297,9 @@
                    dummy = readString(ajpin, null);                   //script name
                    //          System.out.println("AJP: Script name=" + dummy);
   
  -                 serverName = readString(ajpin, "");                //server name
  -                 if( doLog ) d("AJP: serverName=" + serverName );
  +                 serverNameMB.setString( readString(ajpin, ""));
  +                 //server name
  +                 if( doLog ) d("AJP: serverName=" +serverNameMB.toString());
                    try {
                        serverPort = Integer.parseInt(readString(ajpin, "80")); 
//server port
                    } catch (Exception any) {
  
  
  
  1.17      +5 -5      
jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp13ConnectorRequest.java
  
  Index: Ajp13ConnectorRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp13ConnectorRequest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Ajp13ConnectorRequest.java        2000/11/15 11:40:03     1.16
  +++ Ajp13ConnectorRequest.java        2000/11/30 04:58:51     1.17
  @@ -1,7 +1,7 @@
  -/*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp13ConnectorRequest.java,v
 1.16 2000/11/15 11:40:03 hgomez Exp $
  - * $Revision: 1.16 $
  - * $Date: 2000/11/15 11:40:03 $
  + /*
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp13ConnectorRequest.java,v
 1.17 2000/11/30 04:58:51 costin Exp $
  + * $Revision: 1.17 $
  + * $Date: 2000/11/30 04:58:51 $
    *
    * ====================================================================
    *
  @@ -142,7 +142,7 @@
           uriMB.setString( msg.getString());
           remoteAddr = msg.getString();
           remoteHost = msg.getString();
  -        serverName = msg.getString();
  +        serverNameMB.setString( msg.getString());
           serverPort = msg.getInt();
           bsc        = msg.getByte();
           if(bsc != 0) {
  
  
  
  1.20      +4 -4      
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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JNIConnectionHandler.java 2000/10/06 05:19:13     1.19
  +++ JNIConnectionHandler.java 2000/11/30 04:58:52     1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java,v
 1.19 2000/10/06 05:19:13 costin Exp $
  - * $Revision: 1.19 $
  - * $Date: 2000/10/06 05:19:13 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/JNIConnectionHandler.java,v
 1.20 2000/11/30 04:58:52 costin Exp $
  + * $Revision: 1.20 $
  + * $Date: 2000/11/30 04:58:52 $
    *
    * ====================================================================
    *
  @@ -260,7 +260,7 @@
                queryMB.setString( env[2] );
                remoteAddr  = env[3];
                remoteHost  = env[4];
  -             serverName  = env[5];
  +             serverNameMB.setString( env[5] );
               serverPort  = Integer.parseInt(env[6]);
               authType    = env[7];
               remoteUser  = env[8];
  
  
  
  1.34      +14 -15    
jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java
  
  Index: HttpRequestAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- HttpRequestAdapter.java   2000/10/06 05:19:15     1.33
  +++ HttpRequestAdapter.java   2000/11/30 04:58:55     1.34
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
 1.33 2000/10/06 05:19:15 costin Exp $
  - * $Revision: 1.33 $
  - * $Date: 2000/10/06 05:19:15 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
 1.34 2000/11/30 04:58:55 costin Exp $
  + * $Revision: 1.34 $
  + * $Date: 2000/11/30 04:58:55 $
    *
    * ====================================================================
    *
  @@ -276,27 +276,26 @@
           return socket.getLocalPort();
       }
   
  -    public String getServerName() {
  -     if(serverName!=null) return serverName;
  +    public MessageBytes serverName() {
  +     if(! serverNameMB.isNull()) return serverNameMB;
        
        // XXX Move to interceptor!!!
  +     // XXX optimize
        String hostHeader = this.getHeader("host");
        if (hostHeader != null) {
            int i = hostHeader.indexOf(':');
            if (i > -1) {
                hostHeader = hostHeader.substring(0,i);
            }
  -         serverName=hostHeader;
  -         return serverName;
  +         serverNameMB.setString(hostHeader);
  +     } else {
  +         // XXX
  +         // we need a better solution here
  +         loghelper.log( "Got serverName via localAddress ");
  +         InetAddress localAddress = socket.getLocalAddress();
  +         serverNameMB.setString( localAddress.getHostName() );
        }
  -
  -     if (hostHeader == null) {
  -             // XXX
  -             // we need a better solution here
  -             InetAddress localAddress = socket.getLocalAddress();
  -             serverName = localAddress.getHostName();
  -     }
  -     return serverName;
  +     return serverNameMB;
       }
       
       
  
  
  
  1.13      +21 -2     
jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java
  
  Index: MessageBytes.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MessageBytes.java 2000/11/01 21:43:28     1.12
  +++ MessageBytes.java 2000/11/30 04:58:57     1.13
  @@ -314,14 +314,30 @@
        return bytes;
       }
   
  +    public char[] getChars()
  +    {
  +     if( hasCharValue ) {
  +         return chars;
  +     }
  +     toString();
  +     hasCharValue=true;
  +     chars=strValue.toCharArray();
  +     charsLen=chars.length;
  +     charsOff=0;
  +     return chars;
  +    }
  +    
       /**
        * Returns the start offset of the bytes.
        */
       public int getOffset() {
        if(type==T_BYTES)
            return bytesOff;
  -     if(type==T_CHARS)
  +     if(type==T_CHARS) {
  +         if( ! hasCharValue )
  +             getChars();
            return charsOff;
  +     }
        return 0;
       }
   
  @@ -331,8 +347,11 @@
       public int getLength() {
        if(type==T_BYTES)
            return bytesLen;
  -     if(type==T_CHARS)
  +     if(type==T_CHARS) {
  +         if( ! hasCharValue )
  +             getChars();
            return charsLen;
  +     }
        if(type==T_STR)
            return strValue.length();
        toString();
  
  
  
  1.4       +17 -12    
jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java
  
  Index: PrefixMapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PrefixMapper.java 2000/06/19 21:53:16     1.3
  +++ PrefixMapper.java 2000/11/30 04:58:57     1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.3 
2000/06/19 21:53:16 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/06/19 21:53:16 $
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.4 
2000/11/30 04:58:57 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/11/30 04:58:57 $
    *
    * ====================================================================
    *
  @@ -80,16 +80,16 @@
    */
   public class PrefixMapper {
       // host -> PrefixMapper for virtual hosts
  -    Hashtable vhostMaps=new Hashtable();
  +    SimpleHashtable vhostMaps=new SimpleHashtable();
   
   
  -    Hashtable prefixMappedServlets;
  -    Hashtable exactMappedServlets;
  +    SimpleHashtable prefixMappedServlets;
  +    SimpleHashtable exactMappedServlets;
   
           // Cache the most recent mappings
       // Disabled by default ( since we haven't implemented
       // capacity and remove ). 
  -    Hashtable mapCache;
  +    SimpleHashtable mapCache;
       // By using TreeMap instead of SimpleMap you go from 143 to 161 RPS
       // ( at least on my machine )
       // Interesting - even if SimpleHashtable is faster than Hashtable
  @@ -105,9 +105,9 @@
   
       
       public PrefixMapper() {
  -     prefixMappedServlets=new Hashtable();
  -     exactMappedServlets=new Hashtable();
  -     mapCache=new Hashtable();
  +     prefixMappedServlets=new SimpleHashtable();
  +     exactMappedServlets=new SimpleHashtable();
  +     mapCache=new SimpleHashtable();
       }
   
       public void setMapCache( boolean v ) {
  @@ -141,7 +141,7 @@
                vmap.exactMappedServlets.remove( s );
        }
        // reset the cache
  -     mapCache=new Hashtable();
  +     mapCache=new SimpleHashtable();
        
       }
   
  @@ -193,7 +193,12 @@
   
       /** Match a prefix rule - /foo/bar/index.html/abc
        */
  -    public Object getLongestPrefixMatch( String host, String path ) {
  +    public Object getLongestPrefixMatch( MessageBytes hostMB,
  +                                      MessageBytes pathMB )
  +    {
  +     // XXX fixme
  +     String host=hostMB.toString();
  +     String path=pathMB.toString();
        Object container = null;
           String s = path;
   
  
  
  

Reply via email to