diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 23:05:59 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 23:05:59 +0000 |
commit | 3828a755146e0102b934281129fdd6425ca19a0f (patch) | |
tree | 636c50ef9cff86b68defe0e19acad8e5ebc33aa7 /net/base/file_stream_posix.cc | |
parent | 41291b0e3555aa77d3501c02a75679b1d734d4ee (diff) | |
download | chromium_src-3828a755146e0102b934281129fdd6425ca19a0f.zip chromium_src-3828a755146e0102b934281129fdd6425ca19a0f.tar.gz chromium_src-3828a755146e0102b934281129fdd6425ca19a0f.tar.bz2 |
Avoiding IO completion callback during the closing
of FileStream.
BUG=8942
Review URL: http://codereview.chromium.org/112090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/file_stream_posix.cc')
-rw-r--r-- | net/base/file_stream_posix.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index 7bc685c..fbfeb04 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -201,6 +201,8 @@ class FileStream::AsyncContext { int result_; CancelableCallbackTask* message_loop_task_; + bool is_closing_; + DISALLOW_COPY_AND_ASSIGN(AsyncContext); }; @@ -210,9 +212,11 @@ FileStream::AsyncContext::AsyncContext() background_io_completed_callback_( this, &AsyncContext::OnBackgroundIOCompleted), background_io_completed_(true, false), - message_loop_task_(NULL) {} + message_loop_task_(NULL), + is_closing_(false) {} FileStream::AsyncContext::~AsyncContext() { + is_closing_ = true; if (callback_) { // If |callback_| is non-NULL, that implies either the worker thread is // still running the IO task, or the completion callback is queued up on the @@ -272,6 +276,11 @@ void FileStream::AsyncContext::RunAsynchronousCallback() { message_loop_task_->Cancel(); message_loop_task_ = NULL; + if (is_closing_) { + callback_ = NULL; + return; + } + DCHECK(callback_); CompletionCallback* temp = NULL; std::swap(temp, callback_); |