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

Unified Diff: mojo/edk/system/message_pipe_dispatcher.cc

Issue 1534013003: Fix memory leak in unittests with new Mojo EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert change to enable new edk Created 5 years 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: mojo/edk/system/message_pipe_dispatcher.cc
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc
index 75f7227c9296e86531653c48bda07fc8ffd15453..b5bf7323282aeadafc3111a3461d034c6e142193 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -435,9 +435,14 @@ void MessagePipeDispatcher::CancelAllAwakablesNoLock() {
}
void MessagePipeDispatcher::CloseImplNoLock() {
- lock().AssertAcquired();
+ lock().AssertAcquired();
+ // This early circuit fixes leak in unit tests. There's nothing to do in the
+ // posted task.
+ if (!transferable_ && non_transferable_state_ == CLOSED)
+ return;
+
// We take a manual refcount because at shutdown, the task below might not get
- // a chance to execute. If that happens, the RawChannel's will still call our
+ // a chance to execute. If that happens, the RawChannel will still call our
// OnError method because it always runs (since it watches thread
// destruction). So to avoid UAF, manually add a reference and only release it
// if the task runs.
« 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