Enforce thread invoke policy for invokes to itself

Bug: None
Change-Id: Ic4a80973bd0901f69c66ecabd3c135566f4ef247
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219629
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34119}
This commit is contained in:
Artem Titov 2021-05-25 11:17:07 +02:00 committed by WebRTC LUCI CQ
parent 4fbc3fc59e
commit 157371643d
2 changed files with 5 additions and 2 deletions

View File

@ -103,11 +103,13 @@ ConnectionContext::ConnectionContext(
signaling_thread_->AllowInvokesToThread(network_thread_);
worker_thread_->AllowInvokesToThread(network_thread_);
if (network_thread_->IsCurrent()) {
network_thread_->DisallowAllInvokes();
// TODO(https://crbug.com/webrtc/12802) switch to DisallowAllInvokes
network_thread_->AllowInvokesToThread(network_thread_);
} else {
network_thread_->PostTask(ToQueuedTask([thread = network_thread_] {
thread->DisallowBlockingCalls();
thread->DisallowAllInvokes();
// TODO(https://crbug.com/webrtc/12802) switch to DisallowAllInvokes
thread->AllowInvokesToThread(thread);
}));
}

View File

@ -929,6 +929,7 @@ void Thread::Send(const Location& posted_from,
msg.pdata = pdata;
if (IsCurrent()) {
#if RTC_DCHECK_IS_ON
RTC_DCHECK(this->IsInvokeToThreadAllowed(this));
RTC_DCHECK_RUN_ON(this);
could_be_blocking_call_count_++;
#endif