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.
|
//trigger a check for those candidate pairs.
|
||||||
if(this.preDiscoveredPairsQueue.size() > 0)
|
if(this.preDiscoveredPairsQueue.size() > 0)
|
||||||
{
|
{
|
||||||
|
logger.info("Trigger checks for pairs that were received " +
|
||||||
|
"before running state");
|
||||||
Iterator<CandidatePair> it = preDiscoveredPairsQueue.iterator();
|
Iterator<CandidatePair> it = preDiscoveredPairsQueue.iterator();
|
||||||
|
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
@ -1256,6 +1258,8 @@ public class Agent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useCandidate = pair.useCandidateReceived();
|
||||||
|
|
||||||
remoteCandidate = new RemoteCandidate(
|
remoteCandidate = new RemoteCandidate(
|
||||||
remoteAddress, parentComponent,
|
remoteAddress, parentComponent,
|
||||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||||
@ -1277,6 +1281,9 @@ public class Agent
|
|||||||
CandidatePair triggeredPair
|
CandidatePair triggeredPair
|
||||||
= new CandidatePair(localCandidate, remoteCandidate);
|
= new CandidatePair(localCandidate, remoteCandidate);
|
||||||
|
|
||||||
|
|
||||||
|
logger.info("set use-candidate " + useCandidate + " for pair " +
|
||||||
|
triggeredPair.toShortString());
|
||||||
if(useCandidate)
|
if(useCandidate)
|
||||||
{
|
{
|
||||||
triggeredPair.setUseCandidateReceived();
|
triggeredPair.setUseCandidateReceived();
|
||||||
@ -1288,6 +1295,9 @@ public class Agent
|
|||||||
{
|
{
|
||||||
//we are started, which means we have the remote candidates
|
//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.
|
//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);
|
triggerCheck(triggeredPair);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1323,8 +1333,7 @@ public class Agent
|
|||||||
{
|
{
|
||||||
//if the incoming request contained a USE-CANDIDATE attribute then
|
//if the incoming request contained a USE-CANDIDATE attribute then
|
||||||
//make sure we don't lose this piece of info.
|
//make sure we don't lose this piece of info.
|
||||||
if (triggerPair.useCandidateReceived() ||
|
if (triggerPair.useCandidateReceived())
|
||||||
compatibilityMode == CompatibilityMode.GTALK)
|
|
||||||
knownPair.setUseCandidateReceived();
|
knownPair.setUseCandidateReceived();
|
||||||
|
|
||||||
triggerPair = knownPair;
|
triggerPair = knownPair;
|
||||||
@ -1337,6 +1346,7 @@ public class Agent
|
|||||||
//7.2.1.5. Updating the Nominated Flag
|
//7.2.1.5. Updating the Nominated Flag
|
||||||
if (!isControlling() && triggerPair.useCandidateReceived())
|
if (!isControlling() && triggerPair.useCandidateReceived())
|
||||||
{
|
{
|
||||||
|
logger.info("update nominated flag");
|
||||||
// If the Binding request received by the agent had the
|
// If the Binding request received by the agent had the
|
||||||
// USE-CANDIDATE attribute set, and the agent is in the
|
// USE-CANDIDATE attribute set, and the agent is in the
|
||||||
// controlled role, the agent looks at the state of the
|
// controlled role, the agent looks at the state of the
|
||||||
@ -1354,6 +1364,12 @@ public class Agent
|
|||||||
//ICE processing state.
|
//ICE processing state.
|
||||||
checkListStatesUpdated();
|
checkListStatesUpdated();
|
||||||
}
|
}
|
||||||
|
else if(!isControlling())
|
||||||
|
{
|
||||||
|
//next time we will see a request it will be considered as
|
||||||
|
// having USE-CANDIDATE
|
||||||
|
triggerPair.setUseCandidateReceived();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -381,7 +381,7 @@ public abstract class Candidate
|
|||||||
*/
|
*/
|
||||||
if(candidateType == CandidateType.HOST_CANDIDATE)
|
if(candidateType == CandidateType.HOST_CANDIDATE)
|
||||||
{
|
{
|
||||||
priority += 1 * 1000 -
|
priority += 0.95 * 1000 -
|
||||||
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
||||||
}
|
}
|
||||||
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
||||||
@ -404,7 +404,7 @@ public abstract class Candidate
|
|||||||
|
|
||||||
// IPv6 has better priority than IPv4
|
// IPv6 has better priority than IPv4
|
||||||
if(addr instanceof Inet6Address)
|
if(addr instanceof Inet6Address)
|
||||||
priority += 10;
|
priority += 50;
|
||||||
|
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,13 @@ public class CandidatePair
|
|||||||
*/
|
*/
|
||||||
private boolean useCandidate = false;
|
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
|
* Indicates whether this <tt>CandidatePair</tt> is on any of this agent's
|
||||||
* valid pair lists.
|
* valid pair lists.
|
||||||
@ -511,6 +518,26 @@ public class CandidatePair
|
|||||||
return connCheckTranID;
|
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.
|
* Raises the <tt>useCandidate</tt> flag for this pair.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -182,6 +182,16 @@ class ConnectivityCheckClient
|
|||||||
AttributeFactory.createUsernameAttribute(localUserName);
|
AttributeFactory.createUsernameAttribute(localUserName);
|
||||||
|
|
||||||
request.addAttribute(unameAttr);
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -497,9 +507,24 @@ class ConnectivityCheckClient
|
|||||||
Transport.TCP);
|
Transport.TCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalCandidate validLocalCandidate = parentAgent
|
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);
|
.findLocalCandidate(mappedAddress);
|
||||||
// XXX GTALK, find local candidate with ufrag rather than mapped address
|
}
|
||||||
|
|
||||||
Candidate validRemoteCandidate = checkedPair.getRemoteCandidate();
|
Candidate validRemoteCandidate = checkedPair.getRemoteCandidate();
|
||||||
|
|
||||||
// RFC 5245: The agent checks the mapped address from the STUN
|
// RFC 5245: The agent checks the mapped address from the STUN
|
||||||
@ -648,7 +673,8 @@ class ConnectivityCheckClient
|
|||||||
if((parentAgent.isControlling()
|
if((parentAgent.isControlling()
|
||||||
&& request.containsAttribute(Attribute.USE_CANDIDATE)) ||
|
&& request.containsAttribute(Attribute.USE_CANDIDATE)) ||
|
||||||
((parentAgent.getCompatibilityMode() ==
|
((parentAgent.getCompatibilityMode() ==
|
||||||
CompatibilityMode.GTALK) && validPair.isNominated()))
|
CompatibilityMode.GTALK) && //validPair.isNominated()))
|
||||||
|
checkedPair.useCandidateSent()))
|
||||||
{
|
{
|
||||||
if(validPair.getParentComponent().getSelectedPair() == null)
|
if(validPair.getParentComponent().getSelectedPair() == null)
|
||||||
{
|
{
|
||||||
@ -667,8 +693,9 @@ class ConnectivityCheckClient
|
|||||||
//itself had the USE-CANDIDATE attribute. This case is described in
|
//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
|
//Section 7.2.1.5, and may now result in setting the nominated flag for
|
||||||
//the pair learned from the original request.
|
//the pair learned from the original request.
|
||||||
else if(checkedPair.useCandidateReceived()
|
else if(!parentAgent.isControlling() &&
|
||||||
&& ! checkedPair.isNominated())
|
checkedPair.useCandidateReceived() &&
|
||||||
|
!checkedPair.isNominated())
|
||||||
{
|
{
|
||||||
if(checkedPair.getParentComponent().getSelectedPair() == null)
|
if(checkedPair.getParentComponent().getSelectedPair() == null)
|
||||||
{
|
{
|
||||||
@ -938,12 +965,15 @@ class ConnectivityCheckClient
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
synchronized (paceMakers)
|
synchronized (paceMakers)
|
||||||
|
{
|
||||||
|
synchronized(this)
|
||||||
{
|
{
|
||||||
paceMakers.remove(this);
|
paceMakers.remove(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops and removes all PaceMakers.
|
* Stops and removes all PaceMakers.
|
||||||
|
|||||||
@ -121,7 +121,8 @@ class ConnectivityCheckServer
|
|||||||
/* Google Talk ICE dialect considers every request to have
|
/* Google Talk ICE dialect considers every request to have
|
||||||
* USE-CANDIDATE behavior.
|
* USE-CANDIDATE behavior.
|
||||||
*/
|
*/
|
||||||
useCandidate = true;
|
// it will be set in Agent.incomingCheckReceived
|
||||||
|
useCandidate = false; //true;
|
||||||
|
|
||||||
/* Google Talk STUN request does not contains PRIORITY attribute
|
/* Google Talk STUN request does not contains PRIORITY attribute
|
||||||
* set it to the peer reflexive value (0.9 * 1000);
|
* set it to the peer reflexive value (0.9 * 1000);
|
||||||
@ -142,6 +143,15 @@ class ConnectivityCheckServer
|
|||||||
remoteUfrag = username.substring(0, colon);
|
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;
|
//tell our address handler we saw a new remote address;
|
||||||
parentAgent.incomingCheckReceived(evt.getRemoteAddress(),
|
parentAgent.incomingCheckReceived(evt.getRemoteAddress(),
|
||||||
evt.getLocalAddress(), priority, remoteUfrag, localUFrag,
|
evt.getLocalAddress(), priority, remoteUfrag, localUFrag,
|
||||||
|
|||||||
@ -189,54 +189,63 @@ public class DefaultNominator
|
|||||||
* @param evt the {@link PropertyChangeEvent} containing the pair which
|
* @param evt the {@link PropertyChangeEvent} containing the pair which
|
||||||
* has been validated.
|
* has been validated.
|
||||||
*/
|
*/
|
||||||
private synchronized void strategyNominateFirstHostOrReflexiveValid(
|
private void strategyNominateFirstHostOrReflexiveValid(
|
||||||
PropertyChangeEvent evt)
|
PropertyChangeEvent evt)
|
||||||
{
|
{
|
||||||
if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName()))
|
if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName()))
|
||||||
{
|
{
|
||||||
CandidatePair validPair = (CandidatePair)evt.getSource();
|
CandidatePair validPair = (CandidatePair)evt.getSource();
|
||||||
|
|
||||||
TimerTask task = validatedCandidates.get(
|
TimerTask task = null;
|
||||||
validPair.getParentComponent().toShortString());
|
|
||||||
boolean isRelayed =
|
boolean isRelayed =
|
||||||
(validPair.getLocalCandidate() instanceof RelayedCandidate) ||
|
(validPair.getLocalCandidate() instanceof RelayedCandidate) ||
|
||||||
validPair.getLocalCandidate().getType().equals(
|
validPair.getLocalCandidate().getType().equals(
|
||||||
CandidateType.RELAYED_CANDIDATE) ||
|
CandidateType.RELAYED_CANDIDATE) ||
|
||||||
validPair.getRemoteCandidate().getType().equals(
|
validPair.getRemoteCandidate().getType().equals(
|
||||||
CandidateType.RELAYED_CANDIDATE);
|
CandidateType.RELAYED_CANDIDATE);
|
||||||
|
boolean nominate = false;
|
||||||
|
|
||||||
|
synchronized(validatedCandidates)
|
||||||
|
{
|
||||||
|
task = validatedCandidates.get(
|
||||||
|
validPair.getParentComponent().toShortString());
|
||||||
|
|
||||||
if(isRelayed && task == null)
|
if(isRelayed && task == null)
|
||||||
{
|
{
|
||||||
/* armed a timer and see if a host or server reflexive pair
|
/* armed a timer and see if a host or server reflexive pair
|
||||||
* gets nominated. Otherwise nominate the relayed candidate pair
|
* gets nominated. Otherwise nominate the relayed candidate
|
||||||
|
* pair
|
||||||
*/
|
*/
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
task = new RelayedCandidateTask(validPair);
|
task = new RelayedCandidateTask(validPair);
|
||||||
|
|
||||||
logger.info("Wait timeout to nominate relayed candidate");
|
logger.info("Wait timeout to nominate relayed candidate");
|
||||||
timer.schedule(task, 0);
|
timer.schedule(task, 0);
|
||||||
synchronized(validatedCandidates)
|
|
||||||
{
|
|
||||||
validatedCandidates.put(
|
validatedCandidates.put(
|
||||||
validPair.getParentComponent().toShortString(),
|
validPair.getParentComponent().toShortString(),
|
||||||
task);
|
task);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(!isRelayed)
|
else if(!isRelayed)
|
||||||
{
|
{
|
||||||
// host or server reflexive candidate pair
|
// host or server reflexive candidate pair
|
||||||
if(task != null)
|
if(task != null)
|
||||||
{
|
{
|
||||||
task.cancel();
|
task.cancel();
|
||||||
logger.info("Found a better candidate pair to nominate for "
|
logger.info(
|
||||||
+ validPair.getParentComponent().toShortString());
|
"Found a better candidate pair to nominate for "
|
||||||
|
+ validPair.getParentComponent().
|
||||||
|
toShortString());
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Nominate (first highest valid): " +
|
logger.info("Nominate (first highest valid): " +
|
||||||
validPair.toShortString());
|
validPair.toShortString());
|
||||||
parentAgent.nominate(validPair);
|
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
|
* @param newSize the new thread pool size
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user