Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
ae8c8551fc
|
@ -439,7 +439,9 @@ public class HttpDestination implements Dumpable
|
||||||
|
|
||||||
public void returnIdleConnection(AbstractHttpConnection connection)
|
public void returnIdleConnection(AbstractHttpConnection connection)
|
||||||
{
|
{
|
||||||
connection.onIdleExpired();
|
// TODO work out the real idle time;
|
||||||
|
long idleForMs=connection!=null&&connection.getEndPoint()!=null?connection.getEndPoint().getMaxIdleTime():-1;
|
||||||
|
connection.onIdleExpired(idleForMs);
|
||||||
|
|
||||||
boolean startConnection = false;
|
boolean startConnection = false;
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
|
|
|
@ -437,9 +437,9 @@ class SelectConnector extends AbstractLifeCycle implements HttpClient.Connector,
|
||||||
_endp.setMaxIdleTime(timeMs);
|
_endp.setMaxIdleTime(timeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
_endp.onIdleExpired();
|
_endp.onIdleExpired(idleForMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckForIdle(boolean check)
|
public void setCheckForIdle(boolean check)
|
||||||
|
|
|
@ -35,11 +35,11 @@ public abstract class AbstractConnection implements Connection
|
||||||
return _endp;
|
return _endp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LOG.debug("onIdleExpired {} {}",this,_endp);
|
LOG.debug("onIdleExpired {}ms {} {}",idleForMs,this,_endp);
|
||||||
if (_endp.isInputShutdown() || _endp.isOutputShutdown())
|
if (_endp.isInputShutdown() || _endp.isOutputShutdown())
|
||||||
_endp.close();
|
_endp.close();
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,8 +35,9 @@ public interface AsyncEndPoint extends ConnectedEndPoint
|
||||||
/** Callback when idle.
|
/** Callback when idle.
|
||||||
* <p>An endpoint is idle if there has been no IO activity for
|
* <p>An endpoint is idle if there has been no IO activity for
|
||||||
* {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true.
|
* {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true.
|
||||||
|
* @param idleForMs TODO
|
||||||
*/
|
*/
|
||||||
public void onIdleExpired();
|
public void onIdleExpired(long idleForMs);
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Set if the endpoint should be checked for idleness
|
/** Set if the endpoint should be checked for idleness
|
||||||
|
|
|
@ -54,6 +54,7 @@ public interface Connection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the connection idle timeout expires
|
* Called when the connection idle timeout expires
|
||||||
|
* @param idleForMs TODO
|
||||||
*/
|
*/
|
||||||
void onIdleExpired();
|
void onIdleExpired(long idleForMs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,17 +280,22 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
||||||
public void checkIdleTimestamp(long now)
|
public void checkIdleTimestamp(long now)
|
||||||
{
|
{
|
||||||
long idleTimestamp=_idleTimestamp;
|
long idleTimestamp=_idleTimestamp;
|
||||||
if (idleTimestamp!=0 && _maxIdleTime>0 && now>(idleTimestamp+_maxIdleTime))
|
|
||||||
|
if (idleTimestamp!=0 && _maxIdleTime>0)
|
||||||
{
|
{
|
||||||
onIdleExpired();
|
long idleForMs=now-idleTimestamp;
|
||||||
_idleTimestamp=now;
|
if (idleForMs>_maxIdleTime)
|
||||||
|
{
|
||||||
|
onIdleExpired(idleForMs);
|
||||||
|
_idleTimestamp=now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
_connection.onIdleExpired();
|
_connection.onIdleExpired(idleForMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -237,16 +237,17 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
LOG.debug("onIdleExpired {}ms on {}",idleForMs,this);
|
||||||
_sslEndPoint.shutdownOutput();
|
_sslEndPoint.shutdownOutput();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
LOG.warn(e);
|
LOG.warn(e);
|
||||||
super.onIdleExpired();
|
super.onIdleExpired(idleForMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,9 +701,9 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
||||||
_aEndp.scheduleWrite();
|
_aEndp.scheduleWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
_aEndp.onIdleExpired();
|
_aEndp.onIdleExpired(idleForMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckForIdle(boolean check)
|
public void setCheckForIdle(boolean check)
|
||||||
|
|
|
@ -667,7 +667,7 @@ public class ConnectHandler extends HandlerWrapper
|
||||||
_endPoint.shutdownOutput();
|
_endPoint.shutdownOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -834,7 +834,7 @@ public class ConnectHandler extends HandlerWrapper
|
||||||
_endPoint.shutdownOutput();
|
_endPoint.shutdownOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class WebSocketConnectionD06 extends AbstractConnection implements WebSoc
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
closeOut(WebSocketConnectionD06.CLOSE_NORMAL,"Idle");
|
closeOut(WebSocketConnectionD06.CLOSE_NORMAL,"Idle");
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,10 +242,9 @@ public class WebSocketConnectionD08 extends AbstractConnection implements WebSoc
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
long idle = System.currentTimeMillis()-((SelectChannelEndPoint)_endp).getIdleTimestamp();
|
closeOut(WebSocketConnectionD08.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms");
|
||||||
closeOut(WebSocketConnectionD08.CLOSE_NORMAL,"Idle for "+idle+"ms > "+_endp.getMaxIdleTime()+"ms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -271,10 +271,9 @@ public class WebSocketConnectionD13 extends AbstractConnection implements WebSoc
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void onIdleExpired()
|
public void onIdleExpired(long idleForMs)
|
||||||
{
|
{
|
||||||
long idle = System.currentTimeMillis()-((SelectChannelEndPoint)_endp).getIdleTimestamp();
|
closeOut(WebSocketConnectionD13.CLOSE_NORMAL,"Idle for "+idleForMs+"ms > "+_endp.getMaxIdleTime()+"ms");
|
||||||
closeOut(WebSocketConnectionD13.CLOSE_NORMAL,"Idle for "+idle+"ms > "+_endp.getMaxIdleTime()+"ms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -569,29 +569,23 @@ public class WebSocketMessageD08Test
|
||||||
|
|
||||||
|
|
||||||
// Send enough messages to fill receive buffer
|
// Send enough messages to fill receive buffer
|
||||||
long max=0;
|
|
||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
String mesg="How Now Brown Cow";
|
String mesg="How Now Brown Cow";
|
||||||
for (int i=0;i<count;i++)
|
for (int i=0;i<count;i++)
|
||||||
{
|
{
|
||||||
__serverWebSocket.connection.sendMessage(mesg);
|
__serverWebSocket.connection.sendMessage(mesg);
|
||||||
if (i%100==0)
|
if (i%100==0)
|
||||||
{
|
|
||||||
output.flush();
|
output.flush();
|
||||||
|
|
||||||
long now=System.currentTimeMillis();
|
|
||||||
long duration=now-start;
|
|
||||||
start=now;
|
|
||||||
if (max<duration)
|
|
||||||
max=duration;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
long duration=System.currentTimeMillis()-start;
|
||||||
|
|
||||||
while(totalB.get()<(count*(mesg.length()+2)))
|
while(totalB.get()<(count*(mesg.length()+2)))
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
assertEquals(count*(mesg.length()+2),totalB.get()); // all messages
|
assertEquals(count*(mesg.length()+2),totalB.get()); // all messages
|
||||||
assertTrue(max>1000); // was blocked
|
// if (duration<1500)
|
||||||
|
System.err.println("max="+duration);
|
||||||
|
assertTrue(duration>1500); // was blocked
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class WebSocketOverSSLTest
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
_connection.sendMessage(message);
|
_connection.sendMessage(message);
|
||||||
|
|
||||||
Assert.assertTrue(clientLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(clientLatch.await(20, TimeUnit.SECONDS));
|
||||||
|
|
||||||
// While messages may have all arrived, the SSL close alert
|
// While messages may have all arrived, the SSL close alert
|
||||||
// may be in the way so give some time for it to be processed.
|
// may be in the way so give some time for it to be processed.
|
||||||
|
|
Loading…
Reference in New Issue