diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 21:54:43 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-21 21:54:43 +0000 |
commit | 98999e804310fe2ebe1d56723a0300cc300d05ee (patch) | |
tree | 041f686d45e97949b9560940e757c3e1c752a933 /chrome/browser/nacl_host | |
parent | 235eeb35d967378f86d801bb840fa3139425a160 (diff) | |
download | chromium_src-98999e804310fe2ebe1d56723a0300cc300d05ee.zip chromium_src-98999e804310fe2ebe1d56723a0300cc300d05ee.tar.gz chromium_src-98999e804310fe2ebe1d56723a0300cc300d05ee.tar.bz2 |
Always send a reply to nacl launch requests.
Previously there were many return paths where the reply message would not get sent, which would indefinitely hang the renderer. I also found a leak where if the FILE thread is gone when we try to make the IRT available, the object will be leaked (the the reply message would not be sent either). I tried to find all of the failure cases and ensure the reply message is sent.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8994010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 10 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.h | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index eadffc1..db5b3b0 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -225,9 +225,11 @@ bool NaClProcessHost::Launch( if (!LaunchSelLdr()) { return false; } + chrome_render_message_filter_ = chrome_render_message_filter; - reply_msg_ = reply_msg; + // On success, we take responsibility for sending the reply. + reply_msg_ = reply_msg; return true; } @@ -384,8 +386,10 @@ void NaClProcessHost::OnProcessLaunched() { SendStart(nacl_browser->IrtFile()); } else { // We're waiting for the IRT to be open. - nacl_browser->MakeIrtAvailable(base::Bind(&NaClProcessHost::IrtReady, - weak_factory_.GetWeakPtr())); + if (!nacl_browser->MakeIrtAvailable( + base::Bind(&NaClProcessHost::IrtReady, + weak_factory_.GetWeakPtr()))) + delete this; } } diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h index 265e34f..1943c13 100644 --- a/chrome/browser/nacl_host/nacl_process_host.h +++ b/chrome/browser/nacl_host/nacl_process_host.h @@ -31,7 +31,10 @@ class NaClProcessHost : public BrowserChildProcessHost { // Do any minimal work that must be done at browser startup. static void EarlyStartup(); - // Initialize the new NaCl process, returning true on success. + // Initialize the new NaCl process, returning true on success. On success, + // the NaCl process host will assume responsibility for sending the reply + // message. On failure, the reply will not be sent and this is the caller's + // responsibility to avoid hanging the renderer. bool Launch(ChromeRenderMessageFilter* chrome_render_message_filter, int socket_count, IPC::Message* reply_msg); @@ -62,7 +65,9 @@ class NaClProcessHost : public BrowserChildProcessHost { // this for sending the reply once the process has started. scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter_; - // The reply message to send. + // The reply message to send. We must always send this message when the + // sub-process either succeeds or fails to unblock the renderer waiting for + // the reply. NULL when there is no reply to send. IPC::Message* reply_msg_; // Socket pairs for the NaCl process and renderer. |