Bug 1138520 - Don't wait for ForceKill to finish (r=jchen)

This commit is contained in:
Bill McCloskey 2015-04-17 10:59:56 -07:00
parent 88db66add8
commit 79c50d42c4

View File

@ -1883,11 +1883,6 @@ struct DelayedDeleteContentParentTask : public nsRunnable
void
ContentParent::ActorDestroy(ActorDestroyReason why)
{
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ChildShutdownState"),
NS_LITERAL_CSTRING("ActorDestroy"));
#endif
if (mForceKillTimer) {
mForceKillTimer->Cancel();
mForceKillTimer = nullptr;
@ -2049,12 +2044,6 @@ ContentParent::NotifyTabDestroying(PBrowserParent* aTab)
StartForceKillTimer();
}
static int32_t
ForceKillTimeout()
{
return Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
}
void
ContentParent::StartForceKillTimer()
{
@ -2062,7 +2051,7 @@ ContentParent::StartForceKillTimer()
return;
}
int32_t timeoutSecs = ForceKillTimeout();
int32_t timeoutSecs = Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
if (timeoutSecs > 0) {
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
MOZ_ASSERT(mForceKillTimer);
@ -2933,27 +2922,13 @@ ContentParent::Observe(nsISupports* aSubject,
{
if (mSubprocess && (!strcmp(aTopic, "profile-before-change") ||
!strcmp(aTopic, "xpcom-shutdown"))) {
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ChildShutdownState"),
NS_LITERAL_CSTRING("Begin"));
#endif
// Okay to call ShutDownProcess multiple times.
ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
int32_t timeout = ForceKillTimeout();
// Make sure we have a KillHard timer before we start waiting.
MOZ_RELEASE_ASSERT(!timeout || !mIPCOpen || mCalledKillHard || mForceKillTimer);
// Wait for shutdown to complete, so that we receive any shutdown
// data (e.g. telemetry) from the child before we quit.
// This loop terminate prematurely based on mForceKillTimer.
while (mIPCOpen) {
// If we clear the KillHard timer, it should only be because we
// called KillHard. In that case, ActorDestroy should happen
// momentarily.
MOZ_RELEASE_ASSERT(!timeout || mCalledKillHard || mForceKillTimer);
while (mIPCOpen && !mCalledKillHard) {
NS_ProcessNextEvent(nullptr, true);
}
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
@ -3400,11 +3375,6 @@ ContentParent::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
void
ContentParent::KillHard(const char* aReason)
{
#ifdef MOZ_CRASHREPORTER
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ChildShutdownState"),
NS_LITERAL_CSTRING("KillHard"));
#endif
// On Windows, calling KillHard multiple times causes problems - the
// process handle becomes invalid on the first call, causing a second call
// to crash our process - more details in bug 890840.