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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onIdleExpired()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessagesIn()
|
||||
{
|
||||
|
|
|
@ -158,6 +158,10 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
|
|||
@Override
|
||||
protected void onIdleExpired(TimeoutException timeout)
|
||||
{
|
||||
Connection connection = _connection;
|
||||
if (connection != null && !_connection.onIdleExpired())
|
||||
return;
|
||||
|
||||
boolean output_shutdown=isOutputShutdown();
|
||||
boolean input_shutdown=isInputShutdown();
|
||||
boolean fillFailed = _fillInterest.onFail(timeout);
|
||||
|
|
|
@ -73,6 +73,19 @@ public interface Connection extends Closeable
|
|||
@Override
|
||||
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 getMessagesOut();
|
||||
public long getBytesIn();
|
||||
|
|
|
@ -171,6 +171,12 @@ public class SslConnection extends AbstractConnection
|
|||
getDecryptedEndPoint().getConnection().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onIdleExpired()
|
||||
{
|
||||
return getDecryptedEndPoint().getConnection().onIdleExpired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillable()
|
||||
{
|
||||
|
@ -328,17 +334,29 @@ public class SslConnection extends AbstractConnection
|
|||
|
||||
public DecryptedEndPoint()
|
||||
{
|
||||
super(null,getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
|
||||
setIdleTimeout(getEndPoint().getIdleTimeout());
|
||||
// Disable idle timeout checking: no scheduler and -1 timeout for this instance.
|
||||
super(null, getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
|
||||
super.setIdleTimeout(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getIdleTimeout()
|
||||
{
|
||||
return getEndPoint().getIdleTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdleTimeout(long idleTimeout)
|
||||
{
|
||||
super.setIdleTimeout(idleTimeout);
|
||||
getEndPoint().setIdleTimeout(idleTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen()
|
||||
{
|
||||
return getEndPoint().isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WriteFlusher getWriteFlusher()
|
||||
{
|
||||
|
@ -922,12 +940,6 @@ public class SslConnection extends AbstractConnection
|
|||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen()
|
||||
{
|
||||
return getEndPoint().isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransport()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue