Merge pull request #94 from bgrozev/fix-fd-leak
fix: Propagates close() to the underlying DatagramSocket implementation
This commit is contained in:
commit
cefd964509
@ -203,8 +203,12 @@ public class ComponentSocket
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
component.getParentStream().removePairStateChangeListener(this);
|
Component component = this.component;
|
||||||
component = null;
|
if (component != null)
|
||||||
|
{
|
||||||
|
component.getParentStream().removePairStateChangeListener(this);
|
||||||
|
this.component = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,29 +136,37 @@ public class MergingDatagramSocket
|
|||||||
@Override
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
if (isClosed())
|
try
|
||||||
{
|
{
|
||||||
return;
|
super.close();
|
||||||
}
|
}
|
||||||
closed = true;
|
finally
|
||||||
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?
|
|
||||||
synchronized (receiveLock)
|
|
||||||
{
|
{
|
||||||
receiveLock.notifyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (socketContainersSyncRoot)
|
if (isClosed())
|
||||||
{
|
|
||||||
active = null;
|
|
||||||
for (SocketContainer container : socketContainers)
|
|
||||||
{
|
{
|
||||||
container.close(false);
|
return;
|
||||||
|
}
|
||||||
|
closed = true;
|
||||||
|
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?
|
||||||
|
synchronized (receiveLock)
|
||||||
|
{
|
||||||
|
receiveLock.notifyAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (socketContainersSyncRoot)
|
||||||
|
{
|
||||||
|
active = null;
|
||||||
|
for (SocketContainer container : socketContainers)
|
||||||
|
{
|
||||||
|
container.close(false);
|
||||||
|
}
|
||||||
|
socketContainers = new SocketContainer[0];
|
||||||
}
|
}
|
||||||
socketContainers = new SocketContainer[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user