cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 InputBuffer.java

2004-05-14 Thread remm
remm2004/05/14 14:14:14

  Modified:catalina/src/share/org/apache/coyote/tomcat5
InputBuffer.java
  Log:
  - Fix readLine again (actually, it's not readLine that I keep on trying to fix, it's 
mark
and reset functionality).
  - Avoid creating a buffer the size of the request body when using readLine to read
the entire body with small strings (note: it's not a very big deal, since 
allocating
this many Strings would be really bad for performance).
  - Bug 28959, and Jim Hopp submitted a good test case.
  
  Revision  ChangesPath
  1.7   +13 -1 
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java
  
  Index: InputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InputBuffer.java  8 Mar 2004 23:48:50 -   1.6
  +++ InputBuffer.java  14 May 2004 21:14:14 -  1.7
  @@ -425,8 +425,20 @@
   if (cb.getLength() = 0) {
   cb.setOffset(0);
   cb.setEnd(0);
  +} else {
  +if ((cb.getBuffer().length  (2 * size)) 
  + (cb.getLength())  (cb.getStart())) {
  +System.arraycopy(cb.getBuffer(), cb.getStart(), 
  + cb.getBuffer(), 0, cb.getLength());
  +cb.setEnd(cb.getLength());
  +cb.setOffset(0);
  +}
   }
  -cb.setLimit(cb.getStart() + readAheadLimit);
  +int offset = readAheadLimit;
  +if (offset  size) {
  +offset = size;
  +}
  +cb.setLimit(cb.getStart() + offset);
   markPos = cb.getStart();
   }
   
  
  
  

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



cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 InputBuffer.java

2004-03-08 Thread remm
remm2004/03/08 15:48:50

  Modified:catalina/src/share/org/apache/coyote/tomcat5
InputBuffer.java
  Log:
  - Fix bug 27447 (part 2): reading was not correct when completely filling up
the buffer.
  
  Revision  ChangesPath
  1.6   +1 -0  
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java
  
  Index: InputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InputBuffer.java  5 Mar 2004 13:04:24 -   1.5
  +++ InputBuffer.java  8 Mar 2004 23:48:50 -   1.6
  @@ -171,6 +171,7 @@
   bb.setByteInputChannel(this);
   cb = new CharChunk(size);
   cb.setLimit(size);
  +cb.setOptimizedWrite(false);
   cb.setCharInputChannel(this);
   cb.setCharOutputChannel(this);
   
  
  
  

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



cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 InputBuffer.java

2004-03-05 Thread remm
remm2004/03/05 05:04:24

  Modified:catalina/src/share/org/apache/coyote/tomcat5
InputBuffer.java
  Log:
  - Fix mark/reset functionality.
  - It is valid to reset more than once.
  - If the buffer was grown, discard and reallocate (mark can make the buffer
grow a lot, which is a valid use case).
  - If the buffer is empty when marking, reinit it (to avoid it growing more than it
should).
  
  Revision  ChangesPath
  1.5   +21 -3 
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java
  
  Index: InputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/InputBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InputBuffer.java  27 Feb 2004 14:58:53 -  1.4
  +++ InputBuffer.java  5 Mar 2004 13:04:24 -   1.5
  @@ -139,6 +139,12 @@
   private int markPos = -1;
   
   
  +/**
  + * Buffer size.
  + */
  +private int size = -1;
  +
  +
   // --- Constructors
   
   
  @@ -159,6 +165,7 @@
*/
   public InputBuffer(int size) {
   
  +this.size = size;
   bb = new ByteChunk(size);
   bb.setLimit(size);
   bb.setByteInputChannel(this);
  @@ -208,7 +215,15 @@
bytesRead = 0;
charsRead = 0;
   
  -cb.recycle();
  +// If usage of mark made the buffer too big, reallocate it
  +if (cb.getChars().length  size) {
  +cb = new CharChunk(size);
  +cb.setLimit(size);
  +cb.setCharInputChannel(this);
  +cb.setCharOutputChannel(this);
  +} else {
  +cb.recycle();
  +}
   markPos = -1;
   bb.recycle(); 
   closed = false;
  @@ -406,7 +421,11 @@
   
   public void mark(int readAheadLimit)
   throws IOException {
  -cb.setLimit(cb.getEnd() + readAheadLimit);
  +if (cb.getLength() = 0) {
  +cb.setOffset(0);
  +cb.setEnd(0);
  +}
  +cb.setLimit(cb.getStart() + readAheadLimit);
   markPos = cb.getStart();
   }
   
  @@ -420,7 +439,6 @@
   throw new IOException();
   } else {
   cb.setOffset(markPos);
  -markPos = -1;
   }
   } else {
   bb.recycle();
  
  
  

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