Bug 1263499 - unify the QuickExit function, r=bsmedberg

MozReview-Commit-ID: DGJbyXULHPe

--HG--
extra : rebase_source : 26ad1fdc609060a578a27f3d44168160ec026c09
This commit is contained in:
Peter Chang 2016-04-11 16:12:33 +08:00
parent 60dcde7875
commit b9897cc163
7 changed files with 35 additions and 36 deletions

View File

@ -42,6 +42,7 @@
#include "mozilla/ipc/FileDescriptorSetChild.h"
#include "mozilla/ipc/FileDescriptorUtils.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/ipc/TestShellChild.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layers/APZChild.h"
@ -2229,14 +2230,14 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
{
if (AbnormalShutdown == why) {
NS_WARNING("shutting down early because of crash!");
QuickExit();
ProcessChild::QuickExit();
}
#ifndef NS_FREE_PERMANENT_DATA
// In release builds, there's no point in the content process
// going through the full XPCOM shutdown path, because it doesn't
// keep persistent state.
QuickExit();
ProcessChild::QuickExit();
#else
if (sFirstIdleTask) {
sFirstIdleTask->Cancel();
@ -2257,7 +2258,7 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
if (IsNuwaProcess()) {
// The Nuwa cannot go through the full XPCOM shutdown path or deadlock
// will result.
QuickExit();
ProcessChild::QuickExit();
}
#endif
@ -2298,21 +2299,6 @@ ContentChild::ProcessingError(Result aCode, const char* aReason)
NS_RUNTIMEABORT("Content child abort due to IPC error");
}
void
ContentChild::QuickExit()
{
NS_WARNING("content process _exit()ing");
#ifdef XP_WIN
// In bug 1254829, the destructor got called when dll got detached on windows,
// switch to TerminateProcess to bypass dll detach handler during the process
// termination.
TerminateProcess(GetCurrentProcess(), 0);
#else
_exit(0);
#endif
}
nsresult
ContentChild::AddRemoteAlertObserver(const nsString& aData,
nsIObserver* aObserver)

View File

@ -615,12 +615,6 @@ private:
virtual void ProcessingError(Result aCode, const char* aReason) override;
/**
* Exit *now*. Do not shut down XPCOM, do not pass Go, do not run
* static destructors, do not collect $200.
*/
MOZ_NORETURN void QuickExit();
InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
RefPtr<ConsoleListener> mConsoleListener;

View File

@ -19,12 +19,14 @@
#include "gmp-video-encode.h"
#include "GMPPlatform.h"
#include "mozilla/dom/CrashReporterChild.h"
#include "mozilla/ipc/ProcessChild.h"
#include "GMPUtils.h"
#include "prio.h"
#ifdef MOZ_WIDEVINE_EME
#include "widevine-adapter/WidevineAdapter.h"
#endif
using namespace mozilla::ipc;
using mozilla::dom::CrashReporterChild;
static const int MAX_VOUCHER_LENGTH = 500000;
@ -430,7 +432,7 @@ GMPChild::ActorDestroy(ActorDestroyReason aWhy)
}
if (AbnormalShutdown == aWhy) {
NS_WARNING("Abnormal shutdown of GMP process!");
_exit(0);
ProcessChild::QuickExit();
}
XRE_ShutdownChildProcess();

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_QT
#include <unistd.h> // for _exit()
#include <QtCore/QTimer>
#include "nsQAppInstance.h"
#include "NestedLoopTimer.h"
@ -33,6 +32,7 @@
#ifdef MOZ_X11
# include "mozilla/X11Util.h"
#endif
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/plugins/PluginInstanceChild.h"
#include "mozilla/plugins/StreamNotifyChild.h"
#include "mozilla/plugins/BrowserStreamChild.h"
@ -57,6 +57,7 @@
#include "GeckoProfiler.h"
using namespace mozilla;
using namespace mozilla::ipc;
using namespace mozilla::plugins;
using namespace mozilla::widget;
using mozilla::dom::CrashReporterChild;
@ -786,13 +787,6 @@ PluginModuleChild::RecvSetAudioSessionData(const nsID& aId,
#endif
}
void
PluginModuleChild::QuickExit()
{
NS_WARNING("plugin process _exit()ing");
_exit(0);
}
PPluginModuleChild*
PluginModuleChild::AllocPPluginModuleChild(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherPid)
@ -843,7 +837,7 @@ PluginModuleChild::ActorDestroy(ActorDestroyReason why)
if (AbnormalShutdown == why) {
NS_WARNING("shutting down early because of crash!");
QuickExit();
ProcessChild::QuickExit();
}
if (!mHasShutdown) {

View File

@ -142,8 +142,6 @@ protected:
virtual void
ActorDestroy(ActorDestroyReason why) override;
MOZ_NORETURN void QuickExit();
virtual bool
RecvProcessNativeEventsInInterruptCall() override;

View File

@ -7,6 +7,12 @@
#include "nsDebug.h"
#ifdef XP_WIN
#include <stdlib.h> // for _exit()
#else
#include <unistd.h> // for _exit()
#endif
#include "mozilla/ipc/IOThreadChild.h"
#include "mozilla/ipc/ProcessChild.h"
@ -30,5 +36,18 @@ ProcessChild::~ProcessChild()
gProcessChild = nullptr;
}
/* static */ void
ProcessChild::QuickExit()
{
#ifdef XP_WIN
// In bug 1254829, the destructor got called when dll got detached on windows,
// switch to TerminateProcess to bypass dll detach handler during the process
// termination.
TerminateProcess(GetCurrentProcess(), 0);
#else
_exit(0);
#endif
}
} // namespace ipc
} // namespace mozilla

View File

@ -36,6 +36,12 @@ public:
return gProcessChild->mUILoop;
}
/**
* Exit *now*. Do not shut down XPCOM, do not pass Go, do not run
* static destructors, do not collect $200.
*/
static void QuickExit();
protected:
static ProcessChild* current() {
return gProcessChild;