484718 - Review idle timeout handling.
Introduced Connection.onIdleExpired().
This commit is contained in:
parent
bcd282a8dd
commit
35c4c24099
|
@ -220,6 +220,12 @@ public abstract class AbstractConnection implements Connection
|
||||||
getEndPoint().close();
|
getEndPoint().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onIdleExpired()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMessagesIn()
|
public int getMessagesIn()
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,6 +158,10 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
|
||||||
@Override
|
@Override
|
||||||
protected void onIdleExpired(TimeoutException timeout)
|
protected void onIdleExpired(TimeoutException timeout)
|
||||||
{
|
{
|
||||||
|
Connection connection = _connection;
|
||||||
|
if (connection != null && !_connection.onIdleExpired())
|
||||||
|
return;
|
||||||
|
|
||||||
boolean output_shutdown=isOutputShutdown();
|
boolean output_shutdown=isOutputShutdown();
|
||||||
boolean input_shutdown=isInputShutdown();
|
boolean input_shutdown=isInputShutdown();
|
||||||
boolean fillFailed = _fillInterest.onFail(timeout);
|
boolean fillFailed = _fillInterest.onFail(timeout);
|
||||||
|
|
|
@ -73,6 +73,19 @@ public interface Connection extends Closeable
|
||||||
@Override
|
@Override
|
||||||
public void close();
|
public void close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Callback method invoked upon an idle timeout event.</p>
|
||||||
|
* <p>Implementations of this method may return true to indicate that the idle timeout
|
||||||
|
* handling should proceed normally, typically failing the EndPoint and causing it to
|
||||||
|
* be closed.</p>
|
||||||
|
* <p>When false is returned, the handling of the idle timeout event is halted
|
||||||
|
* immediately and the EndPoint left in the state it was before the idle timeout event.</p>
|
||||||
|
*
|
||||||
|
* @return true to let the EndPoint handle the idle timeout,
|
||||||
|
* false to tell the EndPoint to halt the handling of the idle timeout.
|
||||||
|
*/
|
||||||
|
public boolean onIdleExpired();
|
||||||
|
|
||||||
public int getMessagesIn();
|
public int getMessagesIn();
|
||||||
public int getMessagesOut();
|
public int getMessagesOut();
|
||||||
public long getBytesIn();
|
public long getBytesIn();
|
||||||
|
|
|
@ -171,6 +171,12 @@ public class SslConnection extends AbstractConnection
|
||||||
getDecryptedEndPoint().getConnection().close();
|
getDecryptedEndPoint().getConnection().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onIdleExpired()
|
||||||
|
{
|
||||||
|
return getDecryptedEndPoint().getConnection().onIdleExpired();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFillable()
|
public void onFillable()
|
||||||
{
|
{
|
||||||
|
@ -328,17 +334,29 @@ public class SslConnection extends AbstractConnection
|
||||||
|
|
||||||
public DecryptedEndPoint()
|
public DecryptedEndPoint()
|
||||||
{
|
{
|
||||||
super(null,getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
|
// Disable idle timeout checking: no scheduler and -1 timeout for this instance.
|
||||||
setIdleTimeout(getEndPoint().getIdleTimeout());
|
super(null, getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
|
||||||
|
super.setIdleTimeout(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getIdleTimeout()
|
||||||
|
{
|
||||||
|
return getEndPoint().getIdleTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdleTimeout(long idleTimeout)
|
public void setIdleTimeout(long idleTimeout)
|
||||||
{
|
{
|
||||||
super.setIdleTimeout(idleTimeout);
|
|
||||||
getEndPoint().setIdleTimeout(idleTimeout);
|
getEndPoint().setIdleTimeout(idleTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpen()
|
||||||
|
{
|
||||||
|
return getEndPoint().isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WriteFlusher getWriteFlusher()
|
protected WriteFlusher getWriteFlusher()
|
||||||
{
|
{
|
||||||
|
@ -443,10 +461,10 @@ public class SslConnection extends AbstractConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fillable)
|
if (fillable)
|
||||||
getExecutor().execute(_runFillable);
|
getExecutor().execute(_runFillable);
|
||||||
else
|
else
|
||||||
ensureFillInterested();
|
ensureFillInterested();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -710,13 +728,13 @@ public class SslConnection extends AbstractConnection
|
||||||
// will return 0 (even if some handshake bytes were flushed and filled).
|
// will return 0 (even if some handshake bytes were flushed and filled).
|
||||||
// it is the applications responsibility to call flush again - either in a busy loop
|
// it is the applications responsibility to call flush again - either in a busy loop
|
||||||
// or better yet by using EndPoint#write to do the flushing.
|
// or better yet by using EndPoint#write to do the flushing.
|
||||||
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
{
|
{
|
||||||
for (ByteBuffer b : appOuts)
|
for (ByteBuffer b : appOuts)
|
||||||
LOG.debug("{} flush {}", SslConnection.this, BufferUtil.toHexSummary(b));
|
LOG.debug("{} flush {}", SslConnection.this, BufferUtil.toHexSummary(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_cannotAcceptMoreAppDataToFlush)
|
if (_cannotAcceptMoreAppDataToFlush)
|
||||||
|
@ -746,7 +764,7 @@ public class SslConnection extends AbstractConnection
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
LOG.debug("{} wrap {}", SslConnection.this, wrapResult.toString().replace('\n',' '));
|
LOG.debug("{} wrap {}", SslConnection.this, wrapResult.toString().replace('\n',' '));
|
||||||
|
|
||||||
Status wrapResultStatus = wrapResult.getStatus();
|
Status wrapResultStatus = wrapResult.getStatus();
|
||||||
|
|
||||||
boolean allConsumed=true;
|
boolean allConsumed=true;
|
||||||
|
@ -906,7 +924,7 @@ public class SslConnection extends AbstractConnection
|
||||||
if (!SslConnection.this.isFillInterested())
|
if (!SslConnection.this.isFillInterested())
|
||||||
SslConnection.this.fillInterested();
|
SslConnection.this.fillInterested();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOutputShutdown()
|
public boolean isOutputShutdown()
|
||||||
{
|
{
|
||||||
|
@ -922,12 +940,6 @@ public class SslConnection extends AbstractConnection
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpen()
|
|
||||||
{
|
|
||||||
return getEndPoint().isOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getTransport()
|
public Object getTransport()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue