Bug 1422820 - Don't recurse too much when shutting down cameras. r=pehrsons

--HG--
extra : histedit_source : 2f3145f04e4ca35a412b9870a29ff26d28eab5d6
This commit is contained in:
Paul Adenot 2018-02-08 17:49:25 +01:00
parent 6a3772c982
commit 46da831f14
2 changed files with 16 additions and 2 deletions

View File

@ -34,7 +34,9 @@ CamerasSingleton::CamerasSingleton()
: mCamerasMutex("CamerasSingleton::mCamerasMutex"),
mCameras(nullptr),
mCamerasChildThread(nullptr),
mFakeDeviceChangeEventThread(nullptr) {
mFakeDeviceChangeEventThread(nullptr),
mInShutdown(false)
{
LOG(("CamerasSingleton: %p", this));
}
@ -568,6 +570,9 @@ void
Shutdown(void)
{
OffTheBooksMutexAutoLock lock(CamerasSingleton::Mutex());
CamerasSingleton::StartShutdown();
CamerasChild* child = CamerasSingleton::Child();
if (!child) {
// We don't want to cause everything to get fired up if we're
@ -728,7 +733,7 @@ CamerasChild::~CamerasChild()
{
LOG(("~CamerasChild: %p", this));
{
if (!CamerasSingleton::InShutdown()) {
OffTheBooksMutexAutoLock lock(CamerasSingleton::Mutex());
// In normal circumstances we've already shut down and the
// following does nothing. But on fatal IPC errors we will

View File

@ -92,6 +92,14 @@ public:
return gTheInstance.get()->mFakeDeviceChangeEventThread;
}
static bool InShutdown() {
return gTheInstance.get()->mInShutdown;
}
static void StartShutdown() {
gTheInstance.get()->mInShutdown = true;
}
private:
static Singleton<CamerasSingleton> gTheInstance;
@ -109,6 +117,7 @@ private:
CamerasChild* mCameras;
nsCOMPtr<nsIThread> mCamerasChildThread;
nsCOMPtr<nsIThread> mFakeDeviceChangeEventThread;
Atomic<bool> mInShutdown;
};
// Get a pointer to a CamerasChild object we can use to do IPC with.