Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: net/base/file_stream_win.cc

Issue 112090: Avoiding IO completion callback during the closing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/test_completion_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/file_stream_win.cc
===================================================================
--- net/base/file_stream_win.cc (revision 16872)
+++ net/base/file_stream_win.cc (working copy)
@@ -50,7 +50,7 @@
class FileStream::AsyncContext : public MessageLoopForIO::IOHandler {
public:
AsyncContext(FileStream* owner)
- : owner_(owner), context_(), callback_(NULL) {
+ : owner_(owner), context_(), callback_(NULL), is_closing_(false) {
context_.handler = this;
}
~AsyncContext();
@@ -67,9 +67,11 @@
FileStream* owner_;
MessageLoopForIO::IOContext context_;
CompletionCallback* callback_;
+ bool is_closing_;
};
FileStream::AsyncContext::~AsyncContext() {
+ is_closing_ = true;
bool waited = false;
base::Time start = base::Time::Now();
while (callback_) {
@@ -93,6 +95,11 @@
DCHECK(&context_ == context);
DCHECK(callback_);
+ if (is_closing_) {
brettw 2009/06/03 23:43:04 Can you add a comment why this is here and what ba
+ callback_ = NULL;
+ return;
+ }
+
int result = static_cast<int>(bytes_read);
if (error && error != ERROR_HANDLE_EOF)
result = MapErrorCode(error);
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/test_completion_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698