Added more SSL tests to detect spinning conditions.
This commit is contained in:
parent
e322a28753
commit
d1592cf5b5
File diff suppressed because it is too large
Load Diff
|
@ -16,7 +16,6 @@ package org.eclipse.jetty.io.nio;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -657,14 +656,8 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
|
||||
while (now<end)
|
||||
{
|
||||
process(null,null);
|
||||
synchronized (SslConnection.this)
|
||||
{
|
||||
if (_unwrapBuf!=null && _unwrapBuf.hasContent())
|
||||
break;
|
||||
if (_inbound!=null && _inbound.hasContent())
|
||||
break;
|
||||
}
|
||||
if (process(null,null))
|
||||
break;
|
||||
_endp.blockReadable(end-now);
|
||||
now = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -792,7 +785,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
Buffer i;
|
||||
Buffer o;
|
||||
Buffer u;
|
||||
|
||||
|
||||
synchronized(SslConnection.this)
|
||||
{
|
||||
i=_inbound;
|
||||
|
|
|
@ -16,7 +16,6 @@ package org.eclipse.jetty.server;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -42,6 +41,7 @@ import org.eclipse.jetty.io.AbstractConnection;
|
|||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||
import org.eclipse.jetty.io.Buffers;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
|
@ -148,7 +148,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
_uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
|
||||
_connector = connector;
|
||||
HttpBuffers ab = (HttpBuffers)_connector;
|
||||
_parser = new HttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler());
|
||||
_parser = newHttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler());
|
||||
_requestFields = new HttpFields();
|
||||
_responseFields = new HttpFields(server.getMaxCookieVersion());
|
||||
_request = new Request(this);
|
||||
|
@ -163,7 +163,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
Parser parser, Generator generator, Request request)
|
||||
{
|
||||
super(endpoint);
|
||||
|
||||
|
||||
_uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
|
||||
_connector = connector;
|
||||
_parser = parser;
|
||||
|
@ -176,6 +176,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
_server = server;
|
||||
}
|
||||
|
||||
protected HttpParser newHttpParser(Buffers requestBuffers, EndPoint endpoint, HttpParser.EventHandler requestHandler)
|
||||
{
|
||||
return new HttpParser(requestBuffers, endpoint, requestHandler);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return the parser used by this connection
|
||||
|
@ -193,13 +198,13 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
{
|
||||
return _requests;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Server getServer()
|
||||
{
|
||||
return _server;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the associatedObject.
|
||||
|
@ -385,11 +390,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
/* ------------------------------------------------------------ */
|
||||
public void reset()
|
||||
{
|
||||
_parser.reset();
|
||||
_parser.reset();
|
||||
_parser.returnBuffers(); // TODO maybe only on unhandle
|
||||
_requestFields.clear();
|
||||
_request.recycle();
|
||||
_generator.reset();
|
||||
_generator.reset();
|
||||
_generator.returnBuffers();// TODO maybe only on unhandle
|
||||
_responseFields.clear();
|
||||
_response.recycle();
|
||||
|
@ -561,7 +566,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
}
|
||||
catch(RuntimeException e)
|
||||
{
|
||||
LOG.warn("header full: "+e);
|
||||
LOG.warn("header full: " + e);
|
||||
|
||||
_response.reset();
|
||||
_generator.reset();
|
||||
|
@ -667,7 +672,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
{
|
||||
LOG.debug("closed {}",this);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isExpecting100Continues()
|
||||
{
|
||||
|
@ -712,7 +717,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
|
||||
{
|
||||
uri=uri.asImmutableBuffer();
|
||||
|
||||
|
||||
_host = false;
|
||||
_expect = false;
|
||||
_expect100Continue=false;
|
||||
|
@ -859,11 +864,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
_generator.setPersistent(true);
|
||||
_parser.setPersistent(true);
|
||||
}
|
||||
|
||||
|
||||
if (_server.getSendDateHeader())
|
||||
_generator.setDate(_request.getTimeStampBuffer());
|
||||
break;
|
||||
|
||||
|
||||
case HttpVersions.HTTP_1_1_ORDINAL:
|
||||
_generator.setHead(_head);
|
||||
|
||||
|
@ -954,7 +959,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Bad request!: "+version+" "+status+" "+reason);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1139,5 +1144,5 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,14 +31,11 @@ import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
|||
import org.eclipse.jetty.io.nio.SelectorManager;
|
||||
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
|
||||
import org.eclipse.jetty.server.AsyncHttpConnection;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
import org.eclipse.jetty.util.thread.Timeout.Task;
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
|
@ -97,7 +94,7 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
{
|
||||
server = _acceptChannel;
|
||||
}
|
||||
|
||||
|
||||
if (server!=null && server.isOpen() && _manager.isStarted())
|
||||
{
|
||||
SocketChannel channel = server.accept();
|
||||
|
@ -144,7 +141,7 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
{
|
||||
return _manager;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public synchronized Object getConnection()
|
||||
{
|
||||
|
@ -297,7 +294,7 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
/* ------------------------------------------------------------------------------- */
|
||||
protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint)
|
||||
{
|
||||
return new SelectChannelHttpConnection(SelectChannelConnector.this,endpoint,getServer());
|
||||
return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,getServer());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -310,24 +307,9 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
channel=_acceptChannel;
|
||||
}
|
||||
if (channel==null)
|
||||
AggregateLifeCycle.dump(out,indent,Arrays.asList(new Object[]{null,"CLOSED",_manager}));
|
||||
AggregateLifeCycle.dump(out,indent,Arrays.asList(null,"CLOSED",_manager));
|
||||
else
|
||||
AggregateLifeCycle.dump(out,indent,Arrays.asList(new Object[]{channel,channel.isOpen()?"OPEN":"CLOSED",_manager}));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
private class SelectChannelHttpConnection extends AsyncHttpConnection
|
||||
{
|
||||
private final AsyncEndPoint _endpoint;
|
||||
|
||||
private SelectChannelHttpConnection(Connector connector, EndPoint endpoint, Server server)
|
||||
{
|
||||
super(connector,endpoint,server);
|
||||
_endpoint=null;
|
||||
}
|
||||
|
||||
AggregateLifeCycle.dump(out,indent,Arrays.asList(channel,channel.isOpen()?"OPEN":"CLOSED",_manager));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -14,16 +14,12 @@
|
|||
package org.eclipse.jetty.server.ssl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpSchemes;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.Buffers;
|
||||
|
@ -33,10 +29,7 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.io.RuntimeIOException;
|
||||
import org.eclipse.jetty.io.bio.SocketEndPoint;
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
|
||||
import org.eclipse.jetty.io.nio.SslConnection;
|
||||
import org.eclipse.jetty.server.AsyncHttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
@ -102,7 +95,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
SslConnection.SslEndPoint sslEndpoint=(SslConnection.SslEndPoint)endpoint;
|
||||
SSLEngine sslEngine=sslEndpoint.getSslEngine();
|
||||
SSLSession sslSession=sslEngine.getSession();
|
||||
|
||||
|
||||
SslCertificates.customize(sslSession,endpoint,request);
|
||||
}
|
||||
|
||||
|
@ -541,13 +534,6 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
return integralPort==0||integralPort==request.getServerPort();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException
|
||||
{
|
||||
return super.newEndPoint(channel,selectSet,key);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
|
||||
|
@ -555,20 +541,28 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
try
|
||||
{
|
||||
SSLEngine engine = createSSLEngine(channel);
|
||||
|
||||
SslConnection connection = new SslConnection(engine,endpoint);
|
||||
|
||||
AsyncConnection delegate = super.newConnection(channel,connection.getSslEndPoint());
|
||||
SslConnection connection = newSslConnection(endpoint, engine);
|
||||
AsyncConnection delegate = newPlainConnection(channel, connection.getSslEndPoint());
|
||||
connection.getSslEndPoint().setConnection(delegate);
|
||||
connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate());
|
||||
return connection;
|
||||
}
|
||||
catch(IOException e)
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected AsyncConnection newPlainConnection(SocketChannel channel, AsyncEndPoint endPoint)
|
||||
{
|
||||
return super.newConnection(channel, endPoint);
|
||||
}
|
||||
|
||||
protected SslConnection newSslConnection(AsyncEndPoint endpoint, SSLEngine engine)
|
||||
{
|
||||
return new SslConnection(engine, endpoint);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param channel A channel which if passed is used as to extract remote
|
||||
|
@ -589,7 +583,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
{
|
||||
engine = _sslContextFactory.newSslEngine();
|
||||
}
|
||||
|
||||
|
||||
engine.setUseClientMode(false);
|
||||
return engine;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue