Explorar o código

Prevent any state change after close in PeerConnection

Paul-Louis Ageneau %!s(int64=3) %!d(string=hai) anos
pai
achega
54f4139023
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  1. 5 4
      src/impl/peerconnection.cpp

+ 5 - 4
src/impl/peerconnection.cpp

@@ -1103,12 +1103,13 @@ bool PeerConnection::changeState(State newState) {
 	s << newState;
 	PLOG_INFO << "Changed state to " << s.str();
 
-	if (newState == State::Closed)
-		stateChangeCallback(State::Closed); // synchronous
-	else
+	if (newState == State::Closed) {
+		auto callback = std::move(stateChangeCallback); // steal the callback
+		callback(State::Closed);                        // call it synchronously
+	} else {
 		mProcessor.enqueue(&PeerConnection::trigger<State>, shared_from_this(), stateChangeCallback,
 		                   newState);
-
+	}
 	return true;
 }