[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 <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40624}
This commit is contained in:
Tommi 2023-08-25 01:12:04 +02:00 committed by WebRTC LUCI CQ
parent 0720e9ac1d
commit 70cea9bda8

View File

@ -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));
}
}