Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
2e2247bde5
|
@ -411,7 +411,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 (toFill==_unwrapBuf && _unwrapBuf.hasContent())
|
||||
if (toFill==_unwrapBuf && _unwrapBuf.hasContent() && !_connection.isSuspended())
|
||||
_aEndp.asyncDispatch();
|
||||
}
|
||||
finally
|
||||
|
@ -553,7 +553,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
break;
|
||||
|
||||
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;
|
||||
|
||||
case OK:
|
||||
|
|
|
@ -39,9 +39,11 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.matchers.JUnitMatchers;
|
||||
import org.mockito.internal.matchers.Contains;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -1280,4 +1282,51 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,5 +32,12 @@ public class SelectChannelServerTest extends HttpServerTestBase
|
|||
super.testCommittedError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testSuspendedPipeline() throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
super.testSuspendedPipeline();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -121,8 +121,7 @@ class SuspendHandler extends HandlerWrapper
|
|||
try
|
||||
{
|
||||
Thread.sleep(_resumeAfter);
|
||||
if(((HttpServletRequest)asyncContext.getRequest()).getSession(true).getId()!=null)
|
||||
asyncContext.dispatch();
|
||||
asyncContext.dispatch();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
|
|
@ -145,4 +145,9 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void testSuspendedPipeline() throws Exception
|
||||
{
|
||||
super.testSuspendedPipeline();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -992,7 +992,7 @@ public class DoSFilter implements Filter
|
|||
if (_rateTrackers != null && _trackerTimeoutQ != null)
|
||||
{
|
||||
long now = _trackerTimeoutQ.getNow();
|
||||
int latestIndex = _next == 0 ? 3 : (_next - 1 ) % _timestamps.length;
|
||||
int latestIndex = _next == 0 ? (_timestamps.length-1) : (_next - 1 );
|
||||
long last=_timestamps[latestIndex];
|
||||
boolean hasRecentRequest = last != 0 && (now-last)<1000L;
|
||||
|
||||
|
|
Loading…
Reference in New Issue