Merge pull request #94 from bgrozev/fix-fd-leak

fix: Propagates close() to the underlying DatagramSocket implementation
This commit is contained in:
Дамян Минков 2017-01-11 13:34:54 -06:00 committed by GitHub
commit cefd964509
2 changed files with 31 additions and 19 deletions

View File

@ -202,9 +202,13 @@ public class ComponentSocket
super.close();
}
finally
{
Component component = this.component;
if (component != null)
{
component.getParentStream().removePairStateChangeListener(this);
component = null;
this.component = null;
}
}
}
}

View File

@ -136,6 +136,13 @@ public class MergingDatagramSocket
@Override
public void close()
{
try
{
super.close();
}
finally
{
if (isClosed())
{
return;
@ -144,8 +151,8 @@ public class MergingDatagramSocket
logger.info("Closing.");
// XXX do we want to risk obtaining the lock here, or should we just
// let any thread in receive() 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();
@ -161,6 +168,7 @@ public class MergingDatagramSocket
socketContainers = new SocketContainer[0];
}
}
}
/**
* {@inheritDoc}