costin 02/04/17 15:38:16 Modified: jk/java/org/apache/jk/common ChannelSocket.java ChannelUn.java Log: Update for the interface changes. Revision Changes Path 1.8 +29 -10 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ChannelSocket.java 27 Feb 2002 06:41:18 -0000 1.7 +++ ChannelSocket.java 17 Apr 2002 22:38:16 -0000 1.8 @@ -94,7 +94,7 @@ * * @author Costin Manolache */ -public class ChannelSocket extends Channel { +public class ChannelSocket extends JkHandler { private static org.apache.commons.logging.Log log= org.apache.commons.logging.LogFactory.getLog( ChannelSocket.class ); @@ -180,6 +180,15 @@ if( serverTimeout > 0 ) sSocket.setSoTimeout( serverTimeout ); + if( next==null ) { + if( nextName!=null ) + setNext( wEnv.getHandler( nextName ) ); + if( next==null ) + next=wEnv.getHandler( "dispatch" ); + if( next==null ) + next=wEnv.getHandler( "request" ); + } + // Run a thread that will accept connections. tp.start(); SocketAcceptor acceptAjp=new SocketAcceptor( this ); @@ -329,13 +338,6 @@ return pos; } - public MsgContext createEndpoint() { - MsgContext mc=new MsgContext(); - mc.setChannel(this); - mc.setWorkerEnv( wEnv ); - return mc; - } - boolean running=true; /** Accept incoming connections, dispatch to the thread pool @@ -345,7 +347,9 @@ log.debug("Accepting ajp connections on " + port); while( running ) { try { - MsgContext ep=this.createEndpoint(); + MsgContext ep=new MsgContext(); + ep.setSource(this); + ep.setWorkerEnv( wEnv ); this.accept(ep); SocketConnection ajpConn= new SocketConnection(this, ep); @@ -367,7 +371,8 @@ log.warn("Invalid packet, closing connection" ); break; } - + + ep.setType( 0 ); status= this.invoke( recv, ep ); if( status!= JkHandler.OK ) { log.warn("processCallbacks status " + status ); @@ -380,6 +385,20 @@ } } + + public int invoke( Msg msg, MsgContext ep ) throws IOException { + int type=ep.getType(); + + switch( type ) { + case JkHandler.HANDLE_RECEIVE_PACKET: + return receive( msg, ep ); + case JkHandler.HANDLE_SEND_PACKET: + return send( msg, ep ); + } + + return next.invoke( msg, ep ); + } + public boolean isSameAddress(MsgContext ep) { Socket s=(Socket)ep.getNote( socketNote ); return isSameAddress( s.getLocalAddress(), s.getInetAddress()); 1.12 +38 -29 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ChannelUn.java 16 Apr 2002 00:21:37 -0000 1.11 +++ ChannelUn.java 17 Apr 2002 22:38:16 -0000 1.12 @@ -77,10 +77,10 @@ * * @author Costin Manolache */ -public class ChannelUn extends Channel { +public class ChannelUn extends JkHandler { String file; - ThreadPool tp=new ThreadPool(); + ThreadPool tp; String jkHome; String aprHome; @@ -126,26 +126,21 @@ } public void init() throws IOException { - apr=AprImpl.getAprImpl(); - if( aprHome==null && jkHome != null ) { - File f=new File( jkHome ); - File aprBase=new File( jkHome, "jk2/jni" ); - if( aprBase.exists() ) { - aprHome=aprBase.getAbsolutePath(); - } - } - if( aprHome != null ) { - apr.setBaseDir( aprHome ); - } - try { - apr.loadNative(); - - apr.initialize(); - } catch( Throwable t ) { - log.error("Native code not initialized, disabling UnixSocket and JNI channels: " + t.toString()); + apr=(AprImpl)wEnv.getHandler("apr"); + if( apr==null ) { + log.error("Apr is not available, disabling unix channel "); return; } - + if( next==null ) { + if( nextName!=null ) + setNext( wEnv.getHandler( nextName ) ); + if( next==null ) + next=wEnv.getHandler( "dispatch" ); + if( next==null ) + next=wEnv.getHandler( "request" ); + } + + tp=new ThreadPool(); if( log.isDebugEnabled() ) log.debug( "Creating pool " + gPool ); gPool=apr.poolCreate( 0 ); @@ -295,13 +290,12 @@ } - - public MsgContext createEndpoint() { - MsgContext mc=new MsgContext(); - mc.setChannel( this ); - mc.setWorkerEnv( wEnv ); - return mc; - } +// public MsgContext createEndpoint() { +// MsgContext mc=new MsgContext(); +// mc.setChannel( this ); +// mc.setWorkerEnv( wEnv ); +// return mc; +// } boolean running=true; @@ -312,7 +306,9 @@ log.debug("Accepting ajp connections on " + file); while( running ) { try { - MsgContext ep=this.createEndpoint(); + MsgContext ep=new MsgContext(); + ep.setSource( this ); + ep.setWorkerEnv( wEnv ); this.accept(ep); AprConnection ajpConn= new AprConnection(this, ep); @@ -336,6 +332,7 @@ // EOS break; } + ep.setType(0); int status=this.invoke( recv, ep ); } this.close( ep ); @@ -344,9 +341,21 @@ } } + public int invoke( Msg msg, MsgContext ep ) throws IOException { + int type=ep.getType(); + + switch( type ) { + case JkHandler.HANDLE_RECEIVE_PACKET: + return receive( msg, ep ); + case JkHandler.HANDLE_SEND_PACKET: + return send( msg, ep ); + } + + return next.invoke( msg, ep ); + } + private static org.apache.commons.logging.Log log= org.apache.commons.logging.LogFactory.getLog( ChannelUn.class ); - } class AprAcceptor implements ThreadPoolRunnable {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>