Fixed invocation of EndPoint.onClose().
Made sure EndPoint.onClose() is invoked only once and that EndPoints that have a socket channel associated invoke the SelectorManager lifecycle callbacks for EndPoints.
This commit is contained in:
parent
db8a59b6f5
commit
0cac43d53f
|
@ -181,7 +181,7 @@ public abstract class ChannelEndPoint extends AbstractEndPoint implements Manage
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (_selector!=null)
|
if (_selector!=null)
|
||||||
_selector.onClose(this);
|
_selector.destroyEndPoint(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
||||||
private EndPoint createEndPoint(SelectableChannel channel, SelectionKey selectionKey) throws IOException
|
private EndPoint createEndPoint(SelectableChannel channel, SelectionKey selectionKey) throws IOException
|
||||||
{
|
{
|
||||||
EndPoint endPoint = _selectorManager.newEndPoint(channel, this, selectionKey);
|
EndPoint endPoint = _selectorManager.newEndPoint(channel, this, selectionKey);
|
||||||
|
endPoint.onOpen();
|
||||||
_selectorManager.endPointOpened(endPoint);
|
_selectorManager.endPointOpened(endPoint);
|
||||||
Connection connection = _selectorManager.newConnection(channel, endPoint, selectionKey.attachment());
|
Connection connection = _selectorManager.newConnection(channel, endPoint, selectionKey.attachment());
|
||||||
endPoint.setConnection(connection);
|
endPoint.setConnection(connection);
|
||||||
|
@ -423,21 +424,17 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
||||||
return endPoint;
|
return endPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClose(final EndPoint endPoint)
|
public void destroyEndPoint(final EndPoint endPoint)
|
||||||
{
|
{
|
||||||
final Connection connection = endPoint.getConnection();
|
final Connection connection = endPoint.getConnection();
|
||||||
submit(new Product()
|
submit((Product)() ->
|
||||||
{
|
{
|
||||||
@Override
|
if (LOG.isDebugEnabled())
|
||||||
public void run()
|
LOG.debug("Destroyed {}", endPoint);
|
||||||
{
|
if (connection != null)
|
||||||
if (LOG.isDebugEnabled())
|
_selectorManager.connectionClosed(connection);
|
||||||
LOG.debug("Destroyed {}", endPoint);
|
_selectorManager.endPointClosed(endPoint);
|
||||||
if (connection != null)
|
});
|
||||||
_selectorManager.connectionClosed(connection);
|
|
||||||
endPoint.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -304,7 +304,6 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
|
||||||
*/
|
*/
|
||||||
protected void endPointOpened(EndPoint endpoint)
|
protected void endPointOpened(EndPoint endpoint)
|
||||||
{
|
{
|
||||||
endpoint.onOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,7 +313,6 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
|
||||||
*/
|
*/
|
||||||
protected void endPointClosed(EndPoint endpoint)
|
protected void endPointClosed(EndPoint endpoint)
|
||||||
{
|
{
|
||||||
endpoint.onClose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue