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

Unified Diff: base/files/file_descriptor_watcher_posix.cc

Issue 2382443011: Add comment about leaked FileDescriptorWatcher::Controller::Watcher. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_descriptor_watcher_posix.cc
diff --git a/base/files/file_descriptor_watcher_posix.cc b/base/files/file_descriptor_watcher_posix.cc
index dfd6101e53d7e32287e7d42ee79f4179fde6881e..49ac5d43a4a6080fbb18e0d63138c2480232b0dc 100644
--- a/base/files/file_descriptor_watcher_posix.cc
+++ b/base/files/file_descriptor_watcher_posix.cc
@@ -27,7 +27,15 @@ LazyInstance<ThreadLocalPointer<MessageLoopForIO>>::Leaky
FileDescriptorWatcher::Controller::~Controller() {
DCHECK(sequence_checker_.CalledOnValidSequence());
+
+ // Delete |watcher_| on the MessageLoopForIO.
+ //
+ // If the MessageLoopForIO is deleted before Watcher::StartWatching() runs,
+ // |watcher_| is leaked. If the MessageLoopForIO is deleted after
+ // Watcher::StartWatching() runs but before the DeleteSoon task runs,
+ // |watcher_| is deleted from Watcher::WillDestroyCurrentMessageLoop().
message_loop_for_io_task_runner_->DeleteSoon(FROM_HERE, watcher_.release());
+
// Since WeakPtrs are invalidated by the destructor, RunCallback() won't be
// invoked after this returns.
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698