billbarker    2004/05/30 21:48:54

  Modified:    jk/java/org/apache/jk/apr AprImpl.java
               jk/java/org/apache/jk/common ChannelJni.java
                        ChannelSocket.java ChannelUn.java
                        HandlerRequest.java JkInputStream.java
                        JniHandler.java
               jk/java/org/apache/jk/core MsgContext.java
               jk/java/org/apache/jk/server JkCoyoteHandler.java
  Added:       jk/java/org/apache/jk/core JkChannel.java
  Log:
  Clean up the API a bit to make it easier to improve.
  
  The big change is that the 'source' attribute of MsgContext is now a JkChannel 
instead of an arbitrary JkHandler.  This allows the Actions to bypass the 'invoke' 
path (which is really for incoming requests), and makes Request registration easier.
  
  Other than Request registration, there really isn't much functionality change here.  
However, now JK finally plays nice with the Manager status servlet (at least with the 
Socket and Unix channels).  Also, the memory leak with the JNI channel is finally gone 
(since it doesn't implement Request registration).
  
  Revision  Changes    Path
  1.31      +2 -1      jakarta-tomcat-connectors/jk/java/org/apache/jk/apr/AprImpl.java
  
  Index: AprImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/apr/AprImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- AprImpl.java      24 Feb 2004 08:48:44 -0000      1.30
  +++ AprImpl.java      31 May 2004 04:48:54 -0000      1.31
  @@ -22,6 +22,7 @@
   import java.util.Hashtable;
   import org.apache.jk.core.JkHandler;
   import org.apache.jk.core.MsgContext;
  +import org.apache.jk.core.JkChannel;
   
   /** Implements the interface with the APR library. This is for internal-use
    *  only. The goal is to use 'natural' mappings for user code - for example
  @@ -167,7 +168,7 @@
       public static Object createJavaContext(String type, long cContext) {
           // XXX will be an instance method, fields accessible directly
           AprImpl apr=aprSingleton;
  -        JkHandler jkH=(JkHandler)apr.jkHandlers.get( type );
  +        JkChannel jkH=(JkChannel)apr.jkHandlers.get( type );
           if( jkH==null ) return null;
   
           MsgContext ep=jkH.createMsgContext();
  
  
  
  1.17      +21 -5     
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelJni.java
  
  Index: ChannelJni.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelJni.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ChannelJni.java   24 Feb 2004 08:48:42 -0000      1.16
  +++ ChannelJni.java   31 May 2004 04:48:54 -0000      1.17
  @@ -21,13 +21,14 @@
   import org.apache.jk.core.JkHandler;
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
  +import org.apache.jk.core.JkChannel;
   
  -
  +import org.apache.coyote.Request;
   /** Pass messages using jni 
    *
    * @author Costin Manolache
    */
  -public class ChannelJni extends JniHandler {
  +public class ChannelJni extends JniHandler implements JkChannel {
       int receivedNote=1;
   
       public ChannelJni() {
  @@ -92,6 +93,7 @@
       public int send( Msg msg, MsgContext ep )
           throws IOException
       {
  +        ep.setNote( receivedNote, null );
           if( log.isDebugEnabled() ) log.debug("ChannelJni.send: "  +  msg );
   
           int rc=super.nativeDispatch( msg, ep, JK_HANDLE_JNI_DISPATCH, 0);
  @@ -104,6 +106,22 @@
           return rc;
       }
   
  +    public int flush(Msg msg, MsgContext ep) throws IOException {
  +        ep.setNote( receivedNote, null );
  +        return OK;
  +    }
  +
  +    public boolean isSameAddress(MsgContext ep) {
  +        return true;
  +    }
  +
  +    public void registerRequest(Request req, MsgContext ep, int count) {
  +        // Not supported.
  +    }
  +
  +    public String getChannelName() {
  +        return getName();
  +    }
       /** Receive a packet from the C side. This is called from the C
        *  code using invocation, but only for the first packet - to avoid
        *  recursivity and thread problems.
  @@ -136,11 +154,9 @@
           case JkHandler.HANDLE_RECEIVE_PACKET:
               return receive( msg, ep );
           case JkHandler.HANDLE_SEND_PACKET:
  -            ep.setNote( receivedNote, null );
               return send( msg, ep );
           case JkHandler.HANDLE_FLUSH:
  -            ep.setNote( receivedNote, null );
  -            return 0;
  +            return flush(msg, ep);
           }
   
           // Reset receivedNote. It'll be visible only after a SEND and before a 
receive.
  
  
  
  1.46      +64 -12    
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java
  
  Index: ChannelSocket.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- ChannelSocket.java        21 Mar 2004 23:50:53 -0000      1.45
  +++ ChannelSocket.java        31 May 2004 04:48:54 -0000      1.46
  @@ -21,6 +21,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.net.URLEncoder;
   import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.Socket;
  @@ -38,6 +39,11 @@
   import org.apache.jk.core.JkHandler;
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
  +import org.apache.jk.core.JkChannel;
  +import org.apache.jk.core.WorkerEnv;
  +import org.apache.coyote.Request;
  +import org.apache.coyote.RequestGroupInfo;
  +import org.apache.coyote.RequestInfo;
   import org.apache.tomcat.util.threads.ThreadPool;
   import org.apache.tomcat.util.threads.ThreadPoolRunnable;
   
  @@ -70,7 +76,8 @@
    * @jmx:notification-handler name="org.apache.jk.JK_RECEIVE_PACKET
    * @jmx:notification-handler name="org.apache.jk.JK_FLUSH
    */
  -public class ChannelSocket extends JkHandler implements NotificationBroadcaster {
  +public class ChannelSocket extends JkHandler
  +    implements NotificationBroadcaster, JkChannel {
       private static org.apache.commons.logging.Log log=
           org.apache.commons.logging.LogFactory.getLog( ChannelSocket.class );
   
  @@ -371,29 +378,39 @@
               if( next==null )
                   next=wEnv.getHandler( "request" );
           }
  -
  +        JMXRequestNote =wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "requestNote");
           running = true;
   
           // Run a thread that will accept connections.
           // XXX Try to find a thread first - not sure how...
           if( this.domain != null ) {
               try {
  -                tpOName=new ObjectName(domain + ":type=ThreadPool,name=jk" + port);
  +                tpOName=new ObjectName(domain + ":type=ThreadPool,name=" + 
  +                                       getChannelName());
  +
  +                Registry.getRegistry(null, null)
  +                    .registerComponent(tp, tpOName, null);
   
  -                Registry.getRegistry().registerComponent(tp, tpOName, null);
  +                rgOName = new ObjectName
  +                    (domain+":type=GlobalRequestProcessor,name=" + 
getChannelName());
  +                Registry.getRegistry(null, null)
  +                    .registerComponent(global, rgOName, null);
               } catch (Exception e) {
                   log.error("Can't register threadpool" );
               }
           }
   
  -        // XXX Move to start, make sure the caller calls start
           tp.start();
           SocketAcceptor acceptAjp=new SocketAcceptor(  this );
           tp.runIt( acceptAjp);
  +
       }
   
       ObjectName tpOName;
  -    
  +    ObjectName rgOName;
  +    RequestGroupInfo global=new RequestGroupInfo();
  +    int JMXRequestNote;
  +
       public void start() throws IOException{
           if( sSocket==null )
               init();
  @@ -403,6 +420,23 @@
           destroy();
       }
   
  +    public void registerRequest(Request req, MsgContext ep, int count) {
  +        if(this.domain != null) {
  +            try {
  +                RequestInfo rp=req.getRequestProcessor();
  +                rp.setGlobalProcessor(global);
  +                ObjectName roname = new ObjectName
  +                    (getDomain() + ":type=RequestProcessor,worker="+
  +                     getChannelName()+",name=JkRequest" +count);
  +                ep.setNote(JMXRequestNote, roname);
  +                        
  +                Registry.getRegistry().registerComponent( rp, roname, null);
  +            } catch( Exception ex ) {
  +                log.warn("Error registering request");
  +            }
  +        }
  +    }
  +
       public void open(MsgContext ep) throws IOException {
       }
   
  @@ -444,6 +478,9 @@
               if( tpOName != null )  {
                   Registry.getRegistry().unregisterComponent(tpOName);
               }
  +            if( rgOName != null ) {
  +                Registry.getRegistry().unregisterComponent(rgOName);
  +            }
           } catch(Exception e) {
               log.info("Error shutting down the channel " + port + " " +
                       e.toString());
  @@ -651,12 +688,12 @@
                   log.error( "Error, closing connection", e);
               }
               try{
  -             MsgAjp endM = new MsgAjp();
  -                endM.reset();
  -                endM.appendByte((byte)HANDLE_THREAD_END);
  -             endM.end();
  -             endM.processHeader();
  -                next.invoke(endM, ep);
  +                Request req = (Request)ep.getRequest();
  +                if( req != null ) {
  +                    ObjectName roname = (ObjectName)ep.getNote(JMXRequestNote);
  +                    Registry.getRegistry().unregisterComponent(roname);
  +                    req.getRequestProcessor().setGlobalProcessor(null);
  +                }
               } catch( Exception ee) {
                   log.error( "Error, releasing connection",ee);
               }
  @@ -704,6 +741,21 @@
           return isSameAddress( s.getLocalAddress(), s.getInetAddress());
       }
       
  +    public String getChannelName() {
  +        String encodedAddr = "";
  +        String address = getAddress();
  +        if (address != null) {
  +            encodedAddr = address;
  +            if (encodedAddr.startsWith("/"))
  +                encodedAddr = encodedAddr.substring(1);
  +            if("0.0.0.0".equals(encodedAddr)) {
  +                encodedAddr = "";
  +            } else {
  +                encodedAddr = URLEncoder.encode(encodedAddr) + "-";
  +            }
  +        }
  +        return ("jk-" + encodedAddr + port);
  +    }
       
       /**
        * Return <code>true</code> if the specified client and server addresses
  
  
  
  1.28      +94 -18    
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java
  
  Index: ChannelUn.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ChannelUn.java    22 Mar 2004 00:42:13 -0000      1.27
  +++ ChannelUn.java    31 May 2004 04:48:54 -0000      1.28
  @@ -16,13 +16,21 @@
   
   package org.apache.jk.common;
   
  +import java.net.URLEncoder;
   import java.io.File;
   import java.io.FileOutputStream;
   import java.io.IOException;
  +import javax.management.ObjectName;
   
  +import org.apache.commons.modeler.Registry;
   import org.apache.jk.core.JkHandler;
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
  +import org.apache.jk.core.JkChannel;
  +import org.apache.jk.core.WorkerEnv;
  +import org.apache.coyote.Request;
  +import org.apache.coyote.RequestGroupInfo;
  +import org.apache.coyote.RequestInfo;
   import org.apache.tomcat.util.threads.ThreadPool;
   import org.apache.tomcat.util.threads.ThreadPoolRunnable;
   
  @@ -31,14 +39,14 @@
    *
    * @author Costin Manolache
    */
  -public class ChannelUn extends JniHandler {
  +public class ChannelUn extends JniHandler implements JkChannel {
       static final int CH_OPEN=4;
       static final int CH_CLOSE=5;
       static final int CH_READ=6;
       static final int CH_WRITE=7;
   
       String file;
  -    ThreadPool tp;
  +    ThreadPool tp = ThreadPool.createThreadPool(true);
   
       /* ==================== Tcp socket options ==================== */
   
  @@ -129,18 +137,41 @@
                   next=wEnv.getHandler( "request" );
           }
   
  -        tp=new ThreadPool();
  -                
           super.initJkComponent();
  -        
  -        log.info("JK: listening on unix socket: " + file );
  -        
  +        JMXRequestNote =wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "requestNote");    
    
           // Run a thread that will accept connections.
  +        if( this.domain != null ) {
  +            try {
  +                tpOName=new ObjectName(domain + ":type=ThreadPool,name=" + 
  +                                    getChannelName());
  +
  +                Registry.getRegistry(null, null)
  +                 .registerComponent(tp, tpOName, null);
  +
  +             rgOName = new ObjectName
  +                 (domain+":type=GlobalRequestProcessor,name=" + getChannelName());
  +             Registry.getRegistry(null, null)
  +                 .registerComponent(global, rgOName, null);
  +            } catch (Exception e) {
  +                log.error("Can't register threadpool" );
  +            }
  +        }
           tp.start();
           AprAcceptor acceptAjp=new AprAcceptor(  this );
           tp.runIt( acceptAjp);
  +        log.info("JK: listening on unix socket: " + file );
  +        
       }
  -    
  +
  +    ObjectName tpOName;
  +    ObjectName rgOName;
  +    RequestGroupInfo global=new RequestGroupInfo();
  +    int count = 0;
  +    int JMXRequestNote;
  +
  +    public void start() throws IOException {
  +    }
  +
       public void destroy() throws IOException {
           if( apr==null ) return;
           try {
  @@ -149,12 +180,37 @@
               
               //apr.unSocketClose( unixListenSocket,3);
               super.destroyJkComponent();
  -            
  +
  +            if(tpOName != null) {
  +             Registry.getRegistry().unregisterComponent(tpOName);
  +         }
  +         if(rgOName != null) {
  +             Registry.getRegistry().unregisterComponent(rgOName);
  +         }
           } catch(Exception e) {
  -            e.printStackTrace();
  +            log.error("Error in destroy",e);
           }
       }
   
  +    public void registerRequest(Request req, MsgContext ep, int count) {
  +     if(this.domain != null) {
  +         try {
  +
  +             RequestInfo rp=req.getRequestProcessor();
  +             rp.setGlobalProcessor(global);
  +             ObjectName roname = new ObjectName
  +                 (getDomain() + ":type=RequestProcessor,worker="+
  +                  getChannelName()+",name=JkRequest" +count);
  +             ep.setNote(JMXRequestNote, roname);
  +                        
  +             Registry.getRegistry().registerComponent( rp, roname, null);
  +         } catch( Exception ex ) {
  +             log.warn("Error registering request");
  +         }
  +     }
  +    }
  +
  +
       /** Open a connection - since we're listening that will block in
           accept
       */
  @@ -192,7 +248,15 @@
   
        return msg.getLen();
       }
  -    
  +
  +    public int flush( Msg msg, MsgContext ep) throws IOException {
  +     return OK;
  +    }
  +
  +    public boolean isSameAddress( MsgContext ep ) {
  +     return false; // Not supporting shutdown on this channel.
  +    }
  +
       boolean running=true;
       
       /** Accept incoming connections, dispatch to the thread pool
  @@ -245,12 +309,12 @@
               if( log.isDebugEnabled() )
                   log.debug( "Closing un channel");
               try{
  -                MsgAjp endM = new MsgAjp();
  -                endM.reset();
  -                endM.appendByte((byte)HANDLE_THREAD_END);
  -                endM.end();
  -                endM.processHeader();
  -                next.invoke(endM, ep);
  +                Request req = (Request)ep.getRequest();
  +                if( req != null ) {
  +                    ObjectName roname = (ObjectName)ep.getNote(JMXRequestNote);
  +                    Registry.getRegistry().unregisterComponent(roname);
  +                    req.getRequestProcessor().setGlobalProcessor(null);
  +                }
               } catch( Exception ee) {
                   log.error( "Error, releasing connection",ee);
               }
  @@ -269,11 +333,23 @@
           case JkHandler.HANDLE_SEND_PACKET:
               return send( msg, ep );
           case JkHandler.HANDLE_FLUSH:
  -            return OK;
  +            return flush( msg, ep );
           }
   
           // return next.invoke( msg, ep );
           return OK;
  +    }
  +
  +    public String getChannelName() {
  +        String encodedAddr = "";
  +        String address = file;
  +        if (address != null) {
  +            encodedAddr = "" + address;
  +            if (encodedAddr.startsWith("/"))
  +                encodedAddr = encodedAddr.substring(1);
  +            encodedAddr = URLEncoder.encode(encodedAddr) ;
  +        }
  +        return ("jk-" + encodedAddr);
       }
   
       private static org.apache.commons.logging.Log log=
  
  
  
  1.36      +11 -42    
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java
  
  Index: HandlerRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/HandlerRequest.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- HandlerRequest.java       4 Apr 2004 19:09:38 -0000       1.35
  +++ HandlerRequest.java       31 May 2004 04:48:54 -0000      1.36
  @@ -33,6 +33,7 @@
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
   import org.apache.jk.core.WorkerEnv;
  +import org.apache.jk.core.JkChannel;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.CharChunk;
   import org.apache.tomcat.util.buf.HexUtils;
  @@ -220,7 +221,6 @@
           bodyNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "jkInputStream" );
           tmpBufNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "tmpBuf" );
           secretNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "secret" );
  -        JMXRequestNote =wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "requestNote");
   
           if( next==null )
               next=wEnv.getHandler( "container" );
  @@ -317,7 +317,6 @@
       int bodyNote;
       int tmpBufNote;
       int secretNote;
  -    int JMXRequestNote;
   
       boolean decoded=true;
       boolean tomcatAuthentication=true;
  @@ -393,13 +392,11 @@
               }
   
               // XXX add isSameAddress check
  -            JkHandler ch=ep.getSource();
  -            if( ch instanceof ChannelSocket ) {
  -                if( ! ((ChannelSocket)ch).isSameAddress(ep) ) {
  -                    log.error("Shutdown request not from 'same address' ");
  -                    return ERROR;
  -                }
  -            }
  +            JkChannel ch=ep.getSource();
  +         if( !ch.isSameAddress(ep) ) {
  +             log.error("Shutdown request not from 'same address' ");
  +             return ERROR;
  +         }
   
               // forward to the default handler - it'll do the shutdown
               next.invoke( msg, ep );
  @@ -414,19 +411,10 @@
               msg.reset();
               msg.appendByte(JK_AJP13_CPONG_REPLY);
               ep.setType( JkHandler.HANDLE_SEND_PACKET );
  -            ep.getSource().invoke( msg, ep );
  -                        
  -             return OK;
  +            ep.getSource().send( msg, ep );
  +         return OK;
   
           case HANDLE_THREAD_END:
  -            if(registerRequests) {
  -                Request req = (Request)ep.getRequest();
  -                if( req != null ) {
  -                    ObjectName roname = (ObjectName)ep.getNote(JMXRequestNote);
  -                    Registry.getRegistry().unregisterComponent(roname);
  -                    req.getRequestProcessor().setGlobalProcessor(null);
  -                }
  -            }
               return OK;
   
           default:
  @@ -436,8 +424,7 @@
           return OK;
       }
   
  -    static int count=0;
  -    RequestGroupInfo global=null;
  +    static int count = 0;
   
       private int decodeRequest( Msg msg, MsgContext ep, MessageBytes tmpMB )
           throws IOException
  @@ -449,26 +436,8 @@
               Response res=new Response();
               req.setResponse(res);
               ep.setRequest( req );
  -            if( registerRequests && this.getDomain() != null ) {
  -                try {
  -                    if( global==null ) {
  -                        global=new RequestGroupInfo();
  -                        Registry.getRegistry().registerComponent( global,
  -                                getDomain(), "GlobalRequestProcessor",
  -                                "type=GlobalRequestProcessor,name=jk");
  -                    }
  -
  -                    RequestInfo rp=req.getRequestProcessor();
  -                    rp.setGlobalProcessor(global);
  -                    ObjectName roname = new ObjectName(getDomain() + 
  -                                       ":type=RequestProcessor,name=JkRequest" 
+count++);
  -                    ep.setNote(JMXRequestNote, roname);
  -                        
  -                    Registry.getRegistry().registerComponent( rp,
  -                                                              roname, null);
  -                } catch( Exception ex ) {
  -                    log.warn("Error registering request");
  -                }
  +            if( registerRequests ) {
  +             ep.getSource().registerRequest(req, ep, count++);
               }
           }
   
  
  
  
  1.16      +2 -2      
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JkInputStream.java
  
  Index: JkInputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JkInputStream.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JkInputStream.java        5 Mar 2004 05:12:56 -0000       1.15
  +++ JkInputStream.java        31 May 2004 04:48:54 -0000      1.16
  @@ -244,7 +244,7 @@
       {
           mc.setType( JkHandler.HANDLE_RECEIVE_PACKET );
           bodyMsg.reset();
  -        int err = mc.getSource().invoke(bodyMsg, mc);
  +        int err = mc.getSource().receive(bodyMsg, mc);
           if( log.isDebugEnabled() )
               log.info( "Receiving: getting request body chunk " + err + " " + 
bodyMsg.getLen() );
           
  @@ -310,7 +310,7 @@
               log.debug("refillReadBuffer " + Thread.currentThread());
   
           mc.setType( JkHandler.HANDLE_SEND_PACKET );
  -     mc.getSource().invoke(bodyMsg, mc);
  +     mc.getSource().send(bodyMsg, mc);
   
           // In JNI mode, response will be in bodyMsg. In TCP mode, response need to 
be
           // read
  
  
  
  1.16      +4 -3      
jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JniHandler.java
  
  Index: JniHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/JniHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JniHandler.java   24 Feb 2004 08:48:42 -0000      1.15
  +++ JniHandler.java   31 May 2004 04:48:54 -0000      1.16
  @@ -25,6 +25,7 @@
   import org.apache.jk.core.JkHandler;
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
  +import org.apache.jk.core.JkChannel;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.C2BConverter;
   import org.apache.tomcat.util.buf.MessageBytes;
  @@ -169,21 +170,21 @@
               MsgContext msgCtx=new MsgContext();
               MsgAjp msg=new MsgAjp();
   
  -            msgCtx.setSource( this );
  +            msgCtx.setSource( (JkChannel)this );
               msgCtx.setWorkerEnv( wEnv );
   
               msgCtx.setNext( this );
   
               msgCtx.setMsg( MSG_NOTE, msg); // XXX Use noteId
   
  -            C2BConverter c2b=new C2BConverter(  "UTF8" );
  +            C2BConverter c2b=new C2BConverter(  "iso-8859-1" );
               msgCtx.setNote( C2B_NOTE, c2b );
   
               MessageBytes tmpMB=new MessageBytes();
               msgCtx.setNote( MB_NOTE, tmpMB );
               return msgCtx;
           } catch( Exception ex ) {
  -            ex.printStackTrace();
  +            log.error("Can't create endpoint", ex);
               return null;
           }
       }
  
  
  
  1.10      +3 -3      
jakarta-tomcat-connectors/jk/java/org/apache/jk/core/MsgContext.java
  
  Index: MsgContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/core/MsgContext.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MsgContext.java   24 Feb 2004 08:48:43 -0000      1.9
  +++ MsgContext.java   31 May 2004 04:48:54 -0000      1.10
  @@ -31,7 +31,7 @@
       private int type;
       private Object notes[]=new Object[32];
       private JkHandler next;
  -    private JkHandler source;
  +    private JkChannel source;
       private Object req;
       private WorkerEnv wEnv;
       private Msg msgs[]=new Msg[10];
  @@ -86,11 +86,11 @@
           this.wEnv=we;
       }
       
  -    public final JkHandler getSource() {
  +    public final JkChannel getSource() {
           return source;
       }
       
  -    public final void setSource(JkHandler ch) {
  +    public final void setSource(JkChannel ch) {
           this.source=ch;
       }
   
  
  
  
  1.3       +67 -96    
jakarta-tomcat-connectors/jk/java/org/apache/jk/core/JkChannel.java
  
  
  
  
  1.55      +6 -5      
jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java
  
  Index: JkCoyoteHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- JkCoyoteHandler.java      20 May 2004 07:17:23 -0000      1.54
  +++ JkCoyoteHandler.java      31 May 2004 04:48:54 -0000      1.55
  @@ -43,6 +43,7 @@
   import org.apache.jk.core.Msg;
   import org.apache.jk.core.MsgContext;
   import org.apache.jk.core.WorkerEnv;
  +import org.apache.jk.core.JkChannel;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.C2BConverter;
   import org.apache.tomcat.util.buf.MessageBytes;
  @@ -248,7 +249,7 @@
               msg.appendBytes( chunk.getBytes(), chunk.getOffset() + off, thisTime );
               off+=thisTime;
               ep.setType( JkHandler.HANDLE_SEND_PACKET );
  -            ep.getSource().invoke( msg, ep );
  +            ep.getSource().send( msg, ep );
           }
           return 0;
       }
  @@ -393,7 +394,7 @@
               msg.appendBytes( hV );
           }
           ep.setType( JkHandler.HANDLE_SEND_PACKET );
  -        ep.getSource().invoke( msg, ep );
  +        ep.getSource().send( msg, ep );
       }
       
       // -------------------- Coyote Action implementation --------------------
  @@ -419,7 +420,7 @@
                   org.apache.coyote.Response res=(org.apache.coyote.Response)param;
                   MsgContext ep=(MsgContext)res.getNote( epNote );
                   ep.setType( JkHandler.HANDLE_FLUSH );
  -                ep.getSource().invoke( null, ep );
  +                ep.getSource().flush( null, ep );
                   
               } else if( actionCode==ActionCode.ACTION_CLOSE ) {
                   if( log.isDebugEnabled() ) log.debug("CLOSE " );
  @@ -442,10 +443,10 @@
   
                   try {                
                       ep.setType( JkHandler.HANDLE_SEND_PACKET );
  -                    ep.getSource().invoke( msg, ep );
  +                    ep.getSource().send( msg, ep );
   
                       ep.setType( JkHandler.HANDLE_FLUSH );
  -                    ep.getSource().invoke( msg, ep );
  +                    ep.getSource().flush( msg, ep );
                   } catch(IOException iex) {
                       log.debug("Connection error ending request.",iex);
                   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to