Synchronizes access to an Agent's termination thread

because of an observed race condition leading to calling
start() twice.

14:29:26.756 INFO: [28] org.ice4j.ice.ConnectivityCheckClient.processSuccessResponse() Nomination confirmed for pair: 192.168.1.116:7777/udp/host -> 192.168.1.116:62365/udp/prflx (stream.RTP)
14:29:26.757 INFO: [28] org.ice4j.ice.CheckList.handleNominationConfirmed() Selected pair for stream stream.RTP: 192.168.1.116:7777/udp/host -> 192.168.1.116:62365/udp/prflx (stream.RTP)
14:29:26.758 INFO: [29] org.ice4j.ice.Agent.checkListStatesUpdated() CheckList of stream stream is COMPLETED 14:29:26.758 INFO: [28] org.ice4j.ice.Agent.checkListStatesUpdated() CheckList of stream stream is COMPLETED
14:29:26.758 INFO: [29] org.ice4j.ice.Agent.checkListStatesUpdated() ICE state is COMPLETED
14:29:26.758 INFO: [28] org.ice4j.ice.Agent.checkListStatesUpdated() ICE state is COMPLETED
14:29:26.758 INFO: [29] org.jitsi.videobridge.IceUdpTransportManager.info() ICE processing state of IceUdpTransportManager #2dcab970 (for channels ca079f8cc6778b96 38480814176d5f95 727e3ef175b4a77c)  of con ference bd46bc5c213945f7 changed from Running to Completed.
14:29:26.759 INFO: [28] org.jitsi.videobridge.IceUdpTransportManager.info() ICE processing state of IceUdpTransportManager #2dcab970 (for channels ca079f8cc6778b96 38480814176d5f95 727e3ef175b4a77c)  of con ference bd46bc5c213945f7 changed from Completed to Completed.
14:29:26.766 INFO: [29] org.ice4j.ice.Agent.logCandTypes() Harvester used for selected pair for stream.RTP: host
14:29:26.769 WARNING: [28] org.ice4j.stack.NetAccessManager.handleFatalError() A message processor has unexpectedly stopped. AP:org.ice4j.stack.MessageProcessor@de4a162
java.lang.IllegalThreadStateException
    at java.lang.Thread.start(Thread.java:705)
    at org.ice4j.ice.Agent.scheduleTermination(Agent.java:1930)
    at org.ice4j.ice.Agent.checkListStatesUpdated(Agent.java:1726)
    at org.ice4j.ice.ConnectivityCheckClient.updateCheckListAndTimerStates(ConnectivityCheckClient.java:437)
    at org.ice4j.ice.ConnectivityCheckClient.processResponse(ConnectivityCheckClient.java:360)
    at org.ice4j.stack.StunClientTransaction.handleResponse(StunClientTransaction.java:492)
    at org.ice4j.stack.StunStack.handleMessageEvent(StunStack.java:1028)
    at org.ice4j.stack.MessageProcessor.run(MessageProcessor.java:159)
    at java.lang.Thread.run(Thread.java:745)
This commit is contained in:
boris 2015-03-09 18:24:42 +00:00
parent 818cd10a2f
commit f9ee7aedba

View File

@ -225,6 +225,11 @@ public class Agent
*/
private TerminationThread terminationThread;
/**
* The object used to synchronize access to {@link #terminationThread}.
*/
private final Object terminationThreadSyncRoot = new Object();
/**
* The thread that we use for STUN keep-alive.
*/
@ -1929,10 +1934,13 @@ public class Agent
*/
private void scheduleTermination()
{
if (terminationThread == null)
synchronized (terminationThreadSyncRoot)
{
terminationThread = new TerminationThread();
terminationThread.start();
if (terminationThread == null)
{
terminationThread = new TerminationThread();
terminationThread.start();
}
}
}
@ -2012,7 +2020,10 @@ public class Agent
logger.info("ICE state is TERMINATED");
terminate(IceProcessingState.TERMINATED);
terminationThread = null;
synchronized (terminationThreadSyncRoot)
{
terminationThread = null;
}
}
}