diff --git a/dom/plugins/ipc/PluginHangUIParent.cpp b/dom/plugins/ipc/PluginHangUIParent.cpp index 94166506046..0277d93e8ba 100644 --- a/dom/plugins/ipc/PluginHangUIParent.cpp +++ b/dom/plugins/ipc/PluginHangUIParent.cpp @@ -68,12 +68,12 @@ private: namespace mozilla { namespace plugins { -const DWORD PluginHangUIParent::kTimeout = 30000U; - PluginHangUIParent::PluginHangUIParent(PluginModuleParent* aModule, - const int32_t aHangUITimeoutPref) + const int32_t aHangUITimeoutPref, + const int32_t aChildTimeoutPref) : mModule(aModule), mTimeoutPrefMs(static_cast(aHangUITimeoutPref) * 1000U), + mIPCTimeoutMs(static_cast(aChildTimeoutPref) * 1000U), mMainThreadMessageLoop(MessageLoop::current()), mIsShowing(false), mLastUserResponse(0), @@ -129,7 +129,7 @@ PluginHangUIParent::Init(const nsString& aPluginName) } nsresult rv; - rv = mMiniShm.Init(this, ::IsDebuggerPresent() ? INFINITE : kTimeout); + rv = mMiniShm.Init(this, ::IsDebuggerPresent() ? INFINITE : mIPCTimeoutMs); NS_ENSURE_SUCCESS(rv, false); nsCOMPtr directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID)); @@ -210,6 +210,10 @@ PluginHangUIParent::Init(const nsString& aPluginName) commandLine.AppendLooseValue(L"-"); } + nsAutoString ipcTimeoutStr; + ipcTimeoutStr.AppendInt(mIPCTimeoutMs); + commandLine.AppendLooseValue(ipcTimeoutStr.get()); + std::wstring ipcCookie; rv = mMiniShm.GetCookie(ipcCookie); if (NS_FAILED(rv)) { @@ -245,7 +249,7 @@ PluginHangUIParent::Init(const nsString& aPluginName) INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE); ::WaitForSingleObject(mShowEvent, ::IsDebuggerPresent() ? INFINITE - : kTimeout); + : mIPCTimeoutMs); // Setting this to true even if we time out on mShowEvent. This timeout // typically occurs when the machine is thrashing so badly that // plugin-hang-ui.exe is taking a while to start. If we didn't set @@ -269,7 +273,6 @@ VOID CALLBACK PluginHangUIParent::SOnHangUIProcessExit(PVOID aContext, // If plugin-hang-ui.exe was unexpectedly terminated, we need to re-enable. ::EnableWindow(object->mMainWindowHandle, TRUE); } - object->mMiniShm.CleanUp(); } bool diff --git a/dom/plugins/ipc/PluginHangUIParent.h b/dom/plugins/ipc/PluginHangUIParent.h index 935dab1dfc4..2069ef52a38 100644 --- a/dom/plugins/ipc/PluginHangUIParent.h +++ b/dom/plugins/ipc/PluginHangUIParent.h @@ -35,7 +35,8 @@ class PluginHangUIParent : public MiniShmObserver { public: PluginHangUIParent(PluginModuleParent* aModule, - const int32_t aHangUITimeoutPref); + const int32_t aHangUITimeoutPref, + const int32_t aChildTimeoutPref); virtual ~PluginHangUIParent(); /** @@ -131,6 +132,7 @@ private: private: PluginModuleParent* mModule; const uint32_t mTimeoutPrefMs; + const uint32_t mIPCTimeoutMs; MessageLoop* mMainThreadMessageLoop; volatile bool mIsShowing; unsigned int mLastUserResponse; @@ -142,8 +144,6 @@ private: DWORD mResponseTicks; MiniShmParent mMiniShm; - static const DWORD kTimeout; - DISALLOW_COPY_AND_ASSIGN(PluginHangUIParent); }; diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index d87eb8b3ca7..732558693a0 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -566,7 +566,8 @@ PluginModuleParent::LaunchHangUI() mHangUIParent = nullptr; } mHangUIParent = new PluginHangUIParent(this, - Preferences::GetInt(kHangUITimeoutPref, 0)); + Preferences::GetInt(kHangUITimeoutPref, 0), + Preferences::GetInt(kChildTimeoutPref, 0)); nsAutoString pluginName; if (!GetPluginName(pluginName)) { return false; diff --git a/dom/plugins/ipc/hangui/PluginHangUIChild.cpp b/dom/plugins/ipc/hangui/PluginHangUIChild.cpp index 98128bb3ffe..eee2ffd7550 100644 --- a/dom/plugins/ipc/hangui/PluginHangUIChild.cpp +++ b/dom/plugins/ipc/hangui/PluginHangUIChild.cpp @@ -37,8 +37,6 @@ typedef std::vector WinInfoVec; PluginHangUIChild* PluginHangUIChild::sSelf = nullptr; const int PluginHangUIChild::kExpectedMinimumArgc = 10; -const DWORD PluginHangUIChild::kProcessTimeout = 1200000U; -const DWORD PluginHangUIChild::kShmTimeout = 5000U; PluginHangUIChild::PluginHangUIChild() : mResponseBits(0), @@ -46,7 +44,8 @@ PluginHangUIChild::PluginHangUIChild() mDlgHandle(NULL), mMainThread(NULL), mParentProcess(NULL), - mRegWaitProcess(NULL) + mRegWaitProcess(NULL), + mIPCTimeoutMs(0) { } @@ -98,10 +97,15 @@ PluginHangUIChild::Init(int aArgc, wchar_t* aArgv[]) FreeLibrary(shell32); } } + std::wistringstream issTimeout(aArgv[++i]); + issTimeout >> mIPCTimeoutMs; + if (!issTimeout) { + return false; + } nsresult rv = mMiniShm.Init(this, std::wstring(aArgv[++i]), - IsDebuggerPresent() ? INFINITE : kShmTimeout); + IsDebuggerPresent() ? INFINITE : mIPCTimeoutMs); if (NS_FAILED(rv)) { return false; } @@ -374,7 +378,7 @@ PluginHangUIChild::WaitForDismissal() return false; } DWORD waitResult = WaitForSingleObjectEx(mParentProcess, - kProcessTimeout, + mIPCTimeoutMs, TRUE); return waitResult == WAIT_OBJECT_0 || waitResult == WAIT_IO_COMPLETION; diff --git a/dom/plugins/ipc/hangui/PluginHangUIChild.h b/dom/plugins/ipc/hangui/PluginHangUIChild.h index aaee2e82f82..50d546f2638 100644 --- a/dom/plugins/ipc/hangui/PluginHangUIChild.h +++ b/dom/plugins/ipc/hangui/PluginHangUIChild.h @@ -96,11 +96,10 @@ private: HANDLE mMainThread; HANDLE mParentProcess; HANDLE mRegWaitProcess; + DWORD mIPCTimeoutMs; MiniShmChild mMiniShm; static const int kExpectedMinimumArgc; - static const DWORD kProcessTimeout; - static const DWORD kShmTimeout; typedef HRESULT (WINAPI *SETAPPUSERMODELID)(PCWSTR);