瀏覽代碼

Prevent any state change after close in PeerConnection (Fix #600)

Paul-Louis Ageneau 3 年之前
父節點
當前提交
8712a64d69
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      src/impl/peerconnection.cpp

+ 5 - 4
src/impl/peerconnection.cpp

@@ -1126,12 +1126,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;
 }