Bug 704030 - Make the "all connections closed" check available on non debug builds. r=vladan.

--HG--
extra : rebase_source : 6f39e1e00b39e7356d29c4f5e3f77fa51ba49a16
This commit is contained in:
Rafael Ávila de Espíndola 2013-02-11 12:05:59 -05:00
parent 4f2c4640ed
commit 8d8ceadb10
3 changed files with 55 additions and 6 deletions

View File

@ -22,6 +22,7 @@
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
#include "mozilla/mozPoisonWrite.h"
#include "sqlite3.h"
@ -821,13 +822,15 @@ Service::Observe(nsISupports *, const char *aTopic, const PRUnichar *)
}
} while (anyOpen);
#ifdef DEBUG
nsTArray<nsRefPtr<Connection> > connections;
getConnections(connections);
for (uint32_t i = 0, n = connections.Length(); i < n; i++) {
MOZ_ASSERT(!connections[i]->ConnectionReady());
if (ShutdownChecks == SCM_CRASH) {
nsTArray<nsRefPtr<Connection> > connections;
getConnections(connections);
for (uint32_t i = 0, n = connections.Length(); i < n; i++) {
if (connections[i]->ConnectionReady()) {
MOZ_CRASH();
}
}
}
#endif
}
return NS_OK;

View File

@ -3214,6 +3214,43 @@ XREMain::XRE_mainInit(const nsXREAppData* aAppData, bool* aExitFlag)
return 0;
}
namespace mozilla {
ShutdownChecksMode ShutdownChecks = SCM_NOTHING;
}
static void SetShutdownChecks() {
// Set default first. On debug builds we crash. On nightly and local
// builds we record. Nightlies will then send the info via telemetry,
// but it is usefull to have the data in about:telemetry in local builds
// too.
#ifdef DEBUG
ShutdownChecks = SCM_CRASH;
#else
const char* releaseChannel = NS_STRINGIFY(MOZ_UPDATE_CHANNEL);
if (strcmp(releaseChannel, "nightly") == 0 ||
strcmp(releaseChannel, "default") == 0) {
ShutdownChecks = SCM_RECORD;
} else {
ShutdownChecks = SCM_NOTHING;
}
#endif
// We let an environment variable override the default so that addons
// authors can use it for debugging shutdown with released firefox versions.
const char* mozShutdownChecksEnv = PR_GetEnv("MOZ_SHUTDOWN_CHECKS");
if (mozShutdownChecksEnv) {
if (strcmp(mozShutdownChecksEnv, "crash") == 0) {
ShutdownChecks = SCM_CRASH;
} else if (strcmp(mozShutdownChecksEnv, "record") == 0) {
ShutdownChecks = SCM_RECORD;
} else if (strcmp(mozShutdownChecksEnv, "nothing") == 0) {
ShutdownChecks = SCM_NOTHING;
}
}
}
/*
* XRE_mainStartup - Initializes the profile and various other services.
* Main() will exit early if either return value != 0 or if aExitFlag is
@ -3228,6 +3265,8 @@ XREMain::XRE_mainStartup(bool* aExitFlag)
return 1;
*aExitFlag = false;
SetShutdownChecks();
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_ENABLE_XREMOTE)
// Stash DESKTOP_STARTUP_ID in malloc'ed memory because gtk_init will clear it.
#define HAVE_DESKTOP_STARTUP_ID

View File

@ -19,6 +19,13 @@ MOZ_END_EXTERN_C
#ifdef __cplusplus
namespace mozilla {
enum ShutdownChecksMode {
SCM_CRASH,
SCM_RECORD,
SCM_NOTHING
};
extern ShutdownChecksMode ShutdownChecks;
void PoisonWrite();
void DisableWritePoisoning();
void EnableWritePoisoning();