374158: do not asyncDispatch from SSL if suspended
This commit is contained in:
parent
56e726c201
commit
708f8ccaeb
|
@ -408,7 +408,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are reading into the temp buffer and it has some content, then we should be dispatched.
|
// If we are reading into the temp buffer and it has some content, then we should be dispatched.
|
||||||
if (toFill==_unwrapBuf && _unwrapBuf.hasContent())
|
if (toFill==_unwrapBuf && _unwrapBuf.hasContent() && !_connection.isSuspended())
|
||||||
_aEndp.asyncDispatch();
|
_aEndp.asyncDispatch();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -550,7 +550,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUFFER_OVERFLOW:
|
case BUFFER_OVERFLOW:
|
||||||
_logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString());
|
if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OK:
|
case OK:
|
||||||
|
|
|
@ -39,9 +39,11 @@ import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.StdErrLog;
|
import org.eclipse.jetty.util.log.StdErrLog;
|
||||||
|
import org.hamcrest.CoreMatchers;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.matchers.JUnitMatchers;
|
import org.junit.matchers.JUnitMatchers;
|
||||||
|
import org.mockito.internal.matchers.Contains;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -1280,4 +1282,51 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuspendedPipeline() throws Exception
|
||||||
|
{
|
||||||
|
SuspendHandler suspend = new SuspendHandler();
|
||||||
|
suspend.setSuspendFor(30000);
|
||||||
|
suspend.setResumeAfter(1000);
|
||||||
|
configureServer(suspend);
|
||||||
|
|
||||||
|
long start=System.currentTimeMillis();
|
||||||
|
Socket client=newSocket(HOST,_connector.getLocalPort());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OutputStream os=client.getOutputStream();
|
||||||
|
InputStream is=client.getInputStream();
|
||||||
|
|
||||||
|
// write an initial request
|
||||||
|
os.write((
|
||||||
|
"GET / HTTP/1.1\r\n"+
|
||||||
|
"host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+
|
||||||
|
"\r\n"
|
||||||
|
).getBytes());
|
||||||
|
os.flush();
|
||||||
|
|
||||||
|
Thread.sleep(200);
|
||||||
|
|
||||||
|
// write an pipelined request
|
||||||
|
os.write((
|
||||||
|
"GET / HTTP/1.1\r\n"+
|
||||||
|
"host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+
|
||||||
|
"connection: close\r\n"+
|
||||||
|
"\r\n"
|
||||||
|
).getBytes());
|
||||||
|
os.flush();
|
||||||
|
|
||||||
|
String response=readResponse(client);
|
||||||
|
assertThat(response,JUnitMatchers.containsString("RESUMEDHTTP/1.1 200 OK"));
|
||||||
|
assertThat((System.currentTimeMillis()-start),greaterThanOrEqualTo(1999L));
|
||||||
|
|
||||||
|
// TODO This test should also check that that the CPU did not spin during the suspend.
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,13 @@ public class SelectChannelServerTest extends HttpServerTestBase
|
||||||
{
|
{
|
||||||
super.testCommittedError();
|
super.testCommittedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testSuspendedPipeline() throws Exception
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.testSuspendedPipeline();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,8 +121,7 @@ class SuspendHandler extends HandlerWrapper
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(_resumeAfter);
|
Thread.sleep(_resumeAfter);
|
||||||
if(((HttpServletRequest)asyncContext.getRequest()).getSession(true).getId()!=null)
|
asyncContext.dispatch();
|
||||||
asyncContext.dispatch();
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,5 +144,10 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testSuspendedPipeline() throws Exception
|
||||||
|
{
|
||||||
|
super.testSuspendedPipeline();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue