cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/common ChannelSocket.java ChannelUn.java

2004-11-19 Thread billbarker
billbarker2004/11/19 18:39:34

  Modified:jk/java/org/apache/jk/common ChannelSocket.java
ChannelUn.java
  Log:
  It seems that the 1.5 JVM is less tolarant of 'null' ONames.
  
  Reported By: Allistair Crossley [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.49  +3 -1  
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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- ChannelSocket.java17 Sep 2004 04:08:53 -  1.48
  +++ ChannelSocket.java20 Nov 2004 02:39:34 -  1.49
  @@ -703,7 +703,9 @@
   Request req = (Request)ep.getRequest();
   if( req != null ) {
   ObjectName roname = 
(ObjectName)ep.getNote(JMXRequestNote);
  -Registry.getRegistry().unregisterComponent(roname);
  +if( roname != null ) {
  +Registry.getRegistry().unregisterComponent(roname);
  +}
   req.getRequestProcessor().setGlobalProcessor(null);
   }
   } catch( Exception ee) {
  
  
  
  1.29  +3 -1  
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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ChannelUn.java31 May 2004 04:48:54 -  1.28
  +++ ChannelUn.java20 Nov 2004 02:39:34 -  1.29
  @@ -312,7 +312,9 @@
   Request req = (Request)ep.getRequest();
   if( req != null ) {
   ObjectName roname = 
(ObjectName)ep.getNote(JMXRequestNote);
  -Registry.getRegistry().unregisterComponent(roname);
  +if( roname != null ) {
  +Registry.getRegistry().unregisterComponent(roname);
  +}
   req.getRequestProcessor().setGlobalProcessor(null);
   }
   } catch( Exception ee) {
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/common ChannelSocket.java ChannelUn.java

2002-04-18 Thread costin

costin  02/04/18 12:12:36

  Modified:jk/java/org/apache/jk/common ChannelSocket.java
ChannelUn.java
  Log:
  Allow a 'range' of ports to be used.
  
  This allows multiple tomcats to be started on the same machine with the
  same configuration - and get consecutive sockets ( tcp and unix ) automatically.
  Needed for jni, it also simplify the configuration of lb workers - no need
  to use separate config files for each worker ( on a machine ).
  
  The port will also determine the local part of the instance ID ( the hostname
  or address should form the other part - and we need a way to push this up
  into the coyote and container ).
  
  If Shm is detected it'll set the instance id based on the shared memory
  protocol ( i.e. each worker will get a unique id based on the position
  of the worker def in the shared mem ) .
  
  Revision  ChangesPath
  1.9   +49 -3 
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ChannelSocket.java17 Apr 2002 22:38:16 -  1.8
  +++ ChannelSocket.java18 Apr 2002 19:12:36 -  1.9
  @@ -98,7 +98,9 @@
   private static org.apache.commons.logging.Log log=
   org.apache.commons.logging.LogFactory.getLog( ChannelSocket.class );
   
  -int port=8009;
  +int startPort=8009;
  +int maxPort=8019; // 0 for backward compat.
  +int port=startPort;
   InetAddress inet;
   int serverTimeout;
   boolean tcpNoDelay;
  @@ -112,9 +114,18 @@
   public ThreadPool getThreadPool() {
   return tp;
   }
  -
  +
  +/** Set the port for the ajp13 channel.
  + *  To support seemless load balancing and jni, we treat this
  + *  as the 'base' port - we'll try up until we find one that is not
  + *  used. We'll also provide the 'difference' to the main coyote
  + *  handler - that will be our 'sessionID' and the position in
  + *  the scoreboard and the suffix for the unix domain socket.
  + */
   public void setPort( int port ) {
  +this.startPort=port;
   this.port=port;
  +this.maxPort=port+10;
   }
   
   public void setAddress(InetAddress inet) {
  @@ -153,6 +164,14 @@
socketTimeout=i;
   }
   
  +public void setMaxPort( int i ) {
  +maxPort=i;
  +}
  +
  +public int getInstanceId() {
  +return port-startPort;
  +}
  +
   /*   */
   ServerSocket sSocket;
   int socketNote=1;
  @@ -160,6 +179,7 @@
   int osNote=3;
   
   public void accept( MsgContext ep ) throws IOException {
  +if( sSocket==null ) return;
   Socket s=sSocket.accept();
   ep.setNote( socketNote, s );
   if(log.isDebugEnabled() )
  @@ -176,7 +196,33 @@
   }
   
   public void init() throws IOException {
  -sSocket=new ServerSocket( port );
  +// Find a port.
  +if( maxPortstartPort) maxPort=startPort;
  +
  +for( int i=startPort; i=maxPort; i++ ) {
  +try {
  +sSocket=new ServerSocket( i );
  +port=i;
  +break;
  +} catch( IOException ex ) {
  +log.info(Port busy  + i +   + ex.toString());
  +continue;
  +}
  +}
  +
  +if( sSocket==null ) {
  +log.error(Can't find free port  + startPort +   + maxPort );
  +return;
  +}
  +log.info(Init  + port );
  +
  +// If this is not the base port and we are the 'main' channleSocket and
  +// SHM didn't already set the localId - we'll set the instance id
  +if( channelSocket.equals( name ) 
  +port != startPort 
  +(wEnv.getLocalId()==0) ) {
  +wEnv.setLocalId(  port - startPort );
  +}
   if( serverTimeout  0 )
   sSocket.setSoTimeout( serverTimeout );
   
  
  
  
  1.14  +4 -0  
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ChannelUn.java18 Apr 2002 17:44:49 -  1.13
  +++ ChannelUn.java18 Apr 2002 19:12:36 -  1.14
  @@ -136,6 +136,10 @@
   log.error(No file, disabling unix channel);
   return;
   }
  +if( wEnv.getLocalId() != 0 ) {
  +file=file+ wEnv.getLocalId();
  +

cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/common ChannelSocket.java ChannelUn.java

2002-04-17 Thread costin

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  ChangesPath
  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.java27 Feb 2002 06:41:18 -  1.7
  +++ ChannelSocket.java17 Apr 2002 22:38:16 -  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.java16 Apr 2002 00:21:37 -  1.11
  +++ ChannelUn.java17 Apr 2002 22:38:16 -  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 ) 

cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/common ChannelSocket.java ChannelUn.java

2002-01-25 Thread costin

costin  02/01/25 23:25:09

  Modified:jk/java/org/apache/jk/common ChannelSocket.java
ChannelUn.java
  Log:
  Updates, fixes.
  
  Revision  ChangesPath
  1.3   +80 -25
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChannelSocket.java16 Jan 2002 15:38:29 -  1.2
  +++ ChannelSocket.java26 Jan 2002 07:25:09 -  1.3
  @@ -94,7 +94,7 @@
*
* @author Costin Manolache
*/
  -public class ChannelSocket extends JkChannel implements Channel {
  +public class ChannelSocket extends Channel {
   
   int port;
   InetAddress inet;
  @@ -103,8 +103,6 @@
   int linger=100;
   int socketTimeout;
   
  -Worker worker;
  -
   ThreadPool tp=new ThreadPool();
   
   /*  Tcp socket options  */
  @@ -117,14 +115,6 @@
   this.port=port;
   }
   
  -public void setWorker( Worker w ) {
  -worker=w;
  -}
  -
  -public Worker getWorker() {
  -return worker;
  -}
  -
   public void setAddress(InetAddress inet) {
   this.inet=inet;
   }
  @@ -214,10 +204,70 @@
   }
   }
   
  -public void write( Endpoint ep, byte[] b, int offset, int len) throws 
IOException {
  +public int send( Msg msg, Endpoint ep)
  +throws IOException
  +{
  +msg.end(); // Write the packet header
  +byte buf[]=msg.getBuffer();
  +int len=msg.getLen();
  +
  +if(dL  5 )
  +d(send()  + len +   + buf[4] );
  +
   OutputStream os=(OutputStream)ep.getNote( osNote );
  +os.write( buf, 0, len );
  +return len;
  +}
  +
  +public int receive( Msg msg, Endpoint ep )
  +throws IOException
  +{
  +if (dL  0) {
  +d(receive());
  +}
  +
  +byte buf[]=msg.getBuffer();
  +int hlen=msg.getHeaderLength();
  +
  + // XXX If the length in the packet header doesn't agree with the
  + // actual number of bytes read, it should probably return an error
  + // value.  Also, callers of this method never use the length
  + // returned -- should probably return true/false instead.
  +
  +int rd = this.read(ep, buf, 0, hlen );
  +
  +if(rd  0) {
  +// Most likely normal apache restart.
  +return rd;
  +}
  +
  +msg.processHeader();
   
  -os.write( b, offset, len );
  +/* After processing the header we know the body
  +   length
  +*/
  +int blen=msg.getLen();
  +
  + // XXX check if enough space - it's assert()-ed !!!
  +
  + int total_read = 0;
  +
  +total_read = this.read(ep, buf, hlen, blen);
  +
  +if (total_read = 0) {
  +d(can't read body, waited # + blen);
  +return  -1;
  +}
  +
  +if (total_read != blen) {
  + d( incomplete read, waited # + blen +
  + got only  + total_read);
  +return -2;
  +}
  +
  +if (dL  0)
  + d(receive:  total read =  + total_read);
  + return total_read;
   }
   
   /**
  @@ -228,24 +278,27 @@
*
* from read() Linux manual
*
  - * On success, the number of bytes read is returned (zero indicates end of 
file),
  - * and the file position is advanced by this number.
  - * It is not an error if this number is smaller than the number of bytes 
requested;
  - * this may happen for example because fewer bytes
  - * are actually available right now (maybe because we were close to end-of-file,
  - * or because we are reading from a pipe, or  from  a
  + * On success, the number of bytes read is returned (zero indicates end
  + * of file),and the file position is advanced by this number.
  + * It is not an error if this number is smaller than the number of bytes
  + * requested; this may happen for example because fewer bytes
  + * are actually available right now (maybe because we were close to
  + * end-of-file, or because we are reading from a pipe, or  from  a
* terminal),  or  because  read()  was interrupted by a signal.
* On error, -1 is returned, and errno is set appropriately. In this
* case it is left unspecified whether the file position (if any) changes.
*
**/
  -public int read( Endpoint ep, byte[] b, int offset, int len) throws IOException 
{
  +public int read( Endpoint ep, byte[] b, int offset, int len)
  +throws