357240 improved ishut/oshut handling
This commit is contained in:
parent
444c09fce7
commit
fbf0fad076
|
@ -49,6 +49,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class HttpExchangeTest
|
||||
{
|
||||
final static boolean verbose=false;
|
||||
protected static int _maxConnectionsPerAddress = 2;
|
||||
protected static String _scheme = "http";
|
||||
protected static Server _server;
|
||||
|
@ -129,7 +130,6 @@ public class HttpExchangeTest
|
|||
final CountDownLatch latch = new CountDownLatch(nb);
|
||||
HttpExchange[] httpExchange = new HttpExchange[nb];
|
||||
long start = System.currentTimeMillis();
|
||||
final boolean verbose=false;
|
||||
for (int i = 0; i < nb; i++)
|
||||
{
|
||||
final int n = i;
|
||||
|
@ -397,44 +397,42 @@ public class HttpExchangeTest
|
|||
int size =32;
|
||||
ContentExchange httpExchange=new ContentExchange()
|
||||
{
|
||||
|
||||
@Override
|
||||
protected synchronized void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException
|
||||
{
|
||||
System.err.println("] "+version+" "+status+" "+reason);
|
||||
// TODO Auto-generated method stub
|
||||
super.onResponseStatus(version,status,reason);
|
||||
if (verbose)
|
||||
super.onResponseStatus(version,status,reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onResponseHeader(Buffer name, Buffer value) throws IOException
|
||||
{
|
||||
System.err.println("] "+name+": "+value);
|
||||
// TODO Auto-generated method stub
|
||||
if (verbose)
|
||||
System.err.println("] "+name+": "+value);
|
||||
super.onResponseHeader(name,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onResponseContent(Buffer content) throws IOException
|
||||
{
|
||||
System.err.println("] "+content.length());
|
||||
// TODO Auto-generated method stub
|
||||
if (verbose)
|
||||
System.err.println("] "+content.length());
|
||||
super.onResponseContent(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRequestComplete() throws IOException
|
||||
{
|
||||
System.err.println("] ==");
|
||||
// TODO Auto-generated method stub
|
||||
if (verbose)
|
||||
System.err.println("] ==");
|
||||
super.onRequestComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResponseHeaderComplete() throws IOException
|
||||
{
|
||||
System.err.println("] --");
|
||||
// TODO Auto-generated method stub
|
||||
if (verbose)
|
||||
System.err.println("] --");
|
||||
super.onResponseHeaderComplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,12 @@ public class ChannelEndPoint implements EndPoint
|
|||
if (_channel.isOpen() && _channel instanceof SocketChannel)
|
||||
{
|
||||
Socket socket= ((SocketChannel)_channel).socket();
|
||||
if (!socket.isClosed()&&!socket.isInputShutdown())
|
||||
if (!socket.isClosed())
|
||||
{
|
||||
socket.shutdownInput();
|
||||
if(socket.isOutputShutdown())
|
||||
socket.close();
|
||||
else if (!socket.isInputShutdown())
|
||||
socket.shutdownInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +127,12 @@ public class ChannelEndPoint implements EndPoint
|
|||
if (_channel.isOpen() && _channel instanceof SocketChannel)
|
||||
{
|
||||
Socket socket= ((SocketChannel)_channel).socket();
|
||||
if (!socket.isClosed()&&!socket.isOutputShutdown())
|
||||
if (!socket.isClosed())
|
||||
{
|
||||
socket.shutdownOutput();
|
||||
if (socket.isInputShutdown())
|
||||
socket.close();
|
||||
else if (!socket.isOutputShutdown())
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +176,14 @@ public class ChannelEndPoint implements EndPoint
|
|||
{
|
||||
bbuf.position(buffer.putIndex());
|
||||
len=_channel.read(bbuf);
|
||||
|
||||
|
||||
LOG.debug("{} {} {} read={}",
|
||||
this.getChannel().isOpen(),
|
||||
this.isInputShutdown(),
|
||||
this.isOutputShutdown(),
|
||||
this.getChannel().isOpen(),
|
||||
len);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -178,13 +192,17 @@ public class ChannelEndPoint implements EndPoint
|
|||
}
|
||||
}
|
||||
|
||||
if (len<0 && isOpen() && !isInputShutdown())
|
||||
if (len<0 && isOpen())
|
||||
{
|
||||
shutdownInput();
|
||||
if (!isInputShutdown())
|
||||
shutdownInput();
|
||||
else if (isOutputShutdown())
|
||||
_channel.close();
|
||||
}
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
LOG.debug(x);
|
||||
try
|
||||
{
|
||||
close();
|
||||
|
@ -196,7 +214,6 @@ public class ChannelEndPoint implements EndPoint
|
|||
|
||||
if (len>0)
|
||||
throw x;
|
||||
LOG.ignore(x);
|
||||
len=-1;
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +272,7 @@ public class ChannelEndPoint implements EndPoint
|
|||
{
|
||||
throw new IOException("Not Implemented");
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -436,9 +436,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
public void scheduleWrite()
|
||||
{
|
||||
if (_writable==true)
|
||||
{
|
||||
LOG.warn("Required scheduleWrite");
|
||||
}
|
||||
LOG.debug("Required scheduleWrite {}",this);
|
||||
|
||||
_writable=false;
|
||||
updateKey();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
private volatile boolean _handshook=false;
|
||||
private boolean _allowRenegotiate=true;
|
||||
|
||||
private final boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer
|
||||
private volatile boolean _debug = LOG.isDebugEnabled(); // snapshot debug status for optimizer
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SslSelectChannelEndPoint(Buffers buffers,SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, SSLEngine engine, int maxIdleTime)
|
||||
|
@ -355,6 +355,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
@Override
|
||||
public int fill(Buffer buffer) throws IOException
|
||||
{
|
||||
_debug=LOG.isDebugEnabled();
|
||||
LOG.debug("{} fill",_session);
|
||||
// This end point only works on NIO buffer type (director
|
||||
// or indirect), so extract the NIO buffer that is wrapped
|
||||
|
@ -396,6 +397,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
@Override
|
||||
public int flush(Buffer buffer) throws IOException
|
||||
{
|
||||
_debug=LOG.isDebugEnabled();
|
||||
LOG.debug("{} flush1",_session);
|
||||
return process(null,buffer);
|
||||
}
|
||||
|
@ -407,6 +409,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
@Override
|
||||
public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException
|
||||
{
|
||||
_debug=LOG.isDebugEnabled();
|
||||
LOG.debug("{} flush3",_session);
|
||||
|
||||
int len=0;
|
||||
|
@ -474,7 +477,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
* @return true if progress is made
|
||||
*/
|
||||
private boolean unwrap(ByteBuffer buffer) throws IOException
|
||||
{
|
||||
{
|
||||
needInBuffer();
|
||||
ByteBuffer in_buffer=_inNIOBuffer.getByteBuffer();
|
||||
|
||||
|
@ -482,6 +485,9 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
|
||||
int total_filled=0;
|
||||
boolean remoteClosed = false;
|
||||
|
||||
LOG.debug("{} unwrap {} {}",_session,_inNIOBuffer.space()>0,super.isOpen());
|
||||
|
||||
// loop filling as much encrypted data as we can into the buffer
|
||||
while (_inNIOBuffer.space()>0 && super.isOpen())
|
||||
{
|
||||
|
@ -696,6 +702,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
@Override
|
||||
public void scheduleWrite()
|
||||
{
|
||||
|
@ -703,7 +710,8 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
if (!HandshakeStatus.NEED_UNWRAP.equals(_engine.getHandshakeStatus()) || super.isBufferingOutput())
|
||||
super.scheduleWrite();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.ChannelEndPoint;
|
||||
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -14,7 +15,7 @@ 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 final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",200);
|
||||
|
||||
private static final Logger LOG = Log.getLogger(AsyncHttpConnection.class);
|
||||
private int _total_no_progress;
|
||||
|
@ -134,7 +135,15 @@ public class AsyncHttpConnection extends HttpConnection
|
|||
_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);
|
||||
|
||||
LOG.setDebugEnabled(true);
|
||||
Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl").setDebugEnabled(true);
|
||||
Log.getLogger(ChannelEndPoint.class).setDebugEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
if (NO_PROGRESS_CLOSE>0 && _total_no_progress>NO_PROGRESS_CLOSE)
|
||||
{
|
||||
LOG.warn("Closing EndPoint making no progress: "+_total_no_progress+" "+_endp);
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.net.ssl.TrustManagerFactory;
|
|||
import org.eclipse.jetty.http.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.server.ConnectorTimeoutTest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
||||
{
|
||||
|
@ -57,4 +58,12 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoProgress() throws Exception
|
||||
{
|
||||
testMaxIdleNoRequest();
|
||||
super.testMaxIdleWithSlowRequest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue