Another thing we may change in Ajp13Interceptor.java, is
setSoLinger() which could delays too much connections close.

cf: bug regarding apache threads against ajp13 threads....


-
Henri Gomez                 ___[_]____
EMAIL : [EMAIL PROTECTED]        (. .)                     
PGP KEY : 697ECEDD    ...oOOo..(_)..oOOo...
PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 



>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, August 29, 2001 7:08 AM
>To: [EMAIL PROTECTED]
>Subject: cvs commit:
>jakarta-tomcat/src/share/org/apache/tomcat/modules/server Ajp13.java
>Ajp13Interceptor.java Ajp13Packet.java
>
>
>costin      01/08/28 22:08:07
>
>  Modified:    src/share/org/apache/tomcat/modules/server Ajp13.java
>                        Ajp13Interceptor.java Ajp13Packet.java
>  Log:
>  Bug fix - under certain conditions the POST data was messed up. This
>  doesn't happen with browsers, but it did happened with the 
>test application,
>  because the body was sent in a different tcp packet. We do receive a
>  body packet just after the headers ( we could delay that - 
>in ajp14 ), and
>  this can be void.
>  
>  Improved debugging ( part of the search for the bug )
>  
>  Revision  Changes    Path
>  1.23      +38 -7     
>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/se
>rver/Ajp13.java,v
>  retrieving revision 1.22
>  retrieving revision 1.23
>  diff -u -r1.22 -r1.23
>  --- Ajp13.java       2001/08/23 03:08:39     1.22
>  +++ Ajp13.java       2001/08/29 05:08:07     1.23
>  @@ -211,6 +211,7 @@
>         // This is a touch cargo-cultish, but I think wise.
>         blen = 0; 
>         pos = 0;
>  +      if( dL>0 ) d( "recycle()");
>         headersWriter.recycle();
>       }
>       
>  @@ -382,6 +383,7 @@
>       // immediately after
>       MessageBytes clB=headers.getValue("content-length");
>           int contentLength = (clB==null) ? -1 : clB.getInt();
>  +    if( dL > 0 ) d("Content-Length: " + contentLength );
>               if(contentLength > 0) {
>           req.setContentLength( contentLength );
>           /* Read present data */
>  @@ -389,10 +391,18 @@
>               if(err < 0) {
>                       return 500;
>           }
>  -        
>  -        blen = inBuf.peekInt();
>  +
>  +        // We may get an empty packet ( no data available 
>right now )
>           pos = 0;
>  -        inBuf.getBytes(bodyBuff);
>  +        blen=0;
>  +        if( inBuf.getLen() != 0 ) {
>  +            blen = inBuf.peekInt();
>  +            int cpl=inBuf.getBytes(bodyBuff);
>  +            if( dL > 0 )
>  +                d( "Copy into body buffer " + bodyBuff + " " + cpl
>  +                   + " " + blen + " " + new String( 
>bodyBuff, 0, cpl ));
>  +        }
>  +            
>               }
>       
>           return 200; // Success
>  @@ -438,6 +448,9 @@
>       if(pos + len <= blen) { // Fear the off by one error
>           // Sanity check b.length > off + len?
>           System.arraycopy(bodyBuff, pos, b, off, len);
>  +        if( dL > 0 )
>  +            d("doRead1: " + pos + " " + len + " " + blen + " " +
>  +              new String( b, off, len ) + " " + 
>Thread.currentThread());
>           pos += len;
>           return len;
>       }
>  @@ -451,6 +464,9 @@
>           int c = bytesRemaining < toCopy ? bytesRemaining : toCopy;
>   
>           System.arraycopy(bodyBuff, pos, b, off, c);
>  +        if( dL > 0 ) d("doRead2: " + pos + " " + len + " " 
>+ blen + " " + c +
>  +                       " " + new String( b, off, len ) + " " +
>  +                       new String( bodyBuff, pos, len ));
>   
>           toCopy    -= c;
>   
>  @@ -481,20 +497,28 @@
>       inBuf.reset();
>       inBuf.appendByte(JK_AJP13_GET_BODY_CHUNK);
>       inBuf.appendInt(MAX_READ_SIZE);
>  +    if( dL>0 ) d("refillReadBuffer " + Thread.currentThread());
>       send(inBuf);
>       
>       int err = receive(inBuf);
>           if(err < 0) {
>           throw new IOException();
>       }
>  -    
>  +
>  +    // No data received.
>  +    if( inBuf.getLen() == 0 ) {
>  +        pos=0;
>  +        blen=0;
>  +        return false;
>  +    }
>               blen = inBuf.peekInt();
>               pos = 0;
>  -            inBuf.getBytes(bodyBuff);
>  +            int cpl=inBuf.getBytes(bodyBuff);
>  +    if( dL > 0 ) d( "Copy into body buffer2 " + bodyBuff + 
>" " + cpl + " " + blen + " "  +
>  +                        new String( bodyBuff, 0, cpl ));
>   
>       return (blen > 0);
>  -    }    
>  -
>  +    }
>       // ==================== Servlet Output Support =================
>       
>       /**
>  @@ -665,6 +689,7 @@
>           }
>                   total_read += rd;
>       }
>  +    if( dL>0 ) msg.dump("Ajp13.receive() " + rd + " " + len );
>       return total_read;
>       }
>   
>  @@ -679,6 +704,7 @@
>       byte b[] = msg.getBuff();
>       int len  = msg.getLen();
>       out.write( b, 0, len );
>  +    if( dL>0 ) msg.dump("Ajp13.send()");
>       }
>       
>       /**
>  @@ -695,5 +721,10 @@
>       if(null !=in) {
>           in.close();
>       }
>  +    }
>  +
>  +    private static final int dL=0;
>  +    private void d(String s ) {
>  +    System.err.println( "Ajp13: " + s );
>       }
>   }
>  
>  
>  
>  1.12      +13 -5     
>jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13
>Interceptor.java
>  
>  Index: Ajp13Interceptor.java
>  ===================================================================
>  RCS file: 
>/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/se
>rver/Ajp13Interceptor.java,v
>  retrieving revision 1.11
>  retrieving revision 1.12
>  diff -u -r1.11 -r1.12
>  --- Ajp13Interceptor.java    2001/08/24 04:38:50     1.11
>  +++ Ajp13Interceptor.java    2001/08/29 05:08:07     1.12
>  @@ -1,7 +1,7 @@
>   /*
>  - * $Header: 
>/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/se
>rver/Ajp13Interceptor.java,v 1.11 2001/08/24 04:38:50 costin Exp $
>  - * $Revision: 1.11 $
>  - * $Date: 2001/08/24 04:38:50 $
>  + * $Header: 
>/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/se
>rver/Ajp13Interceptor.java,v 1.12 2001/08/29 05:08:07 costin Exp $
>  + * $Revision: 1.12 $
>  + * $Date: 2001/08/29 05:08:07 $
>    *
>    * 
>====================================================================
>    *
>  @@ -231,13 +231,16 @@
>       
>       public int doRead(byte[] b, int off, int len) throws 
>IOException 
>       {
>  +    int rd=-1;
>       if( contentLength == -1 ) {
>  -        return ajp13.doRead(b,off,len);
>  +        rd=ajp13.doRead(b,off,len);
>  +        return rd;
>       }
>       if( available <= 0 )
>           return -1;
>  -    int rd=ajp13.doRead( b,off, len );
>  +    rd=ajp13.doRead( b,off, len );
>       available -= rd;
>  +    if( dL > 0 ) d("Read: " + new String( b,off, len ));
>       return rd;
>       }
>       
>  @@ -245,6 +248,11 @@
>       {
>           super.recycle();
>       if( ajp13!=null) ajp13.recycle();
>  +    }
>  +
>  +    private static final int dL=10;
>  +    private void d(String s ) {
>  +    System.err.println( "Ajp13Request: " + s );
>       }
>   }
>   
>  
>  
>  
>  1.3       +25 -13    
>jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Ajp13
>Packet.java
>  
>  Index: Ajp13Packet.java
>  ===================================================================
>  RCS file: 
>/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/se
>rver/Ajp13Packet.java,v
>  retrieving revision 1.2
>  retrieving revision 1.3
>  diff -u -r1.2 -r1.3
>  --- Ajp13Packet.java 2001/08/12 02:13:53     1.2
>  +++ Ajp13Packet.java 2001/08/29 05:08:07     1.3
>  @@ -365,9 +365,9 @@
>           System.out.println("null string " + length);
>           return 0;
>       }
>  -    
>  +
>       System.arraycopy( buff, pos,  dest, 0, length );
>  -    pos += length;
>  +    pos += length; 
>       pos++; // Skip terminating \0  XXX I believe this is 
>wrong but harmless
>       return length;
>       }
>  @@ -380,29 +380,41 @@
>       return h.substring( h.length() - 2 );
>       }
>       
>  -    private void hexLine( int start ) {
>  +    private void hexLine( int start , StringBuffer sb) {
>       for( int i=start; i< start+16 ; i++ ) {
>           if( i < len + 4)
>  -            System.out.print( hex( buff[i] ) + " ");
>  +            sb.append( hex( buff[i] ) + " ");
>           else 
>  -            System.out.print( "   " );
>  +            sb.append( "   " );
>       }
>  -    System.out.print(" | ");
>  +    sb.append(" | ");
>       for( int i=start; i < start+16 && i < len + 4; i++ ) {
>  -        if( Character.isLetterOrDigit( (char)buff[i] ))
>  -            System.out.print( new Character((char)buff[i]) );
>  +        char c=(char)buff[i];
>  +        if( ! Character.isISOControl(c) &&
>  +            Character.isDefined(c) )
>  +            sb.append( c );
>  +        else if( c==(char)0x20 )
>  +            sb.append( c );
>           else
>  -            System.out.print( "." );
>  +            sb.append( "." );
>       }
>  -    System.out.println();
>  +    sb.append("\n");
>       }
>       
>       public void dump(String msg) {
>  -    System.out.println( msg + ": " + buff + " " + pos +"/" 
>+ (len + 4));
>  +    StringBuffer sb=new StringBuffer();
>  +    sb.append( this 
>).append("/").append(Thread.currentThread()).append("\n");
>  +    sb.append( msg + ": " + buff + " " + pos +"/" + (len + 
>4) + "\n");
>       
>       for( int j=0; j < len + 4; j+=16 )
>  -        hexLine( j );
>  +        hexLine( j, sb );
>       
>  -    System.out.println();
>  +    System.out.println(sb);
>       }
>  +
>  +    private static final int dL=0;
>  +    private void d(String s ) {
>  +    System.err.println( "Ajp13Packet: " + s );
>       }
>  +
>  +}
>  
>  
>  
>

Reply via email to