From 755316d04190177a97f042fe7009e46a8e5c3d25 Mon Sep 17 00:00:00 2001 From: Benedict Hsieh Date: Fri, 2 Jul 2010 16:59:17 -0700 Subject: [PATCH] Bug 531886 - [regression] *.mfasl fastload caches not invalidated after build / changing XUL/JS code. r=bsmedberg --- config/rules.mk | 3 +++ js/src/config/rules.mk | 3 +++ toolkit/xre/nsAppRunner.cpp | 50 ++++++++++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index d0d2239b18ef..2c1900e939f5 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -2291,3 +2291,6 @@ CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \ libs export libs:: $(CHECK_FROZEN_VARIABLES) + +default:: + if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index d0d2239b18ef..2c1900e939f5 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -2291,3 +2291,6 @@ CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \ libs export libs:: $(CHECK_FROZEN_VARIABLES) + +default:: + if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 1a3eb39d561d..b624ddcb7740 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -248,6 +248,7 @@ extern void InstallSignalHandlers(const char *ProgramName); #include "nsX11ErrorHandler.h" #define FILE_COMPATIBILITY_INFO NS_LITERAL_CSTRING("compatibility.ini") +#define FILE_INVALIDATE_CACHES NS_LITERAL_CSTRING(".purgecaches") int gArgc; char **gArgv; @@ -2309,9 +2310,10 @@ SelectProfile(nsIProfileLock* *aResult, nsINativeAppSupport* aNative, static PRBool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion, const nsCString& aOSABI, nsIFile* aXULRunnerDir, - nsIFile* aAppDir, PRBool* aCachesOK) + nsIFile* aAppDir, nsILocalFile* aFlagFile, + PRBool* aCachesOK) { - *aCachesOK = false; + *aCachesOK = PR_FALSE; nsCOMPtr file; aProfileDir->Clone(getter_AddRefs(file)); if (!file) @@ -2363,10 +2365,18 @@ CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion, return PR_FALSE; } - rv = parser.GetString("Compatibility", "InvalidateCaches", buf); - // If we see this flag, caches are invalid. + rv = parser.GetString("Compatibility", "InvalidateCaches", buf); *aCachesOK = (NS_FAILED(rv) || !buf.EqualsLiteral("1")); + +#ifdef DEBUG + PRBool purgeCaches = PR_FALSE; + if (aFlagFile) { + aFlagFile->Exists(&purgeCaches); + } + + *aCachesOK = !purgeCaches && *aCachesOK; +#endif return PR_TRUE; } @@ -3267,11 +3277,34 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) // by the BuildVersion function. // Also check to see if something has happened to invalidate our // fastload caches, like an extension upgrade or installation. + + // If we see .purgecaches, that means someone did a make. + // Re-register components to catch potential changes. + // We only offer this in debug builds, though. + nsCOMPtr flagFile; +#ifdef DEBUG + rv = NS_ERROR_FILE_NOT_FOUND; + nsCOMPtr fFlagFile; + if (gAppData->directory) { + rv = gAppData->directory->Clone(getter_AddRefs(fFlagFile)); + } + flagFile = do_QueryInterface(fFlagFile); + if (flagFile) { + flagFile->SetNativeLeafName(FILE_INVALIDATE_CACHES); + } + #endif PRBool cachesOK; PRBool versionOK = CheckCompatibility(profD, version, osABI, dirProvider.GetGREDir(), - gAppData->directory, &cachesOK); - + gAppData->directory, flagFile, + &cachesOK); + if (CheckArg("purgecaches")) { + cachesOK = PR_FALSE; + } + if (PR_GetEnv("MOZ_PURGE_CACHES")) { + cachesOK = PR_FALSE; + } + // Every time a profile is loaded by a build with a different version, // it updates the compatibility.ini file saying what version last wrote // the fastload caches. On subsequent launches if the version matches, @@ -3313,6 +3346,11 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) dirProvider.GetGREDir(), gAppData->directory); } +#ifdef DEBUG + if (flagFile) { + flagFile->Remove(PR_TRUE); + } +#endif PRBool needsRestart = PR_FALSE; PRBool appInitiatedRestart = PR_FALSE;