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 @Override
public void close() public void close()
{ {
logger.info("Closing.");
if (isClosed()) if (isClosed())
{ {
return; return;
} }
closed = true; closed = true;
logger.info("Closing.");
// XXX do we want to risk obtaining the lock here, or should we just // 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) synchronized (receiveLock)
{ {
receiveLock.notifyAll(); receiveLock.notifyAll();
@ -135,8 +136,9 @@ public class MergingDatagramSocket
{ {
for (SocketContainer container : socketContainers) for (SocketContainer container : socketContainers)
{ {
doRemove(container.getSocket()); container.close(false);
} }
socketContainers = new SocketContainer[0];
} }
} }