diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 00:30:09 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 00:30:09 +0000 |
commit | 5da693de7189643761323c209bd8a0491c594fd3 (patch) | |
tree | 2c33105457e9c64802d1418d6b7eb7feade5d845 | |
parent | 0cffe5f51763cb050e689831fe1658bd23769869 (diff) | |
download | chromium_src-5da693de7189643761323c209bd8a0491c594fd3.zip chromium_src-5da693de7189643761323c209bd8a0491c594fd3.tar.gz chromium_src-5da693de7189643761323c209bd8a0491c594fd3.tar.bz2 |
Remove theoretical race condition between Stop() and Initialize().
Initialize() could acquire lock_ and launch a new thread_ while Stop() had
un-lock_'d and was joining the old thread. If that happened then Stop() would
silently leak the new thread when it re-acquired lock_ and set thread_ to NULL.
This also removes a cheap but unnecessary lock/unlock pair and clarifies the
function a bit.
Tested: built & ran media_unittests.
Patch by fischman@chromium.org:
http://codereview.chromium.org/6531012/
TEST=none
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75212 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/filters/video_renderer_base.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc index 857b9f8..9ed236b 100644 --- a/media/filters/video_renderer_base.cc +++ b/media/filters/video_renderer_base.cc @@ -106,6 +106,7 @@ void VideoRendererBase::Flush(FilterCallback* callback) { void VideoRendererBase::Stop(FilterCallback* callback) { DCHECK_EQ(pending_reads_, 0); + base::PlatformThreadHandle old_thread_handle = base::kNullThreadHandle; { base::AutoLock auto_lock(lock_); state_ = kStopped; @@ -115,14 +116,13 @@ void VideoRendererBase::Stop(FilterCallback* callback) { // Signal the thread since it's possible to get stopped with the video // thread waiting for a read to complete. frame_available_.Signal(); - { - base::AutoUnlock auto_unlock(lock_); - base::PlatformThread::Join(thread_); - } + old_thread_handle = thread_; thread_ = base::kNullThreadHandle; } - } + if (old_thread_handle) + base::PlatformThread::Join(old_thread_handle); + // Signal the subclass we're stopping. OnStop(callback); } |