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

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

Issue 1554443003: Stop linking in the old Mojo EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 4 years, 11 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
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 a4bbaafc8642351073e625c3424268e2fac27218..2227e1b46f63d4c1971b3ac129ca27a937fa762a 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -469,9 +469,16 @@ void MessagePipeDispatcher::CloseImplNoLock() {
// 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.
- AddRef();
- internal::g_io_thread_task_runner->PostTask(
- FROM_HERE, base::Bind(&MessagePipeDispatcher::CloseOnIOAndRelease, this));
+ AddRef();
+ if (!internal::g_io_thread_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&MessagePipeDispatcher::CloseOnIOAndRelease, this))) {
+ // Avoid a shutdown leak in unittests. If the thread is shutting down,
+ // we can't connect to the other end to let it know that we're closed either
+ // way.
+ if (!transferable_ && non_transferable_state_ == WAITING_FOR_READ_OR_WRITE)
+ Release();
+ }
}
void MessagePipeDispatcher::SerializeInternal() {

Powered by Google App Engine
This is Rietveld 408576698