tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core OutputBuffer.java Response.java
Date Fri, 25 Aug 2000 22:35:58 GMT
alex        00/08/25 15:35:57

  Modified:    src/share/org/apache/tomcat/core OutputBuffer.java
                        Response.java
  Log:
  Fix bug (BugRat #14) with flush() and flushBuffer() by making OutputBuffer.flush() actually
work right
  
  Note that there's still a problem with Jasper -- I know the problem but I'm not sure how
to fix it.  I'll post to tomcat-dev for advice
  
  Revision  Changes    Path
  1.3       +29 -10    jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OutputBuffer.java	2000/08/11 06:14:06	1.2
  +++ OutputBuffer.java	2000/08/25 22:35:56	1.3
  @@ -140,9 +140,10 @@
   
   	// fit in buffer, great.
   	if( len <= avail ) {
  +	  // ??? should be < since if it's just barely full, we still
  +	  // want to flush now
   	    System.arraycopy(b, off, buf, count, len);
   	    count += len;
  -	    return;
   	}
   
   	// Optimization:
  @@ -152,7 +153,7 @@
   	// and still have some space for more. We'll still have 2 writes, but
   	// we write more on the first.
   
  -	if (len - avail < buf.length) {
  +	else if (len - avail < buf.length) {
   	    /* If the request length exceeds the size of the output buffer,
       	       flush the output buffer and then write the data directly.
   	       We can't avoid 2 writes, but we can write more on the second
  @@ -164,13 +165,20 @@
   	    System.arraycopy(b, off+avail, buf, count, len - avail);
   	    count+= len - avail;
   	    bytesWritten += len - avail;
  -	    return;
   	}
   
   	// len > buf.length + avail
  -	flushBytes();
  -	cm.doWrite( req, resp, b, off, len );
  +	else {
  +	  flushBytes();
  +	  cm.doWrite( req, resp, b, off, len );
  +	}
   
  +	// if called from within flush(), then immediately flush
  +	// remaining bytes
  +	if (doFlush) {
  +	  flushBytes();
  +	}
  +
   	return;
       }
   
  @@ -219,6 +227,8 @@
   
   	// fit in buffer, great.
   	if( len <= avail ) {
  +	  // ??? should be < since if it's just barely full, we still
  +	  // want to flush now
   	    System.arraycopy(c, off, cbuf, ccount, len);
   	    ccount += len;
   	    return;
  @@ -307,12 +317,21 @@
       }
   
       public void close() throws IOException {
  -	//nothing
  +      flush();
       }
   
  -    public void flush() throws IOException {
  -	System.out.println("No flush ");
  -    }
  +  private boolean doFlush = false;
  +
  +  synchronized public void flush() throws IOException {
  +    doFlush = true;
  +    if( state==CHAR_STATE )
  +      flushChars();
  +    else if (state==BYTE_STATE)
  +      flushBytes();
  +    else if (state==INITIAL_STATE)
  +      ;       // nothing written yet
  +    doFlush = false;
  +  }
       
       Hashtable encoders=new Hashtable();
       WriteConvertor conv;
  @@ -322,7 +341,7 @@
   	if( !gotEnc ) setConverter();
   
   	conv.write(c, off, len);
  -	conv.flush();
  +	conv.flush();	// ???
       }
   
       private void setConverter() {
  
  
  
  1.30      +5 -5      jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Response.java	2000/08/22 06:56:40	1.29
  +++ Response.java	2000/08/25 22:35:57	1.30
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v 1.29
2000/08/22 06:56:40 costin Exp $
  - * $Revision: 1.29 $
  - * $Date: 2000/08/22 06:56:40 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v 1.30
2000/08/25 22:35:57 alex Exp $
  + * $Revision: 1.30 $
  + * $Date: 2000/08/25 22:35:57 $
    *
    * ====================================================================
    *
  @@ -482,8 +482,8 @@
   	// 	if (usingWriter == true && writer != null)
   	// 	    writer.flush();
   
  -	oBuffer.flushChars();
  -	oBuffer.flushBytes();
  +      oBuffer.flush();
  +
   	// 	if( out!=null ) out.reallyFlush();
   	// 	if(bBuffer!=null) bBuffer.flush();
   	    //} 
  
  
  

Mime
View raw message