fix: Moves the initializedActive update to after

the actual call to initializeActive(). Synchronizes access.
This commit is contained in:
Boris Grozev 2016-12-12 13:53:42 -06:00
parent 6d6f4710e0
commit 7cac0e50a7

View File

@ -23,7 +23,6 @@ import org.ice4j.socket.*;
import java.beans.*; import java.beans.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*;
import org.ice4j.util.*; //Disambiguation import org.ice4j.util.*; //Disambiguation
/** /**
@ -64,6 +63,11 @@ public class ComponentSocket
*/ */
private boolean initializedActive = false; private boolean initializedActive = false;
/**
* Used to synchronize access to {@link #initializedActive}.
*/
private final Object initializedActiveSyncRoot = new Object();
/** /**
* The {@link Logger} used by {@link MergingDatagramSocket} instances. * The {@link Logger} used by {@link MergingDatagramSocket} instances.
*/ */
@ -152,12 +156,13 @@ public class ComponentSocket
} }
} }
else if (IceMediaStream.PROPERTY_PAIR_NOMINATED.equals(propertyName)) else if (IceMediaStream.PROPERTY_PAIR_NOMINATED.equals(propertyName))
{
synchronized (initializedActiveSyncRoot)
{ {
if (initializedActive) if (initializedActive)
{ {
return; return;
} }
initializedActive = true;
// Find the remote address and the correct socket to be used by // Find the remote address and the correct socket to be used by
// the pair. // the pair.
@ -177,9 +182,12 @@ public class ComponentSocket
// Make sure we get the one for the remote address that we are // Make sure we get the one for the remote address that we are
// going to use. // going to use.
IceSocketWrapper socketWrapper IceSocketWrapper socketWrapper
= localCandidate.getCandidateIceSocketWrapper(remoteAddress); = localCandidate
.getCandidateIceSocketWrapper(remoteAddress);
initializeActive(socketWrapper, remoteAddress); initializeActive(socketWrapper, remoteAddress);
initializedActive = true;
}
} }
} }