Fixes #305997 (Coalesce buffers in ChannelEndPoint.flush()).

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1382 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Simone Bordet 2010-03-16 11:56:25 +00:00
parent 96ec4af2df
commit fa37afd7fe
2 changed files with 50 additions and 37 deletions

View File

@ -42,10 +42,11 @@ jetty-7.0.2.RC0
+ JETTY-1179 Persistant session tables created on MySQL use wrong datatype + JETTY-1179 Persistant session tables created on MySQL use wrong datatype
+ JETTY-1184 shrink thread pool even with frequent small jobs + JETTY-1184 shrink thread pool even with frequent small jobs
+ JETTY-1133 Handle multiple URL ; parameters + JETTY-1133 Handle multiple URL ; parameters
+ JETTY-1192 Fixed Digested POST + JETTY-1192 Fixed Digested POST
+ COMETD-46 reset ContentExchange response content on resend + COMETD-46 reset ContentExchange response content on resend
+ Added IPAccessHandler + Added IPAccessHandler
+ Updated Servlet3Continuation to final 3.0.20100224 + Updated Servlet3Continuation to final 3.0.20100224
+ 305997 Coalesce buffers in ChannelEndPoint.flush()
jetty-7.0.1.v20091125 25 November 2009 jetty-7.0.1.v20091125 25 November 2009
+ 274251 DefaultServlet supports exact match mode. + 274251 DefaultServlet supports exact match mode.

View File

