364921 moved setCheckForIdle handling to AsyncHttpConnection

This commit is contained in:
Greg Wilkins 2011-12-22 00:48:25 +11:00
parent ef23bf11b8
commit b99e03c465
5 changed files with 14 additions and 15 deletions

View File

@ -1241,7 +1241,6 @@ public class SslBytesServerTest extends SslBytesTest
closeClient(client);
}
@Ignore // TODO: currently not passing
@Test
public void testServerShutdownOutputClientDoesNotCloseServerCloses() throws Exception
{
@ -1291,11 +1290,9 @@ public class SslBytesServerTest extends SslBytesTest
// The server has shutdown the output since the client sent a Connection: close
// but the client does not close, so the server must idle timeout the endPoint.
TimeUnit.MILLISECONDS.sleep(idleTimeout + idleTimeout / 2);
TimeUnit.MILLISECONDS.sleep(idleTimeout + idleTimeout/2);
Assert.assertFalse(serverEndPoint.get().isOpen());
closeClient(client);
}
private void assumeJavaVersionSupportsTLSRenegotiations()

View File

@ -257,15 +257,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
getSelectSet().scheduleTimeout(task,timeoutMs);
}
/* ------------------------------------------------------------ */
@Override
public boolean isOutputShutdown()
{
setCheckForIdle(true);
return super.isOutputShutdown();
}
/* ------------------------------------------------------------ */
public void setCheckForIdle(boolean check)
{
@ -289,10 +280,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
public void checkIdleTimestamp(long now)
{
long idleTimestamp=_idleTimestamp;
if (idleTimestamp!=0 && _maxIdleTime>0)
{
long idleForMs=now-idleTimestamp;
if (idleForMs>_maxIdleTime)
{
onIdleExpired(idleForMs);

View File

@ -599,6 +599,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
public void shutdownOutput() throws IOException
{
System.err.println("OSHUT SSL");
synchronized (SslConnection.this)
{
LOG.debug("{} ssl endp.oshut {}",_session,this);

View File

@ -54,6 +54,10 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
try
{
setCurrentConnection(this);
// don't check for idle while dispatched (unless blocking IO is done).
_asyncEndp.setCheckForIdle(false);
// While progress and the connection has not changed
while (progress && connection==this)
@ -133,10 +137,16 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
finally
{
setCurrentConnection(null);
// If we are not suspended
if (!_request.isAsyncStarted())
{
// return buffers
_parser.returnBuffers();
_generator.returnBuffers();
// resuming checking for idle
_asyncEndp.setCheckForIdle(true);
}
// Safety net to catch spinning

View File

@ -122,7 +122,6 @@ public class SelectChannelConnector extends AbstractNIOConnector
public void customize(EndPoint endpoint, Request request) throws IOException
{
AsyncEndPoint aEndp = ((AsyncEndPoint)endpoint);
aEndp.setCheckForIdle(false);
request.setTimeStamp(System.currentTimeMillis());
endpoint.setMaxIdleTime(_maxIdleTime);
super.customize(endpoint, request);