diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:32:37 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:32:37 +0000 |
commit | 2e8a7ef475c0d9cabeda4f676f66da42749e57c2 (patch) | |
tree | 1648e042ef535bd89161bf5ef9d17cbfd4dcd96e | |
parent | d25cc9e19957f6680e46086a91d47bb029e4d40b (diff) | |
download | chromium_src-2e8a7ef475c0d9cabeda4f676f66da42749e57c2.zip chromium_src-2e8a7ef475c0d9cabeda4f676f66da42749e57c2.tar.gz chromium_src-2e8a7ef475c0d9cabeda4f676f66da42749e57c2.tar.bz2 |
Merge 32211 - Fix a race condition in signal thread destructor.
BUG=23251
TEST=none
Review URL: http://codereview.chromium.org/402026
TBR=zork@google.com
Review URL: http://codereview.chromium.org/399092
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@32421 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | third_party/libjingle/files/talk/base/signalthread.cc | 3 | ||||
-rw-r--r-- | third_party/libjingle/files/talk/base/signalthread.h | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/third_party/libjingle/files/talk/base/signalthread.cc b/third_party/libjingle/files/talk/base/signalthread.cc index 919d1c3..0b5154d6 100644 --- a/third_party/libjingle/files/talk/base/signalthread.cc +++ b/third_party/libjingle/files/talk/base/signalthread.cc @@ -10,10 +10,11 @@ using namespace talk_base; SignalThread::SignalThread() : main_(Thread::Current()), state_(kInit) { - worker_.parent_ = this; + worker_.SetParent(this); } SignalThread::~SignalThread() { + worker_.SetParent(NULL); } void SignalThread::SetPriority(ThreadPriority priority) { diff --git a/third_party/libjingle/files/talk/base/signalthread.h b/third_party/libjingle/files/talk/base/signalthread.h index 9e6bd05..ccba912 100644 --- a/third_party/libjingle/files/talk/base/signalthread.h +++ b/third_party/libjingle/files/talk/base/signalthread.h @@ -73,8 +73,19 @@ private: friend class Worker; class Worker : public Thread { public: + virtual void Run() { + CritScope cs(&parent_crit_); + if (parent_) + parent_->Run(); + } + void SetParent(SignalThread* parent) { + CritScope cs(&parent_crit_); + parent_ = parent; + } + + private: SignalThread* parent_; - virtual void Run() { parent_->Run(); } + CriticalSection parent_crit_; }; void Run(); |