Skip to content

Commit 2083894

Browse files
ywh233WebRTC LUCI CQ
authored andcommitted
Fix bug of messages being delivered before data channel is open
If the caller calls RegisterObserver() on the network thread while the state is not kOpen but there are queued received data, those received data will be immediately delivered to the observer before the state is transitioned to kOpen, which may break the observer's assertions and cause problems. The problem turns out to be that, when SctpDataChannel::RegisterObserver calls DeliverQueuedReceivedData(), the data will be passed to the observer without checking the |state_| first, meanwhile SctpDataChannel::UpdateState does effectively check the state and null-check |observer_| before delivering the received data. This CL fixes this by simply making DeliverQueuedReceivedData() also check `state_ == kOpen`. In case the state transitions to kOpen after RegisterObserver() is called, the first DeliverQueuedReceivedData() call will be no-op, while the second DeliverQueuedReceivedData() call will do the work. Bug: chromium:1442696 Change-Id: If25ce6a038d704939b1a8ae73d7ced110448b050 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304687 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40036}
1 parent 80baee1 commit 2083894

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pc/sctp_data_channel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ void SctpDataChannel::SetState(DataState state) {
848848

849849
// RTC_RUN_ON(network_thread_).
850850
void SctpDataChannel::DeliverQueuedReceivedData() {
851-
if (!observer_) {
851+
if (!observer_ || state_ != kOpen) {
852852
return;
853853
}
854854

0 commit comments

Comments
 (0)