Fixes bug 72339. nsDNSService doesn't shutdown. r=gordon, sr=dougt

This commit is contained in:
darin%netscape.com 2001-03-28 21:18:51 +00:00
Родитель 376753989f
Коммит 774ae3fcfa
2 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -943,8 +943,9 @@ nsDNSService::DequeueLookup(nsDNSLookup **lookup)
nsAutoMonitor mon(mLookupQMon); nsAutoMonitor mon(mLookupQMon);
// Wait for notification of a queued request. // Wait for notification of a queued request, unless
if (!mLookupQ) // of course if we're in the process of shutting down.
if (!mLookupQ && !mShutdownInProgress)
mon.Wait(); mon.Wait();
// Got a request!! // Got a request!!
@ -967,22 +968,21 @@ nsDNSService::DequeueLookup(nsDNSLookup **lookup)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
nsDNSService::nsDNSService() nsDNSService::nsDNSService()
: mState(NS_OK), : mState(NS_OK)
mMonitor(nsnull), , mMonitor(nsnull)
mLookups(64) , mLookups(64)
#if defined(XP_UNIX) #if defined(XP_UNIX)
, mLookupQ(nsnull) , mLookupQ(nsnull)
, mLookupQMon(nsnull)
, mShutdownInProgress(PR_FALSE)
#endif #endif
#ifdef DNS_TIMING #ifdef DNS_TIMING
, , mCount(0)
mCount(0), , mTimes(0)
mTimes(0), , mSquaredTimes(0)
mSquaredTimes(0), , mOut(nsnull)
mOut(nsnull)
#endif #endif
, , mMyIPAddress(0)
mMyIPAddress(0)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
@ -1262,9 +1262,7 @@ nsDNSService::Run(void)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (lookup) { if (lookup) {
//
// Got a request!! // Got a request!!
//
lookup->DoSyncLookup(); lookup->DoSyncLookup();
NS_RELEASE(lookup); NS_RELEASE(lookup);
} else } else
@ -1544,6 +1542,7 @@ nsDNSService::Shutdown()
// Clear the lookup queue and wake up the worker thread. // Clear the lookup queue and wake up the worker thread.
// //
nsAutoMonitor mon2(mLookupQMon); nsAutoMonitor mon2(mLookupQMon);
mShutdownInProgress = PR_TRUE;
if (mLookupQ) { if (mLookupQ) {
mLookupQ->ClearNextLookup(); mLookupQ->ClearNextLookup();
NS_RELEASE(mLookupQ); NS_RELEASE(mLookupQ);

Просмотреть файл

@ -111,6 +111,9 @@ protected:
// Called by the DNS thread to get the next lookup to process. // Called by the DNS thread to get the next lookup to process.
// Blocks until a lookup is available. // Blocks until a lookup is available.
nsresult DequeueLookup(nsDNSLookup **); nsresult DequeueLookup(nsDNSLookup **);
// Needed if the DNS thread is not already waiting on the lookup monitor.
PRBool mShutdownInProgress;
#endif #endif
#ifdef DNS_TIMING #ifdef DNS_TIMING