Mercurial Hosting > luan
changeset 952:669769bcdf5c
simplify AsyncEndPoint
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 12 Oct 2016 19:47:45 -0600 |
parents | e542a9cc75ef |
children | 7db4a488fc82 |
files | src/org/eclipse/jetty/io/AsyncEndPoint.java src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java src/org/eclipse/jetty/io/nio/SelectorManager.java src/org/eclipse/jetty/io/nio/SslConnection.java src/org/eclipse/jetty/server/nio/SelectChannelConnector.java src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java |
diffstat | 6 files changed, 17 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/AsyncEndPoint.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/io/AsyncEndPoint.java Wed Oct 12 19:47:45 2016 -0600 @@ -29,19 +29,12 @@ public void dispatch(); /* ------------------------------------------------------------ */ - /** Schedule a write dispatch. - * Set the endpoint to not be writable and schedule a dispatch when - * it becomes writable. - */ - public void scheduleWrite(); - - /* ------------------------------------------------------------ */ /** Callback when idle. * <p>An endpoint is idle if there has been no IO activity for * {@link #getMaxIdleTime()} and {@link #isCheckForIdle()} is true. * @param idleForMs TODO */ - public void onIdleExpired(long idleForMs); +// public void onIdleExpired(long idleForMs); /* ------------------------------------------------------------ */ /** Set if the endpoint should be checked for idleness @@ -49,15 +42,6 @@ public void setCheckForIdle(boolean check); /* ------------------------------------------------------------ */ - /** Get if the endpoint should be checked for idleness - */ - public boolean isCheckForIdle(); - - - /* ------------------------------------------------------------ */ - public boolean isWritable(); - - /* ------------------------------------------------------------ */ /** * @return True if IO has been successfully performed since the last call to {@link #hasProgressed()} */
--- a/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Wed Oct 12 19:47:45 2016 -0600 @@ -230,7 +230,7 @@ _checkIdle=false; } - public boolean isCheckForIdle() + private boolean isCheckForIdle() { return _checkIdle; } @@ -268,7 +268,7 @@ } } - public void onIdleExpired(long idleForMs) + private void onIdleExpired(long idleForMs) { try { @@ -442,25 +442,6 @@ } /* ------------------------------------------------------------ */ - /** - * @see org.eclipse.jetty.io.AsyncEndPoint#scheduleWrite() - */ - public void scheduleWrite() - { - if (_writable) - LOG.debug("Required scheduleWrite {}",this); - - _writable=false; - updateKey(); - } - - /* ------------------------------------------------------------ */ - public boolean isWritable() - { - return _writable; - } - - /* ------------------------------------------------------------ */ public boolean hasProgressed() { return false;
--- a/src/org/eclipse/jetty/io/nio/SelectorManager.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java Wed Oct 12 19:47:45 2016 -0600 @@ -207,7 +207,7 @@ super.doStop(); } - public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment); + public abstract AsyncConnection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint, Object attachment); public String dump() {
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Wed Oct 12 19:47:45 2016 -0600 @@ -61,7 +61,7 @@ private NIOBuffer _inbound; private NIOBuffer _unwrapBuf; private NIOBuffer _outbound; - private AsyncEndPoint _aEndp; + private final AsyncEndPoint _aEndp; private boolean _allowRenegotiate=true; private boolean _handshook; private boolean _ishut; @@ -85,26 +85,18 @@ } } - /* ------------------------------------------------------------ */ - public SslConnection(SSLEngine engine,EndPoint endp) + public SslConnection(SSLEngine engine,AsyncEndPoint endp) { this(engine,endp,System.currentTimeMillis()); } - /* ------------------------------------------------------------ */ - public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp) + private SslConnection(SSLEngine engine,AsyncEndPoint endp, long timeStamp) { super(endp,timeStamp); _engine=engine; _session=_engine.getSession(); - _aEndp=(AsyncEndPoint)endp; - _sslEndPoint = newSslEndPoint(); - } - - /* ------------------------------------------------------------ */ - protected SslEndPoint newSslEndPoint() - { - return new SslEndPoint(); + _aEndp=endp; + _sslEndPoint = new SslEndPoint(); } /* ------------------------------------------------------------ */ @@ -604,8 +596,7 @@ return ByteBuffer.wrap(buffer.array()); } - /* ------------------------------------------------------------ */ - public AsyncEndPoint getSslEndPoint() + public SslEndPoint getSslEndPoint() { return _sslEndPoint; } @@ -616,9 +607,8 @@ return String.format("%s %s", super.toString(), _sslEndPoint); } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - public class SslEndPoint implements AsyncEndPoint + + public final class SslEndPoint implements AsyncEndPoint { public SSLEngine getSslEngine() { @@ -743,31 +733,11 @@ _aEndp.dispatch(); } - public void scheduleWrite() - { - _aEndp.scheduleWrite(); - } - - public void onIdleExpired(long idleForMs) - { - _aEndp.onIdleExpired(idleForMs); - } - public void setCheckForIdle(boolean check) { _aEndp.setCheckForIdle(check); } - public boolean isCheckForIdle() - { - return _aEndp.isCheckForIdle(); - } - - public boolean isWritable() - { - return _aEndp.isWritable(); - } - public boolean hasProgressed() { return _progressed.getAndSet(false);
--- a/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java Wed Oct 12 19:47:45 2016 -0600 @@ -123,7 +123,7 @@ super.doStart(); } - protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint) + protected AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint) { return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,server); } @@ -138,7 +138,7 @@ } @Override - public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint, Object attachment) + public AsyncConnection newConnection(SocketChannel channel,SelectChannelEndPoint endpoint, Object attachment) { return SelectChannelConnector.this.newConnection(channel,endpoint); }
--- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Wed Oct 12 18:12:12 2016 -0600 +++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Wed Oct 12 19:47:45 2016 -0600 @@ -35,6 +35,7 @@ import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.io.nio.AsyncConnection; import org.eclipse.jetty.io.nio.SslConnection; +import org.eclipse.jetty.io.nio.SelectChannelEndPoint; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.nio.SelectChannelConnector; @@ -530,15 +531,14 @@ return true; } - /* ------------------------------------------------------------------------------- */ @Override protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint) { try { SSLEngine engine = createSSLEngine(channel); - SslConnection connection = newSslConnection(endpoint, engine); - AsyncConnection delegate = newPlainConnection(channel, connection.getSslEndPoint()); + SslConnection connection = new SslConnection(engine, endpoint); + AsyncConnection delegate = super.newConnection(channel, connection.getSslEndPoint()); connection.getSslEndPoint().setConnection(delegate); connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate()); return connection; @@ -549,16 +549,6 @@ } } - 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