mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 05:14:24 +00:00
bug 321024. Crash in nsCryptoHash during shutdown of nsUrlClassifierDBService. Patch by Tony Chang <tony@ponderer.org>. r=darin
This commit is contained in:
parent
fa3472f021
commit
d9429eeac3
@ -75,6 +75,10 @@ static nsUrlClassifierDBService* sUrlClassifierDBService;
|
||||
// Thread that we do the updates on.
|
||||
static nsIThread* gDbBackgroundThread = nsnull;
|
||||
|
||||
// Once we've committed to shutting down, don't do work in the background
|
||||
// thread.
|
||||
static PRBool gShuttingDownThread = PR_FALSE;
|
||||
|
||||
static const char* kNEW_TABLE_SUFFIX = "_new";
|
||||
|
||||
// This maps A-M to N-Z and N-Z to A-M. All other characters are left alone.
|
||||
@ -207,6 +211,9 @@ nsUrlClassifierDBServiceWorker::Exists(const nsACString& tableName,
|
||||
const nsACString& key,
|
||||
nsIUrlClassifierCallback *c)
|
||||
{
|
||||
if (gShuttingDownThread)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = OpenDb();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to open database");
|
||||
@ -252,6 +259,9 @@ NS_IMETHODIMP
|
||||
nsUrlClassifierDBServiceWorker::CheckTables(const nsACString & tableNames,
|
||||
nsIUrlClassifierCallback *c)
|
||||
{
|
||||
if (gShuttingDownThread)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = OpenDb();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to open database");
|
||||
@ -294,6 +304,9 @@ NS_IMETHODIMP
|
||||
nsUrlClassifierDBServiceWorker::UpdateTables(const nsACString& updateString,
|
||||
nsIUrlClassifierCallback *c)
|
||||
{
|
||||
if (gShuttingDownThread)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
LOG(("Updating tables\n"));
|
||||
|
||||
nsresult rv = OpenDb();
|
||||
@ -441,6 +454,11 @@ nsUrlClassifierDBServiceWorker::Finish(nsIUrlClassifierCallback *c)
|
||||
if (!mHasPendingUpdate)
|
||||
return NS_OK;
|
||||
|
||||
if (gShuttingDownThread) {
|
||||
mConnection->RollbackTransaction();
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
for (PRUint32 i = 0; i < mTableUpdateLines.Length(); ++i) {
|
||||
rv = MaybeSwapTables(mTableUpdateLines[i]);
|
||||
@ -995,11 +1013,14 @@ nsUrlClassifierDBService::Shutdown()
|
||||
mWorker,
|
||||
NS_PROXY_ASYNC,
|
||||
getter_AddRefs(proxy));
|
||||
proxy->CloseDb();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = proxy->CloseDb();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to post close db event");
|
||||
}
|
||||
}
|
||||
LOG(("joining background thread"));
|
||||
|
||||
gShuttingDownThread = PR_TRUE;
|
||||
gDbBackgroundThread->Shutdown();
|
||||
NS_RELEASE(gDbBackgroundThread);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user