Mercurial Hosting > luan
changeset 1065:158d1e6ac17f
fix JBuffer.compact()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 04:36:05 -0700 |
parents | a0abb16cf6e7 |
children | bbbda7c6e8ec |
files | src/org/eclipse/jetty/http/HttpGenerator.java src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/io/BufferUtil.java src/org/eclipse/jetty/io/JBuffer.java src/org/eclipse/jetty/io/nio/SslConnection.java src/org/eclipse/jetty/server/AbstractHttpConnection.java |
diffstat | 6 files changed, 27 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpGenerator.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/http/HttpGenerator.java Wed Nov 09 04:36:05 2016 -0700 @@ -134,7 +134,7 @@ if (_last || _state==STATE_END) { LOG.warn("Ignoring extra content {}",content); - content.clear(); +// content.clear(); return; } _last = last; @@ -173,8 +173,8 @@ // Handle the _content if (_head) { - content.clear(); - _content=null; +// content.clear(); + _content = null; } else if ((_buffer==null || _buffer.remaining()==0) && _content.remaining() > 0 && (_last || isCommitted() && _content.remaining()>1024)) { @@ -343,7 +343,7 @@ _noContent = true; _content=null; if (_buffer!=null) - _buffer.clear(); + _buffer.clearJ(); // end the header. if (_status!=101 ) @@ -358,7 +358,7 @@ _noContent = true; _content=null; if (_buffer!=null) - _buffer.clear(); + _buffer.clearJ(); } } @@ -698,14 +698,14 @@ len=0; // Nothing more we can write now. if (_header != null) - _header.clear(); + _header.clearJ(); _bypass = false; _bufferChunked = false; if (_buffer != null) { - _buffer.clear(); + _buffer.clearJ(); if (_contentLength == HttpTokens.CHUNKED_CONTENT) { // Special case handling for small left over buffer from @@ -713,7 +713,7 @@ if (_content != null && _content.remaining() < _buffer.space() && _state != STATE_FLUSHING) { _buffer.put(_content); - _content.clear(); + _content.clearJ(); _content=null; } } @@ -958,7 +958,7 @@ _contentLength = HttpTokens.UNKNOWN_CONTENT; _content = null; if (_buffer!=null) - _buffer.clear(); + _buffer.clearJ(); } /* ------------------------------------------------------------ */ @@ -1066,7 +1066,7 @@ { _contentWritten += _buffer.remaining(); if (_head) - _buffer.clear(); + _buffer.clearJ(); } private boolean isBufferFull2() @@ -1074,7 +1074,7 @@ if (_buffer != null && _buffer.space()==0) { if (_buffer.remaining()==0) - _buffer.compact(); + _buffer.limit(0); return _buffer.space()==0; }
--- a/src/org/eclipse/jetty/http/HttpParser.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/http/HttpParser.java Wed Nov 09 04:36:05 2016 -0700 @@ -98,17 +98,17 @@ } private void clear() { - _buffer.clear(); + _buffer.limit(0); _mark = -1; } private void compact() { if( _mark == -1 ) { - _buffer.compact(); + BufferUtil.compact(_buffer); } else if( _mark > 0 ) { int old = _buffer.position(); _buffer.position(_mark); - _buffer.compact(); + BufferUtil.compact(_buffer); _buffer.position( old - _mark ); _mark = 0; }
--- a/src/org/eclipse/jetty/io/BufferUtil.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/io/BufferUtil.java Wed Nov 09 04:36:05 2016 -0700 @@ -238,4 +238,10 @@ buffer.get(bytes); return new String(bytes,ISO_8859_1); } + + public static void compact(JBuffer buffer) { + buffer.compact(); + buffer.limit(buffer.position()); + buffer.position(0); + } }
--- a/src/org/eclipse/jetty/io/JBuffer.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/io/JBuffer.java Wed Nov 09 04:36:05 2016 -0700 @@ -68,10 +68,7 @@ } public void compact() { - int n = bb.remaining(); bb.compact(); - bb.position(0); - bb.limit(n); } public int capacity() { @@ -84,7 +81,7 @@ return bb; } - public void clear() { + public void clearJ() { bb.position(0); bb.limit(0); }
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Wed Nov 09 04:36:05 2016 -0700 @@ -123,7 +123,7 @@ _buffers=__buffers.get(); if (_buffers==null) _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2); - _inbound=_buffers._in; + _inbound = _buffers._in; _outbound = _buffers._out; _unwrapBuf=_buffers._unwrap; __buffers.set(null); @@ -221,7 +221,7 @@ if (toFill==null) { // use the unwrapbuffer to hold received data. - _unwrapBuf.compact(); + BufferUtil.compact(_unwrapBuf); toFill=_unwrapBuf; } // Else if the fill buffer is too small for the SSL session @@ -383,7 +383,7 @@ synchronized(bbuf) { - _outbound.compact(); + BufferUtil.compact(_outbound); ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate(); synchronized(out_buffer) { @@ -465,7 +465,7 @@ result.bytesConsumed(), result.bytesProduced()); - _inbound.compact(); + BufferUtil.compact(_inbound); buffer.limit(buffer.limit()+result.bytesProduced()); } catch(SSLException e) @@ -481,7 +481,7 @@ { case BUFFER_UNDERFLOW: if (_endp.isInputShutdown()) - _inbound.clear(); + _inbound.limit(0); break; case BUFFER_OVERFLOW:
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Wed Nov 09 03:09:37 2016 -0700 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Wed Nov 09 04:36:05 2016 -0700 @@ -738,7 +738,7 @@ if (_onebyte==null) _onebyte = BufferUtil.newBuffer(1); else - _onebyte.clear(); + _onebyte.clearJ(); _onebyte.put((byte)b); write(_onebyte); }