minor cleanups and extra debug
This commit is contained in:
parent
54961fca1f
commit
a6988108c3
|
@ -90,6 +90,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
|
||||
scheduleIdle();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectionKey getSelectionKey()
|
||||
{
|
||||
|
@ -260,6 +261,15 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
_connection.idleExpired();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if the endpoint has produced/consumed bytes itself (non application data).
|
||||
*/
|
||||
public boolean isProgressing()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
*/
|
||||
|
|
|
@ -145,6 +145,16 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if the endpoint has produced/consumed bytes itself (non application data).
|
||||
*/
|
||||
public boolean isProgressing()
|
||||
{
|
||||
SSLEngineResult result = _result;
|
||||
return result!=null && (result.bytesConsumed()>0 || result.bytesProduced()>0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if SSL re-negotiation is allowed (default false)
|
||||
|
|
|
@ -7,12 +7,17 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class AsyncHttpConnection extends HttpConnection
|
||||
{
|
||||
private final static int NO_PROGRESS_INFO = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_INFO",100);
|
||||
private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",1000);
|
||||
|
||||
private static final Logger LOG = Log.getLogger(AsyncHttpConnection.class);
|
||||
private int _total_no_progress;
|
||||
|
||||
public AsyncHttpConnection(Connector connector, EndPoint endpoint, Server server)
|
||||
{
|
||||
|
@ -22,13 +27,14 @@ public class AsyncHttpConnection extends HttpConnection
|
|||
public Connection handle() throws IOException
|
||||
{
|
||||
Connection connection = this;
|
||||
boolean some_progress=false;
|
||||
boolean progress=true;
|
||||
|
||||
// Loop while more in buffer
|
||||
try
|
||||
{
|
||||
setCurrentConnection(this);
|
||||
|
||||
boolean progress=true;
|
||||
boolean more_in_buffer =false;
|
||||
|
||||
while (_endp.isOpen() && (more_in_buffer || progress))
|
||||
|
@ -98,7 +104,6 @@ public class AsyncHttpConnection extends HttpConnection
|
|||
reset(false);
|
||||
more_in_buffer = _parser.isMoreInBuffer() || _endp.isBufferingInput();
|
||||
}
|
||||
|
||||
// else Are we suspended?
|
||||
else if (_request.isAsyncStarted())
|
||||
{
|
||||
|
@ -108,6 +113,8 @@ public class AsyncHttpConnection extends HttpConnection
|
|||
}
|
||||
else
|
||||
more_in_buffer = _parser.isMoreInBuffer() || _endp.isBufferingInput();
|
||||
|
||||
some_progress|=progress|((SelectChannelEndPoint)_endp).isProgressing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +128,19 @@ public class AsyncHttpConnection extends HttpConnection
|
|||
((AsyncEndPoint)_endp).scheduleWrite();
|
||||
else
|
||||
_generator.returnBuffers();
|
||||
|
||||
if (!some_progress)
|
||||
{
|
||||
_total_no_progress++;
|
||||
|
||||
if (NO_PROGRESS_INFO>0 && _total_no_progress%NO_PROGRESS_INFO==0 && (NO_PROGRESS_CLOSE<=0 || _total_no_progress< NO_PROGRESS_CLOSE))
|
||||
LOG.info("EndPoint making no progress: "+_total_no_progress+" "+_endp);
|
||||
if (NO_PROGRESS_CLOSE>0 && _total_no_progress>NO_PROGRESS_CLOSE)
|
||||
{
|
||||
LOG.warn("Closing EndPoint making no progress: "+_total_no_progress+" "+_endp);
|
||||
_endp.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
|
|
@ -234,8 +234,8 @@ public class SslTruncationAttackTest
|
|||
// Sleep for a while to detect eventual spin looping
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
|
||||
Assert.assertTrue("endpoint closed", endPointClosed.get());
|
||||
Assert.assertEquals("handle() invocations", 1, handleCount.get());
|
||||
Assert.assertTrue("endpoint not closed", endPointClosed.get());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class DeflateFrameExtension extends AbstractExtension
|
|||
catch(DataFormatException e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
getConnection().close(WebSocketConnectionD13.CLOSE_PROTOCOL,e.toString());
|
||||
getConnection().close(WebSocketConnectionD13.CLOSE_BAD_PAYLOAD,e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ public class WebSocketParserD13 implements WebSocketParser
|
|||
_buffer.skip(_bytesNeeded);
|
||||
_state=State.START;
|
||||
events++;
|
||||
_handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"bad mask");
|
||||
_handler.close(WebSocketConnectionD13.CLOSE_PROTOCOL,"Not masked");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue