Moves UPnP search for WANIPConnection and WANPPPConnection when harvesting is started, to avoid block when harvester is created.
This commit is contained in:
parent
c8d9101610
commit
f36c7609a8
@ -65,14 +65,31 @@ public class UPNPHarvester
|
||||
private int finishThreads = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Gathers UPnP candidates for all host <tt>Candidate</tt>s that are
|
||||
* already present in the specified <tt>component</tt>. This method relies
|
||||
* on the specified <tt>component</tt> to already contain all its host
|
||||
* candidates so that it would resolve them.
|
||||
*
|
||||
* @param component the {@link Component} that we'd like to gather candidate
|
||||
* UPnP <tt>Candidate</tt>s for
|
||||
* @return the <tt>LocalCandidate</tt>s gathered by this
|
||||
* <tt>CandidateHarvester</tt>
|
||||
*/
|
||||
public UPNPHarvester()
|
||||
public synchronized Collection<LocalCandidate> harvest(Component component)
|
||||
{
|
||||
Collection<LocalCandidate> candidates = new HashSet<LocalCandidate>();
|
||||
int retries = 0;
|
||||
|
||||
logger.info("Begin UPnP harvesting");
|
||||
try
|
||||
{
|
||||
if(device == null)
|
||||
{
|
||||
// do it only once
|
||||
if(finishThreads == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("Begin UPnP harvesting");
|
||||
|
||||
UPNPThread wanIPThread = new UPNPThread(stIP);
|
||||
UPNPThread wanPPPThread = new UPNPThread(stPPP);
|
||||
|
||||
@ -97,32 +114,13 @@ public class UPNPHarvester
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
catch(Throwable e)
|
||||
{
|
||||
logger.info("UPnP discovery failed: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers UPnP candidates for all host <tt>Candidate</tt>s that are
|
||||
* already present in the specified <tt>component</tt>. This method relies
|
||||
* on the specified <tt>component</tt> to already contain all its host
|
||||
* candidates so that it would resolve them.
|
||||
*
|
||||
* @param component the {@link Component} that we'd like to gather candidate
|
||||
* UPnP <tt>Candidate</tt>s for
|
||||
* @return the <tt>LocalCandidate</tt>s gathered by this
|
||||
* <tt>CandidateHarvester</tt>
|
||||
*/
|
||||
public synchronized Collection<LocalCandidate> harvest(Component component)
|
||||
{
|
||||
Collection<LocalCandidate> candidates = new HashSet<LocalCandidate>();
|
||||
int retries = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if(device == null)
|
||||
{
|
||||
return candidates;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user