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