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

Unified Diff: mojo/message_pump/handle_watcher.cc

Issue 1508053003: Show the callstack that a nontransferable message pipe was first used if it's erroneously sent later (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove frame fix 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 | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/runner/android/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/message_pump/handle_watcher.cc
diff --git a/mojo/message_pump/handle_watcher.cc b/mojo/message_pump/handle_watcher.cc
index 0071058f08a690252ea08b4acb7a43cee4a3a078..dc3b9b9f37a8990600e0540acf941dfb9ca01eb8 100644
--- a/mojo/message_pump/handle_watcher.cc
+++ b/mojo/message_pump/handle_watcher.cc
@@ -23,6 +23,7 @@
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/message_pump/message_pump_mojo_handler.h"
#include "mojo/message_pump/time_helper.h"
+#include "mojo/public/c/system/message_pipe.h"
namespace mojo {
namespace common {
@@ -457,6 +458,17 @@ void HandleWatcher::Start(const Handle& handle,
state_.reset(new SameThreadWatchingState(
this, handle, handle_signals, deadline, callback));
} else {
+#if !defined(OFFICIAL_BUILD)
+ // Just for making debugging non-transferable message pipes easier. Since
+ // they can't be sent after they're read/written/listened to,
+ // MessagePipeDispatcher saves the callstack of when it's "bound" to a
+ // pipe id. Triggering a read here, instead of later in the PostTask, means
+ // we have a callstack that is useful to check if the pipe is erronously
+ // attempted to be sent.
+ uint32_t temp = 0;
+ MojoReadMessage(handle.value(), nullptr, &temp, nullptr, nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE);
+#endif
state_.reset(new SecondaryThreadWatchingState(
this, handle, handle_signals, deadline, callback));
}
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/runner/android/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698