diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 15:25:28 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 15:25:28 +0000 |
commit | 36330d1074e6428e4bede815a52bb280d58787c2 (patch) | |
tree | 195e31c4bf5456e692db91edb7819151e2b83184 /media/audio/audio_input_controller.cc | |
parent | 57e17cd42c77255be13e2b8804a526413d1d12d8 (diff) | |
download | chromium_src-36330d1074e6428e4bede815a52bb280d58787c2.zip chromium_src-36330d1074e6428e4bede815a52bb280d58787c2.tar.gz chromium_src-36330d1074e6428e4bede815a52bb280d58787c2.tar.bz2 |
Fix race in AudioInputController::Close().
Before this change, a reference to AudioInputController was bound into the
Callback invoking DoClose(), which executes on the audio thread. If the
audio thread is slow to delete that callback (after dispatching |closed_task|)
then the main thread's reference to the AudioInputController might be released
first, leading to AudioInputController being destructed on the audio thread,
triggering a DCHECK in Timer::~Timer() (owned by the AudioInputController via
DelayTimer).
This race was exposed while working on http://codereview.chromium.org/9717021/
but isn't so much related to the content of that CL as to the fact that that CL
twiddles callback lifetime/timing a bit.
Review URL: http://codereview.chromium.org/9839051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_input_controller.cc')
-rw-r--r-- | media/audio/audio_input_controller.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc index 27903fa..67623da 100644 --- a/media/audio/audio_input_controller.cc +++ b/media/audio/audio_input_controller.cc @@ -103,8 +103,8 @@ void AudioInputController::Record() { void AudioInputController::Close(const base::Closure& closed_task) { DCHECK(!closed_task.is_null()); - message_loop_->PostTask(FROM_HERE, base::Bind( - &AudioInputController::DoClose, this, closed_task)); + message_loop_->PostTaskAndReply( + FROM_HERE, base::Bind(&AudioInputController::DoClose, this), closed_task); } void AudioInputController::DoCreate(AudioManager* audio_manager, @@ -150,7 +150,7 @@ void AudioInputController::DoRecord() { handler_->OnRecording(this); } -void AudioInputController::DoClose(const base::Closure& closed_task) { +void AudioInputController::DoClose() { DCHECK(message_loop_->BelongsToCurrentThread()); if (state_ != kClosed) { @@ -162,8 +162,6 @@ void AudioInputController::DoClose(const base::Closure& closed_task) { state_ = kClosed; } - - closed_task.Run(); } void AudioInputController::DoReportError(int code) { |