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

Unified Diff: ppapi/proxy/host_dispatcher.cc

Issue 6625045: Prevent Pepper plugin reentrncy for synchronous messages. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/ppb_instance_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/host_dispatcher.cc
===================================================================
--- ppapi/proxy/host_dispatcher.cc (revision 77850)
+++ ppapi/proxy/host_dispatcher.cc (working copy)
@@ -41,6 +41,20 @@
return BoolToPPBool(usable);
}
+// Saves the state of the given bool and puts it back when it goes out of
+// scope.
+class BoolRestorer {
+ public:
+ BoolRestorer(bool* var) : var_(var), old_value_(*var) {
+ }
+ ~BoolRestorer() {
+ *var_ = old_value_;
+ }
+ private:
+ bool* var_;
+ bool old_value_;
+};
+
} // namespace
HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle,
@@ -105,7 +119,27 @@
return false;
}
+bool HostDispatcher::Send(IPC::Message* msg) {
+ // Normal sync messages are set to unblock, which would normally cause the
+ // plugin to be reentered to process them. We only want to do this when we
+ // know the plugin is in a state to accept reentrancy. Since the plugin side
+ // never clears this flag on messages it sends, we can't get deadlock, but we
+ // may still get reentrancy in the host as a result.
+ if (!allow_plugin_reentrancy_)
+ msg->set_unblock(false);
+ return Dispatcher::Send(msg);
+}
+
bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ // We only want to allow reentrancy when the most recent message from the
+ // plugin was a scripting message. We save the old state of the flag on the
+ // stack in case we're (we are the host) being reentered ourselves. The flag
+ // is set to false here for all messages, and then the scripting API will
+ // explicitly set it to true during processing of those messages that can be
+ // reentered.
+ BoolRestorer restorer(&allow_plugin_reentrancy_);
+ allow_plugin_reentrancy_ = false;
+
// Handle common control messages.
if (Dispatcher::OnMessageReceived(msg))
return true;
« no previous file with comments | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/ppb_instance_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698