Merge pull request #115 from jitsi/fix-filedescriptor-leak
Fixes leak of file descriptors
This commit is contained in:
commit
51baa62ee2
@ -115,6 +115,11 @@ public class DelegatingDatagramSocket
|
|||||||
*/
|
*/
|
||||||
private long nbSentPackets = 0;
|
private long nbSentPackets = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this socket has been closed.
|
||||||
|
*/
|
||||||
|
private boolean closed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new <tt>DelegatingDatagramSocket</tt> instance and binds it
|
* Initializes a new <tt>DelegatingDatagramSocket</tt> instance and binds it
|
||||||
* to any available port on the local host machine. The socket will be
|
* to any available port on the local host machine. The socket will be
|
||||||
@ -282,10 +287,14 @@ public class DelegatingDatagramSocket
|
|||||||
@Override
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
if (delegate == null)
|
// We want both #delegate and super to actually get closed (and release
|
||||||
super.close();
|
// the FDs which they hold). But super will not close unless isClosed()
|
||||||
else
|
// returns false. So we update the #closed flag last.
|
||||||
|
if (delegate != null)
|
||||||
delegate.close();
|
delegate.close();
|
||||||
|
|
||||||
|
super.close();
|
||||||
|
closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -610,7 +619,7 @@ public class DelegatingDatagramSocket
|
|||||||
@Override
|
@Override
|
||||||
public boolean isClosed()
|
public boolean isClosed()
|
||||||
{
|
{
|
||||||
return (delegate == null) ? super.isClosed() : delegate.isClosed();
|
return closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -118,6 +118,8 @@ public class MultiplexedDatagramSocket
|
|||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
multiplexing.close(this);
|
multiplexing.close(this);
|
||||||
|
|
||||||
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -350,6 +350,8 @@ public class RelayedCandidateDatagramSocket
|
|||||||
turnCandidateHarvest.hostCandidate.getTransportAddress(),
|
turnCandidateHarvest.hostCandidate.getTransportAddress(),
|
||||||
this);
|
this);
|
||||||
turnCandidateHarvest.close(this);
|
turnCandidateHarvest.close(this);
|
||||||
|
|
||||||
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user