Adds some patchs contributed by Daniel Pocock that adds additionnals logs and fixes some problems related to race conditions.
This commit is contained in:
parent
c6f54124d5
commit
163fead8ad
@ -433,9 +433,15 @@ public class Agent
|
||||
preferredPort, minPort, maxPort, Transport.TCP);
|
||||
}
|
||||
|
||||
logger.fine("host candidate count: " +
|
||||
component.getLocalCandidateCount());
|
||||
|
||||
//apply other harvesters here
|
||||
harvesters.harvest(component);
|
||||
|
||||
logger.fine("host+harvested candidate count: " +
|
||||
component.getLocalCandidateCount());
|
||||
|
||||
computeFoundations(component);
|
||||
|
||||
//make sure we compute priorities only after we have all candidates
|
||||
@ -444,6 +450,9 @@ public class Agent
|
||||
//eliminate redundant candidates
|
||||
component.eliminateRedundantCandidates();
|
||||
|
||||
logger.fine("host+harvested candidate count (after elimination): " +
|
||||
component.getLocalCandidateCount());
|
||||
|
||||
//select the candidate to put in the media line.
|
||||
component.selectDefaultCandidate();
|
||||
}
|
||||
@ -458,7 +467,16 @@ public class Agent
|
||||
logger.info("Start ICE connectivity establishment");
|
||||
shutdown = false;
|
||||
pruneNonMatchedStreams();
|
||||
initCheckLists();
|
||||
|
||||
try
|
||||
{
|
||||
initCheckLists();
|
||||
}
|
||||
catch(ArithmeticException e)
|
||||
{
|
||||
setState(IceProcessingState.FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
//change state before we actually send checks so that we don't
|
||||
//miss responses and hence the possibility to nominate a pair.
|
||||
@ -2044,6 +2062,7 @@ public class Agent
|
||||
for(IceMediaStream stream : streams)
|
||||
{
|
||||
List<Component> cmps = stream.getComponents();
|
||||
|
||||
for(Component cmp : cmps)
|
||||
{
|
||||
CandidatePair pair = cmp.getSelectedPair();
|
||||
|
||||
@ -688,7 +688,7 @@ public abstract class Candidate
|
||||
{
|
||||
StringBuilder buff = new StringBuilder("candidate: ");
|
||||
|
||||
buff.append(" ").append(getFoundation());
|
||||
buff.append(getFoundation());
|
||||
buff.append(" ").append(getParentComponent().getComponentID());
|
||||
buff.append(" ").append(getTransport());
|
||||
buff.append(" ").append(getPriority());
|
||||
|
||||
@ -151,31 +151,6 @@ class ConnectivityCheckClient
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start check for pair after some delay seconds
|
||||
*
|
||||
* @param candidatePair
|
||||
* @param delay delay in millisecond
|
||||
*/
|
||||
private void startDelayedCheckForPair(final CandidatePair candidatePair,
|
||||
final int delay)
|
||||
{
|
||||
new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
}
|
||||
startCheckForPair(candidatePair);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a STUN {@link Request} containing the necessary PRIORITY and
|
||||
* CONTROLLING/CONTROLLED attributes. Also stores a reference to
|
||||
|
||||
@ -9,6 +9,7 @@ package org.ice4j.ice.harvest;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.ice4j.ice.*;
|
||||
|
||||
@ -21,6 +22,13 @@ import org.ice4j.ice.*;
|
||||
public class CandidateHarvesterSet
|
||||
extends AbstractSet<CandidateHarvester>
|
||||
{
|
||||
/**
|
||||
* The <tt>Logger</tt> used by the <tt>Agent</tt> class and its instances
|
||||
* for logging output.
|
||||
*/
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(CandidateHarvesterSet.class.getName());
|
||||
|
||||
/**
|
||||
* The <tt>CandidateHarvester</tt>s which are the elements of this
|
||||
* <tt>Set</tt>.
|
||||
@ -152,6 +160,9 @@ public class CandidateHarvesterSet
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
logger.info(
|
||||
"disabling harvester due to exception: " +
|
||||
t.getLocalizedMessage());
|
||||
harvester.setEnabled(false);
|
||||
|
||||
if (t instanceof ThreadDeath)
|
||||
@ -232,6 +243,7 @@ public class CandidateHarvesterSet
|
||||
}
|
||||
catch (CancellationException ce)
|
||||
{
|
||||
logger.info("harvester cancelled");
|
||||
/*
|
||||
* It got cancelled so we cannot say that the fault is with
|
||||
* its current harvester.
|
||||
@ -246,6 +258,10 @@ public class CandidateHarvesterSet
|
||||
* for the purpose of determining whether the problem has
|
||||
* appeared while working with a harvester.
|
||||
*/
|
||||
logger.info(
|
||||
"disabling harvester due to ExecutionException: " +
|
||||
ee.getLocalizedMessage());
|
||||
|
||||
CandidateHarvesterSetElement harvester
|
||||
= task.getKey().getHarvester();
|
||||
|
||||
@ -442,6 +458,7 @@ public class CandidateHarvesterSet
|
||||
*/
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
logger.info("disabling harvester: " + harvester);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,8 +101,10 @@ public class StunCandidateHarvester
|
||||
this.shortTermCredentialUsername = shortTermCredentialUsername;
|
||||
|
||||
//these should be configurable.
|
||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
|
||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "3");
|
||||
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER) == null)
|
||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
|
||||
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS) == null)
|
||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "3");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +118,8 @@ public class StunCandidateHarvester
|
||||
*/
|
||||
void completedResolvingCandidate(StunCandidateHarvest harvest)
|
||||
{
|
||||
boolean doNotify = false;
|
||||
|
||||
synchronized (startedHarvests)
|
||||
{
|
||||
startedHarvests.remove(harvest);
|
||||
@ -123,7 +127,7 @@ public class StunCandidateHarvester
|
||||
//if this was the last candidate, we are done with the STUN
|
||||
//resolution and need to notify the waiters.
|
||||
if (startedHarvests.isEmpty())
|
||||
startedHarvests.notify();
|
||||
doNotify = true;
|
||||
}
|
||||
|
||||
synchronized (completedHarvests)
|
||||
@ -133,6 +137,12 @@ public class StunCandidateHarvester
|
||||
else if (!completedHarvests.contains(harvest))
|
||||
completedHarvests.add(harvest);
|
||||
}
|
||||
|
||||
synchronized(startedHarvests)
|
||||
{
|
||||
if(doNotify)
|
||||
startedHarvests.notify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,6 +226,9 @@ public class StunCandidateHarvester
|
||||
*/
|
||||
public Collection<LocalCandidate> harvest(Component component)
|
||||
{
|
||||
logger.fine("invoked harvest / stream.component: " + toString() + " / "
|
||||
+ component.getParentStream().getName() + " / " +
|
||||
component.getComponentID());
|
||||
stunStack = component.getParentStream().getParentAgent().getStunStack();
|
||||
|
||||
for (Candidate cand : component.getLocalCandidates())
|
||||
@ -238,14 +251,31 @@ public class StunCandidateHarvester
|
||||
LocalCandidate[] completedHarvestCandidates
|
||||
= completedHarvest.getCandidates();
|
||||
|
||||
if ((completedHarvestCandidates != null)
|
||||
&& (completedHarvestCandidates.length != 0))
|
||||
if (completedHarvestCandidates != null)
|
||||
{
|
||||
candidates.addAll(
|
||||
logger.fine("harvest / stream.component: " + toString() +
|
||||
" / " + component.getParentStream().getName() + " / " +
|
||||
component.getComponentID() +
|
||||
": completedHarvestCandidates element count: " +
|
||||
completedHarvests.size());
|
||||
|
||||
if(completedHarvestCandidates.length != 0)
|
||||
{
|
||||
candidates.addAll(
|
||||
Arrays.asList(completedHarvestCandidates));
|
||||
}
|
||||
}
|
||||
else
|
||||
logger.fine("harvest / stream.component: " + toString() +
|
||||
" / " + component.getParentStream().getName() + " / " +
|
||||
component.getComponentID() +
|
||||
": completedHarvestCandidates == null");
|
||||
}
|
||||
}
|
||||
logger.info("harvest / stream.component: " + toString() + " / "
|
||||
+ component.getParentStream().getName() + " / " +
|
||||
component.getComponentID() +
|
||||
"found " + candidates.size() + " candidates.");
|
||||
return candidates;
|
||||
}
|
||||
|
||||
@ -266,12 +296,20 @@ public class StunCandidateHarvester
|
||||
HostCandidate cand = getHostCandidate(hostCand);
|
||||
|
||||
if(cand == null)
|
||||
{
|
||||
logger.info("server/candidate address type mismatch, skipping " +
|
||||
"candidate in this harvester");
|
||||
return;
|
||||
}
|
||||
|
||||
StunCandidateHarvest harvest = createHarvest(cand);
|
||||
|
||||
if (harvest == null)
|
||||
{
|
||||
logger.warning("failed to create harvest");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (startedHarvests)
|
||||
{
|
||||
startedHarvests.add(harvest);
|
||||
@ -297,7 +335,11 @@ public class StunCandidateHarvester
|
||||
finally
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
startedHarvests.remove(harvest);
|
||||
logger.warning("harvest did not start, removed: " +
|
||||
harvest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,6 +362,9 @@ public class StunCandidateHarvester
|
||||
}
|
||||
catch (InterruptedException iex)
|
||||
{
|
||||
logger.info(
|
||||
"interrupted waiting for harvests to complete, no. " +
|
||||
"startedHarvests = " + startedHarvests.size());
|
||||
interrupted = true;
|
||||
}
|
||||
// Restore the interrupted status.
|
||||
|
||||
@ -881,10 +881,18 @@ public abstract class Message
|
||||
offset += RFC3489_TRANSACTION_ID_LENGTH;
|
||||
}
|
||||
|
||||
Iterator<Map.Entry<Character, Attribute>> iter
|
||||
= attributes.entrySet().iterator();
|
||||
Vector<Map.Entry<Character, Attribute>> v =
|
||||
new Vector<Map.Entry<Character, Attribute>>();
|
||||
Iterator<Map.Entry<Character, Attribute>> iter = null;
|
||||
char dataLengthForContentDependentAttribute = 0;
|
||||
|
||||
synchronized (attributes)
|
||||
{
|
||||
v.addAll(attributes.entrySet());
|
||||
}
|
||||
|
||||
iter = v.iterator();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Attribute attribute = iter.next().getValue();
|
||||
|
||||
@ -133,6 +133,9 @@ public class SafeCloseDatagramSocket
|
||||
{
|
||||
super.close();
|
||||
|
||||
if(inReceiveSyncRoot == null)
|
||||
return;
|
||||
|
||||
synchronized (inReceiveSyncRoot)
|
||||
{
|
||||
boolean interrupted = false;
|
||||
|
||||
@ -230,6 +230,8 @@ class StunClientTransaction
|
||||
|
||||
try
|
||||
{
|
||||
logger.fine("retrying transmission of STUN test to " +
|
||||
requestDestination.getHostAddress());
|
||||
sendRequest0();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user