Fixes two deadlocks. Also do not answer to a Google's binding request if we do not know yet the local/remote ufrag (this case can happen if we receive binding checks before we start ICE connectivity checks) because it will in certain circumstances choose a different active candidates than the remote peer..
This commit is contained in:
parent
ef03b44b3a
commit
169e56c22f
@ -462,6 +462,8 @@ public class Agent
|
||||
//trigger a check for those candidate pairs.
|
||||
if(this.preDiscoveredPairsQueue.size() > 0)
|
||||
{
|
||||
logger.info("Trigger checks for pairs that were received " +
|
||||
"before running state");
|
||||
Iterator<CandidatePair> it = preDiscoveredPairsQueue.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
@ -1256,6 +1258,8 @@ public class Agent
|
||||
return;
|
||||
}
|
||||
|
||||
useCandidate = pair.useCandidateReceived();
|
||||
|
||||
remoteCandidate = new RemoteCandidate(
|
||||
remoteAddress, parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
@ -1277,6 +1281,9 @@ public class Agent
|
||||
CandidatePair triggeredPair
|
||||
= new CandidatePair(localCandidate, remoteCandidate);
|
||||
|
||||
|
||||
logger.info("set use-candidate " + useCandidate + " for pair " +
|
||||
triggeredPair.toShortString());
|
||||
if(useCandidate)
|
||||
{
|
||||
triggeredPair.setUseCandidateReceived();
|
||||
@ -1288,6 +1295,9 @@ public class Agent
|
||||
{
|
||||
//we are started, which means we have the remote candidates
|
||||
//so it's now safe to go and see whether this is a new PR cand.
|
||||
logger.info("Receive check from " +
|
||||
triggeredPair.toShortString() +
|
||||
"triggered a check");
|
||||
triggerCheck(triggeredPair);
|
||||
}
|
||||
else
|
||||
@ -1323,8 +1333,7 @@ public class Agent
|
||||
{
|
||||
//if the incoming request contained a USE-CANDIDATE attribute then
|
||||
//make sure we don't lose this piece of info.
|
||||
if (triggerPair.useCandidateReceived() ||
|
||||
compatibilityMode == CompatibilityMode.GTALK)
|
||||
if (triggerPair.useCandidateReceived())
|
||||
knownPair.setUseCandidateReceived();
|
||||
|
||||
triggerPair = knownPair;
|
||||
@ -1337,6 +1346,7 @@ public class Agent
|
||||
//7.2.1.5. Updating the Nominated Flag
|
||||
if (!isControlling() && triggerPair.useCandidateReceived())
|
||||
{
|
||||
logger.info("update nominated flag");
|
||||
// If the Binding request received by the agent had the
|
||||
// USE-CANDIDATE attribute set, and the agent is in the
|
||||
// controlled role, the agent looks at the state of the
|
||||
@ -1354,6 +1364,12 @@ public class Agent
|
||||
//ICE processing state.
|
||||
checkListStatesUpdated();
|
||||
}
|
||||
else if(!isControlling())
|
||||
{
|
||||
//next time we will see a request it will be considered as
|
||||
// having USE-CANDIDATE
|
||||
triggerPair.setUseCandidateReceived();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ public abstract class Candidate
|
||||
*/
|
||||
if(candidateType == CandidateType.HOST_CANDIDATE)
|
||||
{
|
||||
priority += 1 * 1000 -
|
||||
priority += 0.95 * 1000 -
|
||||
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
||||
}
|
||||
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
||||
@ -404,7 +404,7 @@ public abstract class Candidate
|
||||
|
||||
// IPv6 has better priority than IPv4
|
||||
if(addr instanceof Inet6Address)
|
||||
priority += 10;
|
||||
priority += 50;
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
@ -45,6 +45,13 @@ public class CandidatePair
|
||||
*/
|
||||
private boolean useCandidate = false;
|
||||
|
||||
/**
|
||||
* A flag indicating whether we have sent a check request that
|
||||
* contained the USE-CANDIDATE attribute for this pair. It is used in
|
||||
* GTalk compatibility mode as it lacks USE-CANDIDATE.
|
||||
*/
|
||||
private boolean useCandidateSent = false;
|
||||
|
||||
/**
|
||||
* Indicates whether this <tt>CandidatePair</tt> is on any of this agent's
|
||||
* valid pair lists.
|
||||
@ -511,6 +518,26 @@ public class CandidatePair
|
||||
return connCheckTranID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises the <tt>useCandidateSent</tt> flag for this pair.
|
||||
*/
|
||||
public void setUseCandidateSent()
|
||||
{
|
||||
this.useCandidateSent = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if someone has previously raised this pair's
|
||||
* <tt>useCandidateSent</tt> flag and <tt>false</tt> otherwise.
|
||||
*
|
||||
* @return <tt>true</tt> if someone has previously raised this pair's
|
||||
* <tt>useCandidate</tt> flag and <tt>false</tt> otherwise.
|
||||
*/
|
||||
public boolean useCandidateSent()
|
||||
{
|
||||
return useCandidateSent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises the <tt>useCandidate</tt> flag for this pair.
|
||||
*/
|
||||
|
||||
@ -182,6 +182,16 @@ class ConnectivityCheckClient
|
||||
AttributeFactory.createUsernameAttribute(localUserName);
|
||||
|
||||
request.addAttribute(unameAttr);
|
||||
|
||||
if (parentAgent.isControlling())
|
||||
{
|
||||
//if we are the controlling agent then we need to indicate our
|
||||
//nominated pairs.
|
||||
if(candidatePair.isNominated())
|
||||
{
|
||||
candidatePair.setUseCandidateSent();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -497,9 +507,24 @@ class ConnectivityCheckClient
|
||||
Transport.TCP);
|
||||
}
|
||||
|
||||
LocalCandidate validLocalCandidate = parentAgent
|
||||
.findLocalCandidate(mappedAddress);
|
||||
// XXX GTALK, find local candidate with ufrag rather than mapped address
|
||||
LocalCandidate validLocalCandidate = null;
|
||||
|
||||
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
|
||||
{
|
||||
// find local candidate with ufrag rather than mapped address
|
||||
UsernameAttribute uname = (UsernameAttribute)request
|
||||
.getAttribute(Attribute.USERNAME);
|
||||
String username = new String(uname.getUsername());
|
||||
String ufrag = username.substring(16, 32);
|
||||
validLocalCandidate = parentAgent.findLocalCandidate(mappedAddress,
|
||||
ufrag);
|
||||
}
|
||||
else if(parentAgent.getCompatibilityMode() == CompatibilityMode.RFC5245)
|
||||
{
|
||||
validLocalCandidate = parentAgent
|
||||
.findLocalCandidate(mappedAddress);
|
||||
}
|
||||
|
||||
Candidate validRemoteCandidate = checkedPair.getRemoteCandidate();
|
||||
|
||||
// RFC 5245: The agent checks the mapped address from the STUN
|
||||
@ -648,7 +673,8 @@ class ConnectivityCheckClient
|
||||
if((parentAgent.isControlling()
|
||||
&& request.containsAttribute(Attribute.USE_CANDIDATE)) ||
|
||||
((parentAgent.getCompatibilityMode() ==
|
||||
CompatibilityMode.GTALK) && validPair.isNominated()))
|
||||
CompatibilityMode.GTALK) && //validPair.isNominated()))
|
||||
checkedPair.useCandidateSent()))
|
||||
{
|
||||
if(validPair.getParentComponent().getSelectedPair() == null)
|
||||
{
|
||||
@ -667,8 +693,9 @@ class ConnectivityCheckClient
|
||||
//itself had the USE-CANDIDATE attribute. This case is described in
|
||||
//Section 7.2.1.5, and may now result in setting the nominated flag for
|
||||
//the pair learned from the original request.
|
||||
else if(checkedPair.useCandidateReceived()
|
||||
&& ! checkedPair.isNominated())
|
||||
else if(!parentAgent.isControlling() &&
|
||||
checkedPair.useCandidateReceived() &&
|
||||
!checkedPair.isNominated())
|
||||
{
|
||||
if(checkedPair.getParentComponent().getSelectedPair() == null)
|
||||
{
|
||||
@ -939,7 +966,10 @@ class ConnectivityCheckClient
|
||||
{
|
||||
synchronized (paceMakers)
|
||||
{
|
||||
paceMakers.remove(this);
|
||||
synchronized(this)
|
||||
{
|
||||
paceMakers.remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,8 @@ class ConnectivityCheckServer
|
||||
/* Google Talk ICE dialect considers every request to have
|
||||
* USE-CANDIDATE behavior.
|
||||
*/
|
||||
useCandidate = true;
|
||||
// it will be set in Agent.incomingCheckReceived
|
||||
useCandidate = false; //true;
|
||||
|
||||
/* Google Talk STUN request does not contains PRIORITY attribute
|
||||
* set it to the peer reflexive value (0.9 * 1000);
|
||||
@ -142,6 +143,15 @@ class ConnectivityCheckServer
|
||||
remoteUfrag = username.substring(0, colon);
|
||||
}
|
||||
|
||||
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK &&
|
||||
parentAgent.findCandidatePair(localUFrag, remoteUfrag) == null)
|
||||
{
|
||||
logger.info("No candidate pair that match local and remote ufrag");
|
||||
// no candidate pair for the moment so do not send response
|
||||
// XXX maybe sent an error
|
||||
return;
|
||||
}
|
||||
|
||||
//tell our address handler we saw a new remote address;
|
||||
parentAgent.incomingCheckReceived(evt.getRemoteAddress(),
|
||||
evt.getLocalAddress(), priority, remoteUfrag, localUFrag,
|
||||
|
||||
@ -189,53 +189,62 @@ public class DefaultNominator
|
||||
* @param evt the {@link PropertyChangeEvent} containing the pair which
|
||||
* has been validated.
|
||||
*/
|
||||
private synchronized void strategyNominateFirstHostOrReflexiveValid(
|
||||
private void strategyNominateFirstHostOrReflexiveValid(
|
||||
PropertyChangeEvent evt)
|
||||
{
|
||||
if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName()))
|
||||
{
|
||||
CandidatePair validPair = (CandidatePair)evt.getSource();
|
||||
|
||||
TimerTask task = validatedCandidates.get(
|
||||
validPair.getParentComponent().toShortString());
|
||||
TimerTask task = null;
|
||||
boolean isRelayed =
|
||||
(validPair.getLocalCandidate() instanceof RelayedCandidate) ||
|
||||
validPair.getLocalCandidate().getType().equals(
|
||||
CandidateType.RELAYED_CANDIDATE) ||
|
||||
validPair.getRemoteCandidate().getType().equals(
|
||||
CandidateType.RELAYED_CANDIDATE);
|
||||
boolean nominate = false;
|
||||
|
||||
if(isRelayed && task == null)
|
||||
synchronized(validatedCandidates)
|
||||
{
|
||||
/* armed a timer and see if a host or server reflexive pair
|
||||
* gets nominated. Otherwise nominate the relayed candidate pair
|
||||
*/
|
||||
Timer timer = new Timer();
|
||||
task = new RelayedCandidateTask(validPair);
|
||||
task = validatedCandidates.get(
|
||||
validPair.getParentComponent().toShortString());
|
||||
|
||||
logger.info("Wait timeout to nominate relayed candidate");
|
||||
timer.schedule(task, 0);
|
||||
synchronized(validatedCandidates)
|
||||
if(isRelayed && task == null)
|
||||
{
|
||||
/* armed a timer and see if a host or server reflexive pair
|
||||
* gets nominated. Otherwise nominate the relayed candidate
|
||||
* pair
|
||||
*/
|
||||
Timer timer = new Timer();
|
||||
task = new RelayedCandidateTask(validPair);
|
||||
|
||||
logger.info("Wait timeout to nominate relayed candidate");
|
||||
timer.schedule(task, 0);
|
||||
validatedCandidates.put(
|
||||
validPair.getParentComponent().toShortString(),
|
||||
validPair.getParentComponent().toShortString(),
|
||||
task);
|
||||
}
|
||||
}
|
||||
else if(!isRelayed)
|
||||
{
|
||||
// host or server reflexive candidate pair
|
||||
if(task != null)
|
||||
else if(!isRelayed)
|
||||
{
|
||||
task.cancel();
|
||||
logger.info("Found a better candidate pair to nominate for "
|
||||
+ validPair.getParentComponent().toShortString());
|
||||
}
|
||||
// host or server reflexive candidate pair
|
||||
if(task != null)
|
||||
{
|
||||
task.cancel();
|
||||
logger.info(
|
||||
"Found a better candidate pair to nominate for "
|
||||
+ validPair.getParentComponent().
|
||||
toShortString());
|
||||
}
|
||||
|
||||
logger.info("Nominate (first highest valid): " +
|
||||
validPair.toShortString());
|
||||
parentAgent.nominate(validPair);
|
||||
logger.info("Nominate (first highest valid): " +
|
||||
validPair.toShortString());
|
||||
nominate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(nominate)
|
||||
parentAgent.nominate(validPair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -310,7 +310,7 @@ class NetAccessManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts all message processors
|
||||
* Stops message processors until processors count equals newSize.
|
||||
*
|
||||
* @param newSize the new thread pool size
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user