@ -4,11 +4,11 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.io.nio; package org.eclipse.jetty.io.nio;
@ -29,7 +29,7 @@ import org.eclipse.jetty.util.log.Log;
/** /**
* *
* *
* To change the template for this generated type comment go to * To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments * Window - Preferences - Java - Code Generation - Code and Comments
@ -41,9 +41,9 @@ public class ChannelEndPoint implements EndPoint
protected final Socket _socket; protected final Socket _socket;
protected InetSocketAddress _local; protected InetSocketAddress _local;
protected InetSocketAddress _remote; protected InetSocketAddress _remote;
/** /**
* *
*/ */
public ChannelEndPoint(ByteChannel channel) public ChannelEndPoint(ByteChannel channel)
{ {
@ -51,23 +51,23 @@ public class ChannelEndPoint implements EndPoint
this._channel = channel; this._channel = channel;
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null; _socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
} }
public boolean isBlocking() public boolean isBlocking()
{ {
return !(_channel instanceof SelectableChannel) || ((SelectableChannel)_channel).isBlocking(); return !(_channel instanceof SelectableChannel) || ((SelectableChannel)_channel).isBlocking();
} }
public boolean blockReadable(long millisecs) throws IOException public boolean blockReadable(long millisecs) throws IOException
{ {
return true; return true;
} }
public boolean blockWritable(long millisecs) throws IOException public boolean blockWritable(long millisecs) throws IOException
{ {
return true; return true;
} }
/* /*
* @see org.eclipse.io.EndPoint#isOpen() * @see org.eclipse.io.EndPoint#isOpen()
*/ */
public boolean isOpen() public boolean isOpen()
@ -139,7 +139,7 @@ public class ChannelEndPoint implements EndPoint
{ {
throw new IOException("Not Implemented"); throw new IOException("Not Implemented");
} }
return len; return len;
} }
@ -203,9 +203,9 @@ public class ChannelEndPoint implements EndPoint
Buffer buf0 = header==null?null:header.buffer(); Buffer buf0 = header==null?null:header.buffer();
Buffer buf1 = buffer==null?null:buffer.buffer(); Buffer buf1 = buffer==null?null:buffer.buffer();
if (_channel instanceof GatheringByteChannel && if (_channel instanceof GatheringByteChannel &&
header!=null && header.length()!=0 && buf0 instanceof NIOBuffer && header!=null && header.length()!=0 && buf0 instanceof NIOBuffer &&
buffer!=null && buffer.length()!=0 && buf1 instanceof NIOBuffer) buffer!=null && buffer.length()!=0 && buf1 instanceof NIOBuffer)
{ {
final NIOBuffer nbuf0 = (NIOBuffer)buf0; final NIOBuffer nbuf0 = (NIOBuffer)buf0;
@ -235,7 +235,7 @@ public class ChannelEndPoint implements EndPoint
// do the gathering write. // do the gathering write.
length=(int)((GatheringByteChannel)_channel).write(_gather2); length=(int)((GatheringByteChannel)_channel).write(_gather2);
int hl=header.length(); int hl=header.length();
if (length>hl) if (length>hl)
{ {
@ -246,7 +246,7 @@ public class ChannelEndPoint implements EndPoint
{ {
header.skip(length); header.skip(length);
} }
} }
finally finally
{ {
@ -267,8 +267,20 @@ public class ChannelEndPoint implements EndPoint
} }
else else
{ {
// TODO - consider copying buffers buffer and trailer into header if there is space! if (header!=null)
{
if (buffer!=null && buffer.length()>0 && header.space()>buffer.length())
{
header.put(buffer);
buffer.clear();
}
if (trailer!=null && trailer.length()>0 && header.space()>trailer.length())
{
header.put(trailer);
trailer.clear();
}
}
// flush header // flush header
if (header!=null && header.length()>0) if (header!=null && header.length()>0)
length=flush(header); length=flush(header);
@ -284,7 +296,7 @@ public class ChannelEndPoint implements EndPoint
trailer!=null && trailer.length()>0) trailer!=null && trailer.length()>0)
length+=flush(trailer); length+=flush(trailer);
} }
return length; return length;
} }
@ -298,50 +310,50 @@ public class ChannelEndPoint implements EndPoint
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getLocalAddr() * @see org.eclipse.io.EndPoint#getLocalAddr()
*/ */
public String getLocalAddr() public String getLocalAddr()
{ {
if (_socket==null) if (_socket==null)
return null; return null;
if (_local==null) if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress(); _local=(InetSocketAddress)_socket.getLocalSocketAddress();
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress()) if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
return StringUtil.ALL_INTERFACES; return StringUtil.ALL_INTERFACES;
return _local.getAddress().getHostAddress(); return _local.getAddress().getHostAddress();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getLocalHost() * @see org.eclipse.io.EndPoint#getLocalHost()
*/ */
public String getLocalHost() public String getLocalHost()
{ {
if (_socket==null) if (_socket==null)
return null; return null;
if (_local==null) if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress(); _local=(InetSocketAddress)_socket.getLocalSocketAddress();
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress()) if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
return StringUtil.ALL_INTERFACES; return StringUtil.ALL_INTERFACES;
return _local.getAddress().getCanonicalHostName(); return _local.getAddress().getCanonicalHostName();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getLocalPort() * @see org.eclipse.io.EndPoint#getLocalPort()
*/ */
public int getLocalPort() public int getLocalPort()
{ {
if (_socket==null) if (_socket==null)
return 0; return 0;
if (_local==null) if (_local==null)
_local=(InetSocketAddress)_socket.getLocalSocketAddress(); _local=(InetSocketAddress)_socket.getLocalSocketAddress();
if (_local==null) if (_local==null)
@ -350,31 +362,31 @@ public class ChannelEndPoint implements EndPoint
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getRemoteAddr() * @see org.eclipse.io.EndPoint#getRemoteAddr()
*/ */
public String getRemoteAddr() public String getRemoteAddr()
{ {
if (_socket==null) if (_socket==null)
return null; return null;
if (_remote==null) if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress(); _remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
if (_remote==null) if (_remote==null)
return null; return null;
return _remote.getAddress().getHostAddress(); return _remote.getAddress().getHostAddress();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getRemoteHost() * @see org.eclipse.io.EndPoint#getRemoteHost()
*/ */
public String getRemoteHost() public String getRemoteHost()
{ {
if (_socket==null) if (_socket==null)
return null; return null;
if (_remote==null) if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress(); _remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
@ -384,14 +396,14 @@ public class ChannelEndPoint implements EndPoint
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getRemotePort() * @see org.eclipse.io.EndPoint#getRemotePort()
*/ */
public int getRemotePort() public int getRemotePort()
{ {
if (_socket==null) if (_socket==null)
return 0; return 0;
if (_remote==null) if (_remote==null)
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress(); _remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
@ -399,7 +411,7 @@ public class ChannelEndPoint implements EndPoint
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/* /*
* @see org.eclipse.io.EndPoint#getConnection() * @see org.eclipse.io.EndPoint#getConnection()
*/ */
public Object getTransport() public Object getTransport()
@ -410,7 +422,7 @@ public class ChannelEndPoint implements EndPoint
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void flush() public void flush()
throws IOException throws IOException
{ {
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */