From 7dfb7fa189701a57ad6399ad1472d6edd28b087c Mon Sep 17 00:00:00 2001 From: "jiayl@webrtc.org" Date: Mon, 29 Sep 2014 22:45:55 +0000 Subject: [PATCH] Reland disallowing blocking calls on the worker thread. This fixed the issue that invoking the call when the thread is not started. BUG=3559 R=juberti@webrtc.org, thorcarpenter@google.com Review URL: https://webrtc-codereview.appspot.com/24769004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7325 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/session/media/channelmanager.cc | 6 ++++++ webrtc/base/thread.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/talk/session/media/channelmanager.cc b/talk/session/media/channelmanager.cc index 45e7e4764a..f40396d928 100644 --- a/talk/session/media/channelmanager.cc +++ b/talk/session/media/channelmanager.cc @@ -218,6 +218,12 @@ bool ChannelManager::Init() { ASSERT(worker_thread_ != NULL); if (worker_thread_) { + if (worker_thread_ != rtc::Thread::Current()) { + // Do not allow invoking calls to other threads on the worker thread. + worker_thread_->Invoke(rtc::Bind( + &rtc::Thread::SetAllowBlockingCalls, worker_thread_, false)); + } + if (media_engine_->Init(worker_thread_)) { initialized_ = true; diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h index 34ec45e3b9..8276f4e8ec 100644 --- a/webrtc/base/thread.h +++ b/webrtc/base/thread.h @@ -210,7 +210,7 @@ class Thread : public MessageQueue { bool RunningForTest() { return running(); } // Sets the per-thread allow-blocking-calls flag and returns the previous - // value. + // value. Must be called on this thread. bool SetAllowBlockingCalls(bool allow); protected: