JETTY-1015 Reduce BayeuxClient and HttpClient lock contention

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@206 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-05-05 14:13:18 +00:00
parent 806219ab59
commit 3ee44fd757
3 changed files with 33 additions and 24 deletions

View File

@ -8,6 +8,7 @@ jetty-7.0.0.M2-SNAPSHOT
+ JETTY-1003 java.lang.IllegalArgumentException: timeout can't be negative + JETTY-1003 java.lang.IllegalArgumentException: timeout can't be negative
+ JETTY-1004 CERT VU#402580 Canonical path handling includes ? in path segment + JETTY-1004 CERT VU#402580 Canonical path handling includes ? in path segment
+ JETTY-1014 Enable start-stop-daemon by default on jetty.sh (START_STOP_DAEMON=1) + JETTY-1014 Enable start-stop-daemon by default on jetty.sh (START_STOP_DAEMON=1)
+ JETTY-1015 Reduce BayeuxClient and HttpClient lock contention
jetty-6.1.17 30 April 2009 jetty-6.1.17 30 April 2009
+ JETTY-936 Make optional dispatching to welcome files as servlets + JETTY-936 Make optional dispatching to welcome files as servlets

View File

@ -203,27 +203,28 @@ public class HttpDestination
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
public HttpConnection getIdleConnection() throws IOException public HttpConnection getIdleConnection() throws IOException
{
synchronized (this)
{ {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long idleTimeout=_client.getIdleTimeout(); long idleTimeout=_client.getIdleTimeout();
HttpConnection connection = null;
// Find an idle connection while (true)
while (_idle.size() > 0)
{ {
HttpConnection connection = _idle.remove(_idle.size() - 1); synchronized (this)
{
if (_idle.size() > 0)
connection = _idle.remove(_idle.size()-1);
}
if (connection==null)
return null;
long last = connection.getLast(); long last = connection.getLast();
if (connection.getEndPoint().isOpen() && (last==0 || ((now-last)<idleTimeout)) ) if (connection.getEndPoint().isOpen() && (last==0 || ((now-last)<idleTimeout)) )
return connection; return connection;
else
{
_connections.remove(connection); _connections.remove(connection);
connection.getEndPoint().close(); connection.getEndPoint().close();
} connection=null;
}
return null;
} }
} }

View File

@ -73,17 +73,24 @@ public class HttpExchangeTest extends TestCase
} }
public void testPerf() throws Exception public void testPerf() throws Exception
{
if (_stress)
{
sender(1,false);
sender(1,true);
sender(100,false);
sender(100,true);
sender(10000,false);
sender(10000,true);
}
else
{ {
sender(1,false); sender(1,false);
sender(1,true); sender(1,true);
sender(10,false); sender(10,false);
sender(10,true); sender(10,true);
sender(100,false); sender(20,false);
sender(100,true); sender(20,true);
if (_stress)
{
sender(1000,false);
sender(1000,true);
} }
} }