cleanup: Cleaner closing of MergingDatagramSocket.

This commit is contained in:
Boris Grozev 2016-11-30 15:30:42 -06:00
parent 633f05b4e5
commit dae6d32875

View File

@ -117,15 +117,16 @@ public class MergingDatagramSocket
@Override
public void close()
{
logger.info("Closing.");
if (isClosed())
{
return;
}
closed = true;
logger.info("Closing.");
// XXX do we want to risk obtaining the lock here, or should we just
// let any thread in find out about the close after it's next timeout?
// let any thread in receive() find out about the close after it's next
// timeout?
synchronized (receiveLock)
{
receiveLock.notifyAll();
@ -135,8 +136,9 @@ public class MergingDatagramSocket
{
for (SocketContainer container : socketContainers)
{
doRemove(container.getSocket());
container.close(false);
}
socketContainers = new SocketContainer[0];
}
}