Bug 711447 - Close connection in nsPermissionManager. r=dwitte.

--HG--
extra : rebase_source : 0df435f943142b7a09de36fdb03e01114ef20f15
This commit is contained in:
Rafael Ávila de Espíndola 2011-12-21 17:04:49 -05:00
parent fbf4870fb3
commit 5fe190c37d
2 changed files with 20 additions and 10 deletions

View File

@ -620,6 +620,20 @@ nsPermissionManager::RemoveAll()
return rv;
}
void
nsPermissionManager::CloseDB()
{
// Null the statements, this will finalize them.
mStmtInsert = nsnull;
mStmtDelete = nsnull;
mStmtUpdate = nsnull;
if (mDBConn) {
mozilla::DebugOnly<nsresult> rv = mDBConn->Close();
MOZ_ASSERT(NS_SUCCEEDED(rv));
mDBConn = nsnull;
}
}
nsresult
nsPermissionManager::RemoveAllInternal()
{
@ -629,10 +643,7 @@ nsPermissionManager::RemoveAllInternal()
if (mDBConn) {
nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("DELETE FROM moz_hosts"));
if (NS_FAILED(rv)) {
mStmtInsert = nsnull;
mStmtDelete = nsnull;
mStmtUpdate = nsnull;
mDBConn = nsnull;
CloseDB();
rv = InitDB(true);
return rv;
}
@ -792,12 +803,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
} else {
RemoveAllFromMemory();
}
if (mDBConn) {
// Null the statements, this will finalize them.
mStmtInsert = nsnull;
mStmtDelete = nsnull;
mStmtUpdate = nsnull;
}
CloseDB();
}
else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
// the profile has already changed; init the db from the new location

View File

@ -222,6 +222,10 @@ private:
PRInt64 aExpireTime,
const PRUnichar *aData);
void NotifyObservers(nsIPermission *aPermission, const PRUnichar *aData);
// Finalize all statements, close the DB and null it.
void CloseDB();
nsresult RemoveAllInternal();
nsresult RemoveAllFromMemory();
nsresult NormalizeToACE(nsCString &aHost);