From 70cea9bda8b8815be3c5bae4b6fa8053713efcac Mon Sep 17 00:00:00 2001 From: Tommi Date: Fri, 25 Aug 2023 01:12:04 +0200 Subject: [PATCH] [SctpDataChannel] Don't use PostTask for observer registration. Instead, use BlockingCall to match with how unregistration is done. This is needed because the ThreadWrapper implementation in Chromium, overriding the Thread implementation in WebRTC, does not order sent (blocking) tasks along with posted tasks. That makes the functional difference that Thread1 posting and sending tasks to Thread2, can not assume that the tasks run in the order they were posted and sent. I.e. in this case: // Running on Thread1. thread2->PostTask([](){ Foo(); }); thread2->BlockingCall([](){ Bar(); }); Thread2 may actually execute Bar() first, and then Foo(). Bug: chromium:1470992 Change-Id: I1f83f12ce39c09279c0f2b3bc71c3a33e2cb16c5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/317700 Commit-Queue: Tomas Gunnarsson Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#40624} --- pc/sctp_data_channel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc index a17008fb3f..8fdbf4cb92 100644 --- a/pc/sctp_data_channel.cc +++ b/pc/sctp_data_channel.cc @@ -396,7 +396,7 @@ void SctpDataChannel::RegisterObserver(DataChannelObserver* observer) { if (network_thread_ == current_thread) { register_observer(); } else { - network_thread_->PostTask(std::move(register_observer)); + network_thread_->BlockingCall(std::move(register_observer)); } }