Backed out changeset ecd2b45a42af (Bug 364864) due to Leak test red

This commit is contained in:
Karsten Düsterloh
2009-10-05 23:34:21 +02:00
parent 18eeeadc8d
commit b1af2f1ce4
3 changed files with 14 additions and 31 deletions

View File

@@ -283,10 +283,8 @@ CategoryNode::AddLeaf(const char* aEntryName,
PRBool aPersist, PRBool aPersist,
PRBool aReplace, PRBool aReplace,
char** _retval, char** _retval,
PLArenaPool* aArena, PLArenaPool* aArena)
PRBool* aDirty)
{ {
NS_ABORT_IF_FALSE(aDirty, "CategoryNode::AddLeaf: aDirty is null");
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
CategoryLeaf* leaf = CategoryLeaf* leaf =
mTable.GetEntry(aEntryName); mTable.GetEntry(aEntryName);
@@ -325,29 +323,25 @@ CategoryNode::AddLeaf(const char* aEntryName,
} }
leaf->nonpValue = arenaValue; leaf->nonpValue = arenaValue;
if (aPersist) { if (aPersist)
leaf->pValue = arenaValue; leaf->pValue = arenaValue;
*aDirty = PR_TRUE;
}
} }
} }
return rv; return rv;
} }
NS_METHOD NS_METHOD
CategoryNode::DeleteLeaf(const char* aEntryName, CategoryNode::DeleteLeaf(const char* aEntryName,
PRBool aDontPersistAnymore, PRBool aDontPersist)
PRBool* aDirty)
{ {
NS_ABORT_IF_FALSE(aDirty, "CategoryNode::DeleteLeaf: aDirty is null");
// we don't throw any errors, because it normally doesn't matter // we don't throw any errors, because it normally doesn't matter
// and it makes JS a lot cleaner // and it makes JS a lot cleaner
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
if (aDontPersistAnymore) { if (aDontPersist) {
// we can just remove the entire hash entry without introspection // we can just remove the entire hash entry without introspection
mTable.RemoveEntry(aEntryName); mTable.RemoveEntry(aEntryName);
*aDirty = PR_TRUE;
} else { } else {
// if we are keeping the persistent value, we need to look at // if we are keeping the persistent value, we need to look at
// the contents of the current entry // the contents of the current entry
@@ -603,6 +597,7 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
if (!category) { if (!category) {
// That category doesn't exist yet; let's make it. // That category doesn't exist yet; let's make it.
category = CategoryNode::Create(&mArena); category = CategoryNode::Create(&mArena);
char* categoryName = ArenaStrdup(aCategoryName, &mArena); char* categoryName = ArenaStrdup(aCategoryName, &mArena);
mTable.Put(categoryName, category); mTable.Put(categoryName, category);
} }
@@ -613,13 +608,13 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
// We will need the return value of AddLeaf even if the called doesn't want it // We will need the return value of AddLeaf even if the called doesn't want it
char *oldEntry = nsnull; char *oldEntry = nsnull;
nsresult rv = category->AddLeaf(aEntryName, nsresult rv = category->AddLeaf(aEntryName,
aValue, aValue,
aPersist, aPersist,
aReplace, aReplace,
&oldEntry, &oldEntry,
&mArena, &mArena);
&mDirty);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
if (oldEntry) { if (oldEntry) {
@@ -641,7 +636,7 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
NS_IMETHODIMP NS_IMETHODIMP
nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName, nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
const char *aEntryName, const char *aEntryName,
PRBool aDontPersistAnymore) PRBool aDontPersist)
{ {
NS_ENSURE_ARG_POINTER(aCategoryName); NS_ENSURE_ARG_POINTER(aCategoryName);
NS_ENSURE_ARG_POINTER(aEntryName); NS_ENSURE_ARG_POINTER(aEntryName);
@@ -662,8 +657,7 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
return NS_OK; return NS_OK;
nsresult rv = category->DeleteLeaf(aEntryName, nsresult rv = category->DeleteLeaf(aEntryName,
aDontPersistAnymore, aDontPersist);
&mDirty);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
NotifyObservers(NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID, NotifyObservers(NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID,
@@ -768,7 +762,6 @@ nsCategoryManager::WriteCategoryManagerToRegistry(PRFileDesc* fd)
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
mDirty = PR_FALSE;
return NS_OK; return NS_OK;
} }

View File

@@ -88,12 +88,10 @@ public:
PRBool aPersist, PRBool aPersist,
PRBool aReplace, PRBool aReplace,
char** _retval, char** _retval,
PLArenaPool* aArena, PLArenaPool* aArena);
PRBool* aDirty);
NS_METHOD DeleteLeaf(const char* aEntryName, NS_METHOD DeleteLeaf(const char* aEntryName,
PRBool aDontPersist, PRBool aDontPersist);
PRBool* aDirty);
void Clear() { void Clear() {
mozilla::MutexAutoLock lock(mLock); mozilla::MutexAutoLock lock(mLock);
@@ -152,16 +150,9 @@ public:
*/ */
NS_METHOD SuppressNotifications(PRBool aSuppress); NS_METHOD SuppressNotifications(PRBool aSuppress);
/**
* Do we have persistable category changes?
* This is to be used by nsComponentManagerImpl::Shutdown ONLY.
*/
inline PRBool IsDirty() { return mDirty; }
nsCategoryManager() nsCategoryManager()
: mLock("nsCategoryManager") : mLock("nsCategoryManager")
, mSuppressNotifications(PR_FALSE) , mSuppressNotifications(PR_FALSE)
, mDirty(PR_FALSE)
{ } { }
private: private:
@@ -179,7 +170,6 @@ private:
nsClassHashtable<nsDepCharHashKey, CategoryNode> mTable; nsClassHashtable<nsDepCharHashKey, CategoryNode> mTable;
mozilla::Mutex mLock; mozilla::Mutex mLock;
PRBool mSuppressNotifications; PRBool mSuppressNotifications;
PRBool mDirty;
}; };
#endif #endif

View File

@@ -715,8 +715,8 @@ nsresult nsComponentManagerImpl::Shutdown(void)
// Shutdown the component manager // Shutdown the component manager
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning Shutdown.")); PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning Shutdown."));
// Write out our component data file, if dirty. // Write out our component data file.
if (mRegistryDirty || mCategoryManager->IsDirty()) { if (mRegistryDirty) {
nsresult rv = WritePersistentRegistry(); nsresult rv = WritePersistentRegistry();
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, ("nsComponentManager: Could not write out persistent registry.")); PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, ("nsComponentManager: Could not write out persistent registry."));