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; 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. * The thread that we use for STUN keep-alive.
*/ */
@ -1928,6 +1933,8 @@ public class Agent
* Initializes and starts the {@link TerminationThread} * Initializes and starts the {@link TerminationThread}
*/ */
private void scheduleTermination() private void scheduleTermination()
{
synchronized (terminationThreadSyncRoot)
{ {
if (terminationThread == null) if (terminationThread == null)
{ {
@ -1935,6 +1942,7 @@ public class Agent
terminationThread.start(); terminationThread.start();
} }
} }
}
/** /**
* Initializes and starts the background <tt>Thread</tt> which is to send * Initializes and starts the background <tt>Thread</tt> which is to send
@ -2012,9 +2020,12 @@ public class Agent
logger.info("ICE state is TERMINATED"); logger.info("ICE state is TERMINATED");
terminate(IceProcessingState.TERMINATED); terminate(IceProcessingState.TERMINATED);
synchronized (terminationThreadSyncRoot)
{
terminationThread = null; terminationThread = null;
} }
} }
}
/** /**
* Terminates this <tt>Agent</tt> by stopping the handling of connectivity * Terminates this <tt>Agent</tt> by stopping the handling of connectivity