зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 122682 "browser hangs temporarily if switched offline while DNS thread in in GetHostByName". r=gagan, sr=darin.
This commit is contained in:
Родитель
51cf5d0033
Коммит
ff0e4ce58c
|
@ -941,6 +941,11 @@ nsDNSService::Init()
|
|||
PRStatus status = PR_SUCCESS;
|
||||
#endif
|
||||
|
||||
if (mState == DNS_OFFLINE) {
|
||||
mState = DNS_ONLINE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mDNSServiceLock == nsnull, "nsDNSService not shut down");
|
||||
if (mDNSServiceLock) return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
|
@ -994,7 +999,7 @@ nsDNSService::Init()
|
|||
rv = InstallPrefObserver();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mState = DNS_RUNNING;
|
||||
mState = DNS_ONLINE;
|
||||
return NS_OK;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
|
@ -1055,7 +1060,7 @@ nsDNSService::LateInit()
|
|||
|
||||
nsDNSService::~nsDNSService()
|
||||
{
|
||||
nsresult rv = Shutdown();
|
||||
nsresult rv = ShutdownInternal();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "DNS shutdown failed");
|
||||
NS_ASSERTION(mThread == nsnull, "DNS shutdown failed");
|
||||
NS_ASSERTION(mDNSServiceLock == nsnull, "DNS shutdown failed");
|
||||
|
@ -1380,7 +1385,7 @@ nsDNSService::Lookup(const char* hostName,
|
|||
nsresult rv;
|
||||
nsDNSRequest * request = nsnull;
|
||||
*result = nsnull;
|
||||
if (!mDNSServiceLock || (mState != DNS_RUNNING)) return NS_ERROR_OFFLINE;
|
||||
if (!mDNSServiceLock || (mState != DNS_ONLINE)) return NS_ERROR_OFFLINE;
|
||||
else {
|
||||
nsAutoLock dnsLock(mDNSServiceLock);
|
||||
|
||||
|
@ -1582,6 +1587,8 @@ nsDNSService::AbortLookups()
|
|||
NS_IMETHODIMP
|
||||
nsDNSService::Resolve(const char *i_hostname, char **o_ip)
|
||||
{
|
||||
if (!mDNSServiceLock || (mState != DNS_ONLINE)) return NS_ERROR_OFFLINE;
|
||||
|
||||
// Beware! This does not check for an IP address already in hostname.
|
||||
NS_ENSURE_ARG_POINTER(o_ip);
|
||||
*o_ip = 0;
|
||||
|
@ -1711,6 +1718,13 @@ nsDNSService::IsInNet(const char * ipaddr,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsDNSService::Shutdown()
|
||||
{
|
||||
mState = DNS_OFFLINE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDNSService::ShutdownInternal()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ private:
|
|||
void EvictLookup( nsDNSLookup * lookup);
|
||||
void AddToEvictionQ( nsDNSLookup * lookup);
|
||||
void AbortLookups();
|
||||
|
||||
nsresult ShutdownInternal();
|
||||
|
||||
static PRBool gNeedLateInitialization;
|
||||
static PLDHashTableOps gHashTableOps;
|
||||
|
@ -125,9 +125,10 @@ private:
|
|||
|
||||
enum {
|
||||
DNS_NOT_INITIALIZED = 0,
|
||||
DNS_RUNNING = 1,
|
||||
DNS_SHUTTING_DOWN = 2,
|
||||
DNS_SHUTDOWN = 3
|
||||
DNS_ONLINE = 1,
|
||||
DNS_OFFLINE = 2,
|
||||
DNS_SHUTTING_DOWN = 3,
|
||||
DNS_SHUTDOWN = 4
|
||||
};
|
||||
|
||||
#if defined(XP_MAC)
|
||||
|
|
Загрузка…
Ссылка в новой задаче