зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 252118 "necko ignores settings for max-persistent-connections-per-server" r=biesi sr=bzbarsky
This commit is contained in:
Родитель
5b46cda86f
Коммит
de308e6df5
|
@ -1,3 +1,4 @@
|
|||
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -239,6 +240,13 @@ nsHttpConnectionMgr::ReclaimConnection(nsHttpConnection *conn)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpConnectionMgr::UpdateParam(nsParamName name, PRUint16 value)
|
||||
{
|
||||
PRUint32 param = (PRUint32(name) << 16) | PRUint32(value);
|
||||
return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateParam, NS_OK, (void *) param);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpConnectionMgr::ProcessPendingQ(nsHttpConnectionInfo *ci)
|
||||
{
|
||||
|
@ -823,6 +831,39 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(nsresult, void *param)
|
|||
NS_RELEASE(conn);
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionMgr::OnMsgUpdateParam(nsresult status, void *param)
|
||||
{
|
||||
PRUint16 name = (PRUint32(param) & 0xFFFF0000) >> 16;
|
||||
PRUint16 value = PRUint32(param) & 0x0000FFFF;
|
||||
|
||||
switch (name) {
|
||||
case MAX_CONNECTIONS:
|
||||
mMaxConns = value;
|
||||
break;
|
||||
case MAX_CONNECTIONS_PER_HOST:
|
||||
mMaxConnsPerHost = value;
|
||||
break;
|
||||
case MAX_CONNECTIONS_PER_PROXY:
|
||||
mMaxConnsPerProxy = value;
|
||||
break;
|
||||
case MAX_PERSISTENT_CONNECTIONS_PER_HOST:
|
||||
mMaxPersistConnsPerHost = value;
|
||||
break;
|
||||
case MAX_PERSISTENT_CONNECTIONS_PER_PROXY:
|
||||
mMaxPersistConnsPerProxy = value;
|
||||
break;
|
||||
case MAX_REQUEST_DELAY:
|
||||
mMaxRequestDelay = value;
|
||||
break;
|
||||
case MAX_PIPELINED_REQUESTS:
|
||||
mMaxPipelinedRequests = value;
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("unexpected parameter name");
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpConnectionMgr::nsConnectionHandle
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -53,13 +54,24 @@ class nsHttpPipeline;
|
|||
class nsHttpConnectionMgr
|
||||
{
|
||||
public:
|
||||
|
||||
// parameter names
|
||||
enum nsParamName {
|
||||
MAX_CONNECTIONS,
|
||||
MAX_CONNECTIONS_PER_HOST,
|
||||
MAX_CONNECTIONS_PER_PROXY,
|
||||
MAX_PERSISTENT_CONNECTIONS_PER_HOST,
|
||||
MAX_PERSISTENT_CONNECTIONS_PER_PROXY,
|
||||
MAX_REQUEST_DELAY,
|
||||
MAX_PIPELINED_REQUESTS
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// NOTE: functions below may only be called on the main thread.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsHttpConnectionMgr();
|
||||
|
||||
// XXX cleanup the way we pass around prefs.
|
||||
nsresult Init(PRUint16 maxConnections,
|
||||
PRUint16 maxConnectionsPerHost,
|
||||
PRUint16 maxConnectionsPerProxy,
|
||||
|
@ -105,6 +117,10 @@ public:
|
|||
// it will be closed.
|
||||
nsresult ReclaimConnection(nsHttpConnection *conn);
|
||||
|
||||
// called to update a parameter after the connection manager has already
|
||||
// been initialized.
|
||||
nsresult UpdateParam(nsParamName name, PRUint16 value);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// NOTE: functions below may be called only on the socket thread.
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -252,6 +268,7 @@ private:
|
|||
void OnMsgProcessPendingQ (nsresult status, void *param);
|
||||
void OnMsgPruneDeadConnections (nsresult status, void *param);
|
||||
void OnMsgReclaimConnection (nsresult status, void *param);
|
||||
void OnMsgUpdateParam (nsresult status, void *param);
|
||||
|
||||
// counters
|
||||
PRUint16 mNumActiveConns;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -788,32 +789,55 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||
|
||||
if (PREF_CHANGED(HTTP_PREF("request.max-start-delay"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("request.max-start-delay"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxRequestDelay = (PRUint16) CLAMP(val, 0, 0xffff);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_REQUEST_DELAY,
|
||||
mMaxRequestDelay);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("max-connections"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("max-connections"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxConnections = (PRUint16) CLAMP(val, 1, 0xffff);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS,
|
||||
mMaxRequestDelay);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("max-connections-per-server"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("max-connections-per-server"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxConnectionsPerServer = (PRUint8) CLAMP(val, 1, 0xff);
|
||||
if (mConnMgr) {
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS_PER_HOST,
|
||||
mMaxConnectionsPerServer);
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS_PER_PROXY,
|
||||
mMaxConnectionsPerServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-server"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("max-persistent-connections-per-server"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxPersistentConnectionsPerServer = (PRUint8) CLAMP(val, 1, 0xff);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_HOST,
|
||||
mMaxPersistentConnectionsPerServer);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("max-persistent-connections-per-proxy"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("max-persistent-connections-per-proxy"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxPersistentConnectionsPerProxy = (PRUint8) CLAMP(val, 1, 0xff);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_PERSISTENT_CONNECTIONS_PER_PROXY,
|
||||
mMaxPersistentConnectionsPerProxy);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("sendRefererHeader"))) {
|
||||
|
@ -887,8 +911,12 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
|||
|
||||
if (PREF_CHANGED(HTTP_PREF("pipelining.maxrequests"))) {
|
||||
rv = prefs->GetIntPref(HTTP_PREF("pipelining.maxrequests"), &val);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mMaxPipelinedRequests = CLAMP(val, 1, NS_HTTP_MAX_PIPELINED_REQUESTS);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_PIPELINED_REQUESTS,
|
||||
mMaxPipelinedRequests);
|
||||
}
|
||||
}
|
||||
|
||||
if (PREF_CHANGED(HTTP_PREF("proxy.pipelining"))) {
|
||||
|
@ -1548,8 +1576,6 @@ nsHttpHandler::Observe(nsISupports *subject,
|
|||
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(subject);
|
||||
if (prefBranch)
|
||||
PrefsChanged(prefBranch, NS_ConvertUCS2toUTF8(data).get());
|
||||
|
||||
// XXX should probably shutdown and init the conn mgr.
|
||||
}
|
||||
else if (strcmp(topic, "profile-change-net-teardown") == 0 ||
|
||||
strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче