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
|
||||
{
|
||||
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
|
||||
{
|
||||
EndPoint endPoint = _selectorManager.newEndPoint(channel, this, selectionKey);
|
||||
endPoint.onOpen();
|
||||
_selectorManager.endPointOpened(endPoint);
|
||||
Connection connection = _selectorManager.newConnection(channel, endPoint, selectionKey.attachment());
|
||||
endPoint.setConnection(connection);
|
||||
|
@ -423,21 +424,17 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
return endPoint;
|
||||
}
|
||||
|
||||
public void onClose(final EndPoint endPoint)
|
||||
public void destroyEndPoint(final EndPoint endPoint)
|
||||
{
|
||||
final Connection connection = endPoint.getConnection();
|
||||
submit(new Product()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Destroyed {}", endPoint);
|
||||
if (connection != null)
|
||||
_selectorManager.connectionClosed(connection);
|
||||
endPoint.close();
|
||||
}
|
||||
});
|
||||
submit((Product)() ->
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Destroyed {}", endPoint);
|
||||
if (connection != null)
|
||||
_selectorManager.connectionClosed(connection);
|
||||
_selectorManager.endPointClosed(endPoint);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -304,7 +304,6 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
|
|||
*/
|
||||
protected void endPointOpened(EndPoint endpoint)
|
||||
{
|
||||
endpoint.onOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,7 +313,6 @@ public abstract class SelectorManager extends ContainerLifeCycle implements Dump
|
|||
*/
|
||||
protected void endPointClosed(EndPoint endpoint)
|
||||
{
|
||||
endpoint.onClose();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue