From 395a39d4e8a2b5144c5771b51141197d8d4b2648 Mon Sep 17 00:00:00 2001 From: "dcamp@mozilla.com" Date: Wed, 16 Jan 2008 11:20:45 -0800 Subject: [PATCH] Bug 412392: Fix up some shutdown issues in nsUrlClassifierDBService. r=tony, a=schrep --- .../src/nsUrlClassifierDBService.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp index e5efa595c77..f8bb07a5253 100644 --- a/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp @@ -2071,6 +2071,9 @@ nsUrlClassifierDBServiceWorker::ResetUpdate() NS_IMETHODIMP nsUrlClassifierDBServiceWorker::BeginUpdate(nsIUrlClassifierUpdateObserver *observer) { + if (gShuttingDownThread) + return NS_ERROR_NOT_INITIALIZED; + NS_ENSURE_STATE(!mUpdateObserver); nsresult rv = OpenDb(); @@ -2110,6 +2113,9 @@ nsUrlClassifierDBServiceWorker::BeginUpdate(nsIUrlClassifierUpdateObserver *obse NS_IMETHODIMP nsUrlClassifierDBServiceWorker::BeginStream() { + if (gShuttingDownThread) + return NS_ERROR_NOT_INITIALIZED; + NS_ENSURE_STATE(mUpdateObserver); NS_ENSURE_STATE(!mInStream); @@ -2194,6 +2200,9 @@ nsUrlClassifierDBServiceWorker::UpdateStream(const nsACString& chunk) NS_IMETHODIMP nsUrlClassifierDBServiceWorker::FinishStream() { + if (gShuttingDownThread) + return NS_ERROR_NOT_INITIALIZED; + NS_ENSURE_STATE(mInStream); NS_ENSURE_STATE(mUpdateObserver); @@ -2207,6 +2216,9 @@ nsUrlClassifierDBServiceWorker::FinishStream() NS_IMETHODIMP nsUrlClassifierDBServiceWorker::FinishUpdate() { + if (gShuttingDownThread) + return NS_ERROR_NOT_INITIALIZED; + NS_ENSURE_STATE(!mInStream); NS_ENSURE_STATE(mUpdateObserver); @@ -2885,8 +2897,11 @@ nsUrlClassifierDBService::Shutdown() LOG(("joining background thread")); gShuttingDownThread = PR_TRUE; - gDbBackgroundThread->Shutdown(); - NS_RELEASE(gDbBackgroundThread); + + nsIThread *backgroundThread = gDbBackgroundThread; + gDbBackgroundThread = nsnull; + backgroundThread->Shutdown(); + NS_RELEASE(backgroundThread); return NS_OK; }