From 157371643d4ce27edc61ebfde4f79c5abca563c1 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 25 May 2021 11:17:07 +0200 Subject: [PATCH] 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 Reviewed-by: Tommi Cr-Commit-Position: refs/heads/master@{#34119} --- pc/connection_context.cc | 6 ++++-- rtc_base/thread.cc | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pc/connection_context.cc b/pc/connection_context.cc index 8d6ee636f3..1bb7908f5c 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -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); })); } diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 2a5d5eccdd..8ca9ce76a8 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -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