mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backing out changesets 374d3cf7b48d, 5d9dc9b6127e, 8c4f57a5674d, cd9a392337b7
This commit is contained in:
parent
3df57bb663
commit
f3130e5161
@ -101,8 +101,6 @@
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
PRLogModuleInfo* gContentSinkLogModuleInfo;
|
||||
|
||||
@ -723,10 +721,6 @@ nsContentSink::ProcessLink(nsIContent* aElement,
|
||||
PrefetchHref(aHref, aElement, hasPrefetch);
|
||||
}
|
||||
|
||||
if ((!aHref.IsEmpty()) && linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
PrefetchDNS(aHref);
|
||||
}
|
||||
|
||||
// is it a stylesheet link?
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
|
||||
return NS_OK;
|
||||
@ -858,23 +852,6 @@ nsContentSink::PrefetchHref(const nsAString &aHref,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsContentSink::PrefetchDNS(const nsAString &aHref)
|
||||
{
|
||||
nsAutoString hostname;
|
||||
|
||||
if (StringBeginsWith(aHref, NS_LITERAL_STRING("//"))) {
|
||||
hostname = Substring(aHref, 2);
|
||||
}
|
||||
else
|
||||
nsGenericHTMLElement::GetHostnameFromHrefString(aHref, hostname);
|
||||
|
||||
nsRefPtr<nsHTMLDNSPrefetch> prefetch = new nsHTMLDNSPrefetch(hostname, mDocument);
|
||||
if (prefetch) {
|
||||
prefetch->PrefetchLow();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::GetChannelCacheKey(nsIChannel* aChannel, nsACString& aCacheKey)
|
||||
{
|
||||
|
@ -192,10 +192,6 @@ protected:
|
||||
void PrefetchHref(const nsAString &aHref, nsIContent *aSource,
|
||||
PRBool aExplicit);
|
||||
|
||||
// aHref can either be the usual URI format or of the form "//www.hostname.com"
|
||||
// without a scheme.
|
||||
void PrefetchDNS(const nsAString &aHref);
|
||||
|
||||
// Gets the cache key (used to identify items in a cache) of the channel.
|
||||
nsresult GetChannelCacheKey(nsIChannel* aChannel, nsACString& aCacheKey);
|
||||
|
||||
|
@ -6561,7 +6561,6 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
||||
"content-language",
|
||||
"content-disposition",
|
||||
"refresh",
|
||||
"x-dns-prefetch-control",
|
||||
// add more http headers if you need
|
||||
// XXXbz don't add content-location support without reading bug
|
||||
// 238654 and its dependencies/dups first.
|
||||
|
@ -987,7 +987,6 @@ GK_ATOM(headerWindowTarget, "window-target")
|
||||
GK_ATOM(withParam, "with-param")
|
||||
GK_ATOM(wizard, "wizard")
|
||||
GK_ATOM(wrap, "wrap")
|
||||
GK_ATOM(headerDNSPrefetchControl,"x-dns-prefetch-control")
|
||||
GK_ATOM(xml, "xml")
|
||||
GK_ATOM(xmlns, "xmlns")
|
||||
GK_ATOM(xmp, "xmp")
|
||||
|
@ -83,7 +83,6 @@ EXPORTS = \
|
||||
|
||||
CPPSRCS = \
|
||||
nsClientRect.cpp \
|
||||
nsHTMLDNSPrefetch.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsFormSubmission.cpp \
|
||||
nsImageMapUtils.cpp \
|
||||
|
@ -64,8 +64,6 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
|
||||
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
||||
@ -137,26 +135,11 @@ public:
|
||||
protected:
|
||||
// The cached visited state
|
||||
nsLinkState mLinkState;
|
||||
|
||||
void PrefetchDNS();
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Anchor)
|
||||
|
||||
void
|
||||
nsHTMLAnchorElement::PrefetchDNS()
|
||||
{
|
||||
nsCOMPtr<nsIURI> hrefURI;
|
||||
GetHrefURI(getter_AddRefs(hrefURI));
|
||||
|
||||
if (hrefURI) {
|
||||
nsRefPtr<nsHTMLDNSPrefetch> prefetch =
|
||||
new nsHTMLDNSPrefetch(hrefURI, GetOwnerDoc());
|
||||
if (prefetch)
|
||||
prefetch->PrefetchLow();
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLAnchorElement::nsHTMLAnchorElement(nsINodeInfo *aNodeInfo)
|
||||
: nsGenericHTMLElement(aNodeInfo),
|
||||
@ -229,7 +212,6 @@ nsHTMLAnchorElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
|
||||
PrefetchDNS();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2950,13 +2950,6 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
||||
PrefetchHref(hrefVal, element, hasPrefetch);
|
||||
}
|
||||
}
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
nsAutoString hrefVal;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchDNS(hrefVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -657,18 +657,6 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
mScriptLoader->AddExecuteBlocker();
|
||||
}
|
||||
}
|
||||
// Look for <link rel="dns-prefetch" href="hostname">
|
||||
if (nodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
|
||||
nsAutoString relVal;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
if (relVal.EqualsLiteral("dns-prefetch")) {
|
||||
nsAutoString hrefVal;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchDNS(hrefVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -83,7 +83,6 @@
|
||||
#include "nsXMLHttpRequest.h"
|
||||
#include "nsIFocusEventSuppressor.h"
|
||||
#include "nsDOMThreadService.h"
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPopupManager.h"
|
||||
@ -186,12 +185,6 @@ nsLayoutStatics::Initialize()
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = nsHTMLDNSPrefetch::Initialize();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Could not initialize HTML DNS prefetch");
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
rv = nsXULContentUtils::Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -287,7 +280,6 @@ nsLayoutStatics::Shutdown()
|
||||
CSSLoaderImpl::Shutdown();
|
||||
nsCSSRuleProcessor::FreeSystemMetrics();
|
||||
nsTextFrameTextRunCache::Shutdown();
|
||||
nsHTMLDNSPrefetch::Shutdown();
|
||||
nsCSSRendering::Shutdown();
|
||||
#ifdef DEBUG
|
||||
nsFrame::DisplayReflowShutdown();
|
||||
|
@ -51,7 +51,7 @@ native PRNetAddr(union PRNetAddr);
|
||||
* NOTE: This is a free-threaded interface, meaning that the methods on
|
||||
* this interface may be called from any thread.
|
||||
*/
|
||||
[scriptable, uuid(ef3f4993-cfbc-4e5a-9509-16deafe16549)]
|
||||
[scriptable, uuid(66418cc8-5f5d-4f52-a7f9-db8fb3b2cfe6)]
|
||||
interface nsISocketTransport : nsITransport
|
||||
{
|
||||
/**
|
||||
@ -134,22 +134,6 @@ interface nsISocketTransport : nsITransport
|
||||
const unsigned long STATUS_SENDING_TO = 0x804b0005;
|
||||
const unsigned long STATUS_WAITING_FOR = 0x804b000a;
|
||||
const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
|
||||
|
||||
/**
|
||||
* connectionFlags is a bitmask that can be used to modify underlying
|
||||
* behavior of the socket connection.
|
||||
*/
|
||||
attribute unsigned long connectionFlags;
|
||||
|
||||
/**
|
||||
* Values for the connectionFlags
|
||||
*
|
||||
* When making a new connection BYPASS_CACHE will force the Necko DNS
|
||||
* cache entry to be refreshed with a new call to NSPR if it is set before
|
||||
* opening the new stream.
|
||||
*/
|
||||
const unsigned long BYPASS_CACHE = (1 << 0);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
@ -272,14 +272,6 @@
|
||||
#define NS_ERROR_UNKNOWN_HOST \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 30)
|
||||
|
||||
/**
|
||||
* A low or medium priority DNS lookup failed because the pending
|
||||
* queue was already full. High priorty (the default) always
|
||||
* makes room
|
||||
*/
|
||||
#define NS_ERROR_DNS_LOOKUP_QUEUE_FULL \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 33)
|
||||
|
||||
/**
|
||||
* The lookup of a proxy hostname failed.
|
||||
*
|
||||
|
@ -93,7 +93,6 @@ CPPSRCS = \
|
||||
nsNetStrings.cpp \
|
||||
nsBase64Encoder.cpp \
|
||||
nsSerializationHelper.cpp \
|
||||
nsDNSPrefetch.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
|
@ -707,7 +707,6 @@ nsSocketTransport::nsSocketTransport()
|
||||
, mProxyPort(0)
|
||||
, mProxyTransparent(PR_FALSE)
|
||||
, mProxyTransparentResolvesHost(PR_FALSE)
|
||||
, mConnectionFlags(0)
|
||||
, mState(STATE_CLOSED)
|
||||
, mAttached(PR_FALSE)
|
||||
, mInputClosed(PR_TRUE)
|
||||
@ -947,11 +946,7 @@ nsSocketTransport::ResolveHost()
|
||||
|
||||
mResolving = PR_TRUE;
|
||||
|
||||
PRUint32 dnsFlags = 0;
|
||||
if (mConnectionFlags & nsSocketTransport::BYPASS_CACHE)
|
||||
dnsFlags = nsIDNSService::RESOLVE_BYPASS_CACHE;
|
||||
|
||||
rv = dns->AsyncResolve(SocketHost(), dnsFlags, this, nsnull,
|
||||
rv = dns->AsyncResolve(SocketHost(), 0, this, nsnull,
|
||||
getter_AddRefs(mDNSRequest));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG((" advancing to STATE_RESOLVING\n"));
|
||||
@ -1951,21 +1946,6 @@ nsSocketTransport::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetConnectionFlags(PRUint32 *value)
|
||||
{
|
||||
*value = mConnectionFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetConnectionFlags(PRUint32 value)
|
||||
{
|
||||
mConnectionFlags = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_SOCKET_TRACING
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -202,8 +202,7 @@ private:
|
||||
PRUint16 mProxyPort;
|
||||
PRPackedBool mProxyTransparent;
|
||||
PRPackedBool mProxyTransparentResolvesHost;
|
||||
PRUint32 mConnectionFlags;
|
||||
|
||||
|
||||
PRUint16 SocketPort() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyPort : mPort; }
|
||||
const nsCString &SocketHost() { return (!mProxyHost.IsEmpty() && !mProxyTransparent) ? mProxyHost : mHost; }
|
||||
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include "nsDiskCacheDeviceSQL.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsNetStrings.h"
|
||||
#include "nsDNSPrefetch.h"
|
||||
|
||||
#include "nsNetCID.h"
|
||||
|
||||
@ -620,13 +619,10 @@ static void nsNetShutdown(nsIModule *neckoModule)
|
||||
#ifdef XP_MACOSX
|
||||
net_ShutdownURLHelperOSX();
|
||||
#endif
|
||||
|
||||
|
||||
// Release necko strings
|
||||
delete gNetStrings;
|
||||
gNetStrings = nsnull;
|
||||
|
||||
// Release DNS service reference.
|
||||
nsDNSPrefetch::Shutdown();
|
||||
}
|
||||
|
||||
static const nsModuleComponentInfo gNetModuleInfo[] = {
|
||||
|
@ -46,7 +46,7 @@ interface nsIDNSListener;
|
||||
/**
|
||||
* nsIDNSService
|
||||
*/
|
||||
[scriptable, uuid(ee4d9f1d-4f99-4384-b547-29da735f8b6e)]
|
||||
[scriptable, uuid(3ac9e611-e6b6-44b5-b312-c040e65b2929)]
|
||||
interface nsIDNSService : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -107,11 +107,4 @@ interface nsIDNSService : nsISupports
|
||||
* if set, the canonical name of the specified host will be queried.
|
||||
*/
|
||||
const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1);
|
||||
|
||||
/**
|
||||
* if set, the query is given lower priority. Medium takes precedence
|
||||
* if both are used.
|
||||
*/
|
||||
const unsigned long RESOLVE_PRIORITY_MEDIUM = (1 << 2);
|
||||
const unsigned long RESOLVE_PRIORITY_LOW = (1 << 3);
|
||||
};
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetError.h"
|
||||
#include "nsDNSPrefetch.h"
|
||||
#include "prsystem.h"
|
||||
#include "prnetdb.h"
|
||||
#include "prmon.h"
|
||||
@ -62,7 +61,6 @@ static const char kPrefDnsCacheExpiration[] = "network.dnsCacheExpiration";
|
||||
static const char kPrefEnableIDN[] = "network.enableIDN";
|
||||
static const char kPrefIPv4OnlyDomains[] = "network.dns.ipv4OnlyDomains";
|
||||
static const char kPrefDisableIPv6[] = "network.dns.disableIPv6";
|
||||
static const char kPrefDisablePrefetch[] = "network.dns.disablePrefetch";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -323,12 +321,10 @@ nsDNSService::Init()
|
||||
PRBool firstTime = (mLock == nsnull);
|
||||
|
||||
// prefs
|
||||
PRUint32 maxCacheEntries = 400;
|
||||
PRUint32 maxCacheLifetime = 3; // minutes
|
||||
PRUint32 maxCacheEntries = 20;
|
||||
PRUint32 maxCacheLifetime = 1; // minutes
|
||||
PRBool enableIDN = PR_TRUE;
|
||||
PRBool disableIPv6 = PR_FALSE;
|
||||
PRBool disablePrefetch = PR_FALSE;
|
||||
|
||||
nsAdoptingCString ipv4OnlyDomains;
|
||||
|
||||
// read prefs
|
||||
@ -344,7 +340,6 @@ nsDNSService::Init()
|
||||
prefs->GetBoolPref(kPrefEnableIDN, &enableIDN);
|
||||
prefs->GetBoolPref(kPrefDisableIPv6, &disableIPv6);
|
||||
prefs->GetCharPref(kPrefIPv4OnlyDomains, getter_Copies(ipv4OnlyDomains));
|
||||
prefs->GetBoolPref(kPrefDisablePrefetch, &disablePrefetch);
|
||||
}
|
||||
|
||||
if (firstTime) {
|
||||
@ -359,7 +354,6 @@ nsDNSService::Init()
|
||||
prefs->AddObserver(kPrefEnableIDN, this, PR_FALSE);
|
||||
prefs->AddObserver(kPrefIPv4OnlyDomains, this, PR_FALSE);
|
||||
prefs->AddObserver(kPrefDisableIPv6, this, PR_FALSE);
|
||||
prefs->AddObserver(kPrefDisablePrefetch, this, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,10 +374,8 @@ nsDNSService::Init()
|
||||
mIDN = idn;
|
||||
mIPv4OnlyDomains = ipv4OnlyDomains; // exchanges buffer ownership
|
||||
mDisableIPv6 = disableIPv6;
|
||||
mDisablePrefetch = disablePrefetch;
|
||||
}
|
||||
|
||||
nsDNSPrefetch::Initialize(this);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -414,10 +406,6 @@ nsDNSService::AsyncResolve(const nsACString &hostname,
|
||||
nsCOMPtr<nsIIDNService> idn;
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
if (mDisablePrefetch && (flags & (RESOLVE_PRIORITY_LOW | RESOLVE_PRIORITY_MEDIUM)))
|
||||
return NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
|
||||
|
||||
res = mResolver;
|
||||
idn = mIDN;
|
||||
}
|
||||
|
@ -68,5 +68,4 @@ private:
|
||||
// a per-domain basis and work around broken DNS servers. See bug 68796.
|
||||
nsAdoptingCString mIPv4OnlyDomains;
|
||||
PRBool mDisableIPv6;
|
||||
PRBool mDisablePrefetch;
|
||||
};
|
||||
|
@ -68,28 +68,8 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Use a persistent thread pool in order to avoid spinning up new threads all the time.
|
||||
// In particular, thread creation results in a res_init() call from libc which is
|
||||
// quite expensive.
|
||||
//
|
||||
// The pool dynamically grows between 0 and MAX_RESOLVER_THREADS in size. New requests
|
||||
// go first to an idle thread. If that cannot be found and there are fewer than MAX_RESOLVER_THREADS
|
||||
// currently in the pool a new thread is created for high priority requests. If
|
||||
// the new request is at a lower priority a new thread will only be created if
|
||||
// there are fewer than HighThreadThreshold currently outstanding. If a thread cannot be
|
||||
// created or an idle thread located for the request it is queued.
|
||||
//
|
||||
// When the pool is greater than HighThreadThreshold in size a thread will be destroyed after
|
||||
// ShortIdleTimeoutSeconds of idle time. Smaller pools use LongIdleTimeoutSeconds for a
|
||||
// timeout period.
|
||||
|
||||
#define MAX_NON_PRIORITY_REQUESTS 150
|
||||
|
||||
#define HighThreadThreshold 4
|
||||
#define LongIdleTimeoutSeconds 300 // for threads 1 -> HighThreadThreshold
|
||||
#define ShortIdleTimeoutSeconds 60 // for threads HighThreadThreshold+1 -> MAX_RESOLVER_THREADS
|
||||
|
||||
PR_STATIC_ASSERT (HighThreadThreshold <= MAX_RESOLVER_THREADS);
|
||||
#define MAX_THREADS 8
|
||||
#define IDLE_TIMEOUT PR_SecondsToInterval(60)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@ -193,7 +173,7 @@ nsHostRecord::Create(const nsHostKey *key, nsHostRecord **result)
|
||||
}
|
||||
|
||||
rec->host = ((char *) rec) + sizeof(nsHostRecord);
|
||||
rec->flags = key->flags;
|
||||
rec->flags = RES_KEY_FLAGS(key->flags);
|
||||
rec->af = key->af;
|
||||
|
||||
rec->_refc = 1; // addref
|
||||
@ -204,7 +184,6 @@ nsHostRecord::Create(const nsHostKey *key, nsHostRecord **result)
|
||||
rec->addr = nsnull;
|
||||
rec->expiration = NowInMinutes();
|
||||
rec->resolving = PR_FALSE;
|
||||
rec->onQueue = PR_FALSE;
|
||||
PR_INIT_CLIST(rec);
|
||||
PR_INIT_CLIST(&rec->callbacks);
|
||||
rec->negative = PR_FALSE;
|
||||
@ -235,7 +214,7 @@ static PLDHashNumber
|
||||
HostDB_HashKey(PLDHashTable *table, const void *key)
|
||||
{
|
||||
const nsHostKey *hk = static_cast<const nsHostKey *>(key);
|
||||
return PL_DHashStringKey(table, hk->host) ^ RES_KEY_FLAGS(hk->flags) ^ hk->af;
|
||||
return PL_DHashStringKey(table, hk->host) ^ hk->flags ^ hk->af;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
@ -247,7 +226,7 @@ HostDB_MatchEntry(PLDHashTable *table,
|
||||
const nsHostKey *hk = static_cast<const nsHostKey *>(key);
|
||||
|
||||
return !strcmp(he->rec->host, hk->host) &&
|
||||
RES_KEY_FLAGS (he->rec->flags) == RES_KEY_FLAGS(hk->flags) &&
|
||||
he->rec->flags == hk->flags &&
|
||||
he->rec->af == hk->af;
|
||||
}
|
||||
|
||||
@ -329,26 +308,14 @@ nsHostResolver::nsHostResolver(PRUint32 maxCacheEntries,
|
||||
, mMaxCacheLifetime(maxCacheLifetime)
|
||||
, mLock(nsnull)
|
||||
, mIdleThreadCV(nsnull)
|
||||
, mNumIdleThreads(0)
|
||||
, mHaveIdleThread(PR_FALSE)
|
||||
, mThreadCount(0)
|
||||
, mAnyPriorityThreadCount(0)
|
||||
, mEvictionQSize(0)
|
||||
, mPendingCount(0)
|
||||
, mShutdown(PR_TRUE)
|
||||
{
|
||||
mCreationTime = PR_Now();
|
||||
PR_INIT_CLIST(&mHighQ);
|
||||
PR_INIT_CLIST(&mMediumQ);
|
||||
PR_INIT_CLIST(&mLowQ);
|
||||
PR_INIT_CLIST(&mPendingQ);
|
||||
PR_INIT_CLIST(&mEvictionQ);
|
||||
|
||||
mHighPriorityInfo.self = this;
|
||||
mHighPriorityInfo.onlyHighPriority = PR_TRUE;
|
||||
mAnyPriorityInfo.self = this;
|
||||
mAnyPriorityInfo.onlyHighPriority = PR_FALSE;
|
||||
|
||||
mLongIdleTimeout = PR_SecondsToInterval(LongIdleTimeoutSeconds);
|
||||
mShortIdleTimeout = PR_SecondsToInterval(ShortIdleTimeoutSeconds);
|
||||
}
|
||||
|
||||
nsHostResolver::~nsHostResolver()
|
||||
@ -392,29 +359,13 @@ nsHostResolver::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsHostResolver::ClearPendingQueue(PRCList *aPendingQ)
|
||||
{
|
||||
// loop through pending queue, erroring out pending lookups.
|
||||
if (!PR_CLIST_IS_EMPTY(aPendingQ)) {
|
||||
PRCList *node = aPendingQ->next;
|
||||
while (node != aPendingQ) {
|
||||
nsHostRecord *rec = static_cast<nsHostRecord *>(node);
|
||||
node = node->next;
|
||||
OnLookupComplete(rec, NS_ERROR_ABORT, nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHostResolver::Shutdown()
|
||||
{
|
||||
LOG(("nsHostResolver::Shutdown\n"));
|
||||
|
||||
PRCList pendingQHigh, pendingQMed, pendingQLow, evictionQ;
|
||||
PR_INIT_CLIST(&pendingQHigh);
|
||||
PR_INIT_CLIST(&pendingQMed);
|
||||
PR_INIT_CLIST(&pendingQLow);
|
||||
PRCList pendingQ, evictionQ;
|
||||
PR_INIT_CLIST(&pendingQ);
|
||||
PR_INIT_CLIST(&evictionQ);
|
||||
|
||||
{
|
||||
@ -422,23 +373,26 @@ nsHostResolver::Shutdown()
|
||||
|
||||
mShutdown = PR_TRUE;
|
||||
|
||||
MoveCList(mHighQ, pendingQHigh);
|
||||
MoveCList(mMediumQ, pendingQMed);
|
||||
MoveCList(mLowQ, pendingQLow);
|
||||
MoveCList(mPendingQ, pendingQ);
|
||||
MoveCList(mEvictionQ, evictionQ);
|
||||
mEvictionQSize = 0;
|
||||
mPendingCount = 0;
|
||||
|
||||
if (mNumIdleThreads)
|
||||
|
||||
if (mHaveIdleThread)
|
||||
PR_NotifyCondVar(mIdleThreadCV);
|
||||
|
||||
// empty host database
|
||||
PL_DHashTableEnumerate(&mDB, HostDB_RemoveEntry, nsnull);
|
||||
}
|
||||
|
||||
ClearPendingQueue(&pendingQHigh);
|
||||
ClearPendingQueue(&pendingQMed);
|
||||
ClearPendingQueue(&pendingQLow);
|
||||
|
||||
// loop through pending queue, erroring out pending lookups.
|
||||
if (!PR_CLIST_IS_EMPTY(&pendingQ)) {
|
||||
PRCList *node = pendingQ.next;
|
||||
while (node != &pendingQ) {
|
||||
nsHostRecord *rec = static_cast<nsHostRecord *>(node);
|
||||
node = node->next;
|
||||
OnLookupComplete(rec, NS_ERROR_ABORT, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&evictionQ)) {
|
||||
PRCList *node = evictionQ.next;
|
||||
@ -451,33 +405,6 @@ nsHostResolver::Shutdown()
|
||||
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
IsHighPriority(PRUint16 flags)
|
||||
{
|
||||
return !(flags & (nsHostResolver::RES_PRIORITY_LOW | nsHostResolver::RES_PRIORITY_MEDIUM));
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
IsMediumPriority(PRUint16 flags)
|
||||
{
|
||||
return flags & nsHostResolver::RES_PRIORITY_MEDIUM;
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
IsLowPriority(PRUint16 flags)
|
||||
{
|
||||
return flags & nsHostResolver::RES_PRIORITY_LOW;
|
||||
}
|
||||
|
||||
void
|
||||
nsHostResolver::MoveQueue(nsHostRecord *aRec, PRCList &aDestQ)
|
||||
{
|
||||
NS_ASSERTION(aRec->onQueue, "Moving Host Record Not Currently Queued");
|
||||
|
||||
PR_REMOVE_LINK(aRec);
|
||||
PR_APPEND_LINK(aRec, &aDestQ);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHostResolver::ResolveHost(const char *host,
|
||||
PRUint16 flags,
|
||||
@ -557,38 +484,16 @@ nsHostResolver::ResolveHost(const char *host,
|
||||
// put reference to host record on stack...
|
||||
result = he->rec;
|
||||
}
|
||||
else if (mPendingCount >= MAX_NON_PRIORITY_REQUESTS &&
|
||||
!IsHighPriority(flags) &&
|
||||
!he->rec->resolving) {
|
||||
// This is a lower priority request and we are swamped, so refuse it.
|
||||
rv = NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
|
||||
}
|
||||
// otherwise, hit the resolver...
|
||||
else {
|
||||
// Add callback to the list of pending callbacks.
|
||||
// add callback to the list of pending callbacks
|
||||
PR_APPEND_LINK(callback, &he->rec->callbacks);
|
||||
|
||||
if (!he->rec->resolving) {
|
||||
he->rec->flags = flags;
|
||||
rv = IssueLookup(he->rec);
|
||||
if (NS_FAILED(rv))
|
||||
PR_REMOVE_AND_INIT_LINK(callback);
|
||||
}
|
||||
else if (he->rec->onQueue) {
|
||||
// Consider the case where we are on a pending queue of
|
||||
// lower priority than the request is being made at.
|
||||
// In that case we should upgrade to the higher queue.
|
||||
|
||||
if (IsHighPriority(flags) && !IsHighPriority(he->rec->flags)) {
|
||||
// Move from (low|med) to high.
|
||||
MoveQueue(he->rec, mHighQ);
|
||||
he->rec->flags = flags;
|
||||
} else if (IsMediumPriority(flags) && IsLowPriority(he->rec->flags)) {
|
||||
// Move from low to med.
|
||||
MoveQueue(he->rec, mMediumQ);
|
||||
he->rec->flags = flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -637,57 +542,35 @@ nsHostResolver::IssueLookup(nsHostRecord *rec)
|
||||
{
|
||||
NS_ASSERTION(!rec->resolving, "record is already being resolved");
|
||||
|
||||
// Add rec to one of the pending queues, possibly removing it from mEvictionQ.
|
||||
// If rec is on mEvictionQ, then we can just move the owning
|
||||
// reference over to the new active queue.
|
||||
// add rec to mPendingQ, possibly removing it from mEvictionQ.
|
||||
// if rec is on mEvictionQ, then we can just move the owning
|
||||
// reference over to mPendingQ.
|
||||
if (rec->next == rec)
|
||||
NS_ADDREF(rec);
|
||||
else {
|
||||
PR_REMOVE_LINK(rec);
|
||||
mEvictionQSize--;
|
||||
}
|
||||
|
||||
if (IsHighPriority(rec->flags))
|
||||
PR_APPEND_LINK(rec, &mHighQ);
|
||||
else if (IsMediumPriority(rec->flags))
|
||||
PR_APPEND_LINK(rec, &mMediumQ);
|
||||
else
|
||||
PR_APPEND_LINK(rec, &mLowQ);
|
||||
mPendingCount++;
|
||||
|
||||
PR_APPEND_LINK(rec, &mPendingQ);
|
||||
rec->resolving = PR_TRUE;
|
||||
rec->onQueue = PR_TRUE;
|
||||
|
||||
if (mNumIdleThreads) {
|
||||
if (mHaveIdleThread) {
|
||||
// wake up idle thread to process this lookup
|
||||
PR_NotifyCondVar(mIdleThreadCV);
|
||||
}
|
||||
else if ((mThreadCount < HighThreadThreshold) ||
|
||||
(IsHighPriority(rec->flags) && mThreadCount < MAX_RESOLVER_THREADS)) {
|
||||
else if (mThreadCount < MAX_THREADS) {
|
||||
// dispatch new worker thread
|
||||
NS_ADDREF_THIS(); // owning reference passed to thread
|
||||
|
||||
struct nsHostResolverThreadInfo *info;
|
||||
|
||||
if (mAnyPriorityThreadCount < HighThreadThreshold) {
|
||||
info = &mAnyPriorityInfo;
|
||||
mAnyPriorityThreadCount++;
|
||||
}
|
||||
else
|
||||
info = &mHighPriorityInfo;
|
||||
|
||||
mThreadCount++;
|
||||
PRThread *thr = PR_CreateThread(PR_SYSTEM_THREAD,
|
||||
ThreadFunc,
|
||||
info,
|
||||
this,
|
||||
PR_PRIORITY_NORMAL,
|
||||
PR_GLOBAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD,
|
||||
0);
|
||||
if (!thr) {
|
||||
mThreadCount--;
|
||||
if (info == &mAnyPriorityInfo)
|
||||
mAnyPriorityThreadCount--;
|
||||
NS_RELEASE_THIS();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -700,54 +583,25 @@ nsHostResolver::IssueLookup(nsHostRecord *rec)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsHostResolver::DeQueue(PRCList &aQ, nsHostRecord **aResult)
|
||||
{
|
||||
*aResult = static_cast<nsHostRecord *>(aQ.next);
|
||||
PR_REMOVE_AND_INIT_LINK(*aResult);
|
||||
mPendingCount--;
|
||||
(*aResult)->onQueue = PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHostResolver::GetHostToLookup(nsHostRecord **result, struct nsHostResolverThreadInfo *aID)
|
||||
nsHostResolver::GetHostToLookup(nsHostRecord **result)
|
||||
{
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
PRIntervalTime start = PR_IntervalNow(), timeout;
|
||||
|
||||
while (!mShutdown) {
|
||||
// remove next record from Q; hand over owning reference. Check high, then med, then low
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&mHighQ)) {
|
||||
DeQueue (mHighQ, result);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (! aID->onlyHighPriority) {
|
||||
if (!PR_CLIST_IS_EMPTY(&mMediumQ)) {
|
||||
DeQueue (mMediumQ, result);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&mLowQ)) {
|
||||
DeQueue (mLowQ, result);
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
timeout = (mNumIdleThreads >= HighThreadThreshold) ? mShortIdleTimeout : mLongIdleTimeout;
|
||||
// wait for one or more of the following to occur:
|
||||
// (1) the pending queue has a host record to process
|
||||
// (2) the shutdown flag has been set
|
||||
// (3) the thread has been idle for too long
|
||||
//
|
||||
// PR_WaitCondVar will return when any of these conditions is true.
|
||||
PRIntervalTime start = PR_IntervalNow(), timeout = IDLE_TIMEOUT;
|
||||
//
|
||||
// wait for one or more of the following to occur:
|
||||
// (1) the pending queue has a host record to process
|
||||
// (2) the shutdown flag has been set
|
||||
// (3) the thread has been idle for too long
|
||||
//
|
||||
// PR_WaitCondVar will return when any of these conditions is true.
|
||||
//
|
||||
while (PR_CLIST_IS_EMPTY(&mPendingQ) && !mHaveIdleThread && !mShutdown) {
|
||||
// become the idle thread and wait for a lookup
|
||||
|
||||
mNumIdleThreads++;
|
||||
mHaveIdleThread = PR_TRUE;
|
||||
PR_WaitCondVar(mIdleThreadCV, timeout);
|
||||
mNumIdleThreads--;
|
||||
mHaveIdleThread = PR_FALSE;
|
||||
|
||||
PRIntervalTime delta = PR_IntervalNow() - start;
|
||||
if (delta >= timeout)
|
||||
@ -756,10 +610,15 @@ nsHostResolver::GetHostToLookup(nsHostRecord **result, struct nsHostResolverThre
|
||||
start += delta;
|
||||
}
|
||||
|
||||
if (!PR_CLIST_IS_EMPTY(&mPendingQ)) {
|
||||
// remove next record from mPendingQ; hand over owning reference.
|
||||
*result = static_cast<nsHostRecord *>(mPendingQ.next);
|
||||
PR_REMOVE_AND_INIT_LINK(*result);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// tell thread to exit...
|
||||
mThreadCount--;
|
||||
if (!aID->onlyHighPriority)
|
||||
mAnyPriorityThreadCount--;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -838,11 +697,11 @@ nsHostResolver::ThreadFunc(void *arg)
|
||||
#if defined(RES_RETRY_ON_FAILURE)
|
||||
nsResState rs;
|
||||
#endif
|
||||
struct nsHostResolverThreadInfo *info = (struct nsHostResolverThreadInfo *) arg;
|
||||
nsHostResolver *resolver = info->self;
|
||||
|
||||
nsHostResolver *resolver = (nsHostResolver *) arg;
|
||||
nsHostRecord *rec;
|
||||
PRAddrInfo *ai;
|
||||
while (resolver->GetHostToLookup(&rec, info)) {
|
||||
while (resolver->GetHostToLookup(&rec)) {
|
||||
LOG(("resolving %s ...\n", rec->host));
|
||||
|
||||
PRIntn flags = PR_AI_ADDRCONFIG;
|
||||
|
@ -68,11 +68,6 @@ class nsResolveHostCallback;
|
||||
return n; \
|
||||
}
|
||||
|
||||
#define MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY 5
|
||||
#define MAX_RESOLVER_THREADS_FOR_HIGH_PRIORITY 3
|
||||
#define MAX_RESOLVER_THREADS (MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY + \
|
||||
MAX_RESOLVER_THREADS_FOR_HIGH_PRIORITY)
|
||||
|
||||
struct nsHostKey
|
||||
{
|
||||
const char *host;
|
||||
@ -129,9 +124,6 @@ private:
|
||||
PRBool resolving; /* true if this record is being resolved, which means
|
||||
* that it is either on the pending queue or owned by
|
||||
* one of the worker threads. */
|
||||
|
||||
PRBool onQueue; /* true if pending and on the queue (not yet given to getaddrinfo())*/
|
||||
|
||||
|
||||
~nsHostRecord();
|
||||
};
|
||||
@ -165,16 +157,6 @@ public:
|
||||
nsresult status) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* nsHostResolverThreadInfo structures are passed to the resolver
|
||||
* thread.
|
||||
*/
|
||||
struct nsHostResolverThreadInfo
|
||||
{
|
||||
nsHostResolver *self;
|
||||
PRBool onlyHighPriority;
|
||||
};
|
||||
|
||||
/**
|
||||
* nsHostResolver - an asynchronous host name resolver.
|
||||
*/
|
||||
@ -232,47 +214,32 @@ public:
|
||||
*/
|
||||
enum {
|
||||
RES_BYPASS_CACHE = 1 << 0,
|
||||
RES_CANON_NAME = 1 << 1,
|
||||
RES_PRIORITY_MEDIUM = 1 << 2,
|
||||
RES_PRIORITY_LOW = 1 << 3
|
||||
RES_CANON_NAME = 1 << 1
|
||||
};
|
||||
|
||||
private:
|
||||
nsHostResolver(PRUint32 maxCacheEntries=50, PRUint32 maxCacheLifetime=1);
|
||||
~nsHostResolver();
|
||||
|
||||
// nsHostResolverThreadInfo * is passed to the ThreadFunc
|
||||
struct nsHostResolverThreadInfo mHighPriorityInfo, mAnyPriorityInfo;
|
||||
|
||||
nsresult Init();
|
||||
nsresult IssueLookup(nsHostRecord *);
|
||||
PRBool GetHostToLookup(nsHostRecord **m, struct nsHostResolverThreadInfo *aID);
|
||||
PRBool GetHostToLookup(nsHostRecord **);
|
||||
void OnLookupComplete(nsHostRecord *, nsresult, PRAddrInfo *);
|
||||
void DeQueue(PRCList &aQ, nsHostRecord **aResult);
|
||||
void ClearPendingQueue(PRCList *aPendingQueue);
|
||||
|
||||
static void MoveQueue(nsHostRecord *aRec, PRCList &aDestQ);
|
||||
|
||||
static void ThreadFunc(void *);
|
||||
|
||||
PRUint32 mMaxCacheEntries;
|
||||
PRUint32 mMaxCacheLifetime;
|
||||
PRLock *mLock;
|
||||
PRCondVar *mIdleThreadCV; // non-null if idle thread
|
||||
PRUint32 mNumIdleThreads;
|
||||
PRBool mHaveIdleThread;
|
||||
PRUint32 mThreadCount;
|
||||
PRUint32 mAnyPriorityThreadCount;
|
||||
PLDHashTable mDB;
|
||||
PRCList mHighQ;
|
||||
PRCList mMediumQ;
|
||||
PRCList mLowQ;
|
||||
PRCList mPendingQ;
|
||||
PRCList mEvictionQ;
|
||||
PRUint32 mEvictionQSize;
|
||||
PRUint32 mPendingCount;
|
||||
PRTime mCreationTime;
|
||||
PRBool mShutdown;
|
||||
PRIntervalTime mLongIdleTimeout;
|
||||
PRIntervalTime mShortIdleTimeout;
|
||||
};
|
||||
|
||||
#endif // nsHostResolver_h__
|
||||
|
@ -104,10 +104,6 @@ typedef PRUint8 nsHttpVersion;
|
||||
// preventing it from being reclaimed, even after the transaction completes.
|
||||
#define NS_HTTP_STICKY_CONNECTION (1<<2)
|
||||
|
||||
// a transaction with this caps flag will, upon opening a new connection,
|
||||
// bypass the local DNS cache
|
||||
#define NS_HTTP_REFRESH_DNS (1<<3)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// some default values
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -81,7 +81,6 @@
|
||||
#include "nsIOService.h"
|
||||
#include "nsAuthInformationHolder.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsDNSPrefetch.h"
|
||||
|
||||
// True if the local cache should be bypassed when processing a request.
|
||||
#define BYPASS_LOCAL_CACHE(loadFlags) \
|
||||
@ -3994,13 +3993,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Start a DNS lookup very early in case the real open is queued the DNS can
|
||||
// happen in parallel.
|
||||
nsRefPtr<nsDNSPrefetch> prefetch = new nsDNSPrefetch(mURI);
|
||||
if (prefetch) {
|
||||
prefetch->PrefetchMedium();
|
||||
}
|
||||
|
||||
// Remember the cookie header that was set, if any
|
||||
const char *cookieHeader = mRequestHead.PeekHeader(nsHttp::Cookie);
|
||||
if (cookieHeader)
|
||||
@ -4018,10 +4010,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
|
||||
if (mRequestHead.HasHeaderValue(nsHttp::Connection, "close"))
|
||||
mCaps &= ~(NS_HTTP_ALLOW_KEEPALIVE | NS_HTTP_ALLOW_PIPELINING);
|
||||
|
||||
if ((mLoadFlags & VALIDATE_ALWAYS) ||
|
||||
(BYPASS_LOCAL_CACHE(mLoadFlags)))
|
||||
mCaps |= NS_HTTP_REFRESH_DNS;
|
||||
|
||||
mIsPending = PR_TRUE;
|
||||
mWasOpened = PR_TRUE;
|
||||
|
||||
|
@ -140,7 +140,7 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps)
|
||||
|
||||
// if we don't have a socket transport then create a new one
|
||||
if (!mSocketTransport) {
|
||||
rv = CreateTransport(caps);
|
||||
rv = CreateTransport();
|
||||
if (NS_FAILED(rv))
|
||||
goto loser;
|
||||
}
|
||||
@ -424,7 +424,7 @@ nsHttpConnection::ResumeRecv()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
nsHttpConnection::CreateTransport(PRUint8 caps)
|
||||
nsHttpConnection::CreateTransport()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -452,9 +452,6 @@ nsHttpConnection::CreateTransport(PRUint8 caps)
|
||||
getter_AddRefs(strans));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (caps & NS_HTTP_REFRESH_DNS)
|
||||
strans->SetConnectionFlags(nsISocketTransport::BYPASS_CACHE);
|
||||
|
||||
// NOTE: these create cyclical references, which we break inside
|
||||
// nsHttpConnection::Close
|
||||
rv = strans->SetEventSink(this, nsnull);
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
// called to cause the underlying socket to start speaking SSL
|
||||
nsresult ProxyStartSSL();
|
||||
|
||||
nsresult CreateTransport(PRUint8 caps);
|
||||
nsresult CreateTransport();
|
||||
nsresult OnTransactionDone(nsresult reason);
|
||||
nsresult OnSocketWritable();
|
||||
nsresult OnSocketReadable();
|
||||
|
Loading…
Reference in New Issue
Block a user