Introduce Settings.HTTP_MAX_CONNECTIONS to regulate maximum connections to specific endpoints for capability requests.
Previously, CapsBase.SetupRequest() hardcoded this to 32 and DownloadManager.ParallelDownloads was setting this with a default value of 8. This meant that the ConnectionLimit would oscillate rapidly between these two figures as requests were made. On Mono 3.2.8 and quite possibly other Mono, this appears to increase the chance that the VM will crash under heavy request load. This commit makes both SetupRequest() calls use the static Settings.HTTP_MAX_CONNECTIONS - other static settings already exist, and so also makes this configurable. DownloadManager.ParallelDownloads remains a separate setting since it also governs max parallel downloads through a separate coded mechanism.
This commit is contained in:
@@ -127,7 +127,6 @@ namespace OpenMetaverse.Http
|
||||
ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, TimeoutCallback, state, millisecondsTimeout, true);
|
||||
}
|
||||
|
||||
|
||||
static HttpWebRequest SetupRequest(Uri address, X509Certificate2 clientCert)
|
||||
{
|
||||
if (address == null)
|
||||
@@ -144,8 +143,16 @@ namespace OpenMetaverse.Http
|
||||
request.ServicePoint.MaxIdleTime = 1000 * 60;
|
||||
// Disable stupid Expect-100: Continue header
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
// Crank up the max number of connections per endpoint (default is 2!)
|
||||
request.ServicePoint.ConnectionLimit = Math.Max(request.ServicePoint.ConnectionLimit, 32);
|
||||
// Crank up the max number of connections per endpoint
|
||||
// We set this manually here instead of in ServicePointManager to avoid intereference with callers.
|
||||
if (request.ServicePoint.ConnectionLimit < Settings.MAX_HTTP_CONNECTIONS)
|
||||
{
|
||||
Logger.Log(
|
||||
string.Format(
|
||||
"In CapsBase.SetupRequest() setting conn limit for {0}:{1} to {2}",
|
||||
address.Host, address.Port, Settings.MAX_HTTP_CONNECTIONS), Helpers.LogLevel.Debug);
|
||||
request.ServicePoint.ConnectionLimit = Settings.MAX_HTTP_CONNECTIONS;
|
||||
}
|
||||
// Caps requests are never sent as trickles of data, so Nagle's
|
||||
// coalescing algorithm won't help us
|
||||
request.ServicePoint.UseNagleAlgorithm = false;
|
||||
|
||||
@@ -88,15 +88,10 @@ namespace OpenMetaverse
|
||||
Queue<DownloadRequest> queue = new Queue<DownloadRequest>();
|
||||
Dictionary<string, ActiveDownload> activeDownloads = new Dictionary<string, ActiveDownload>();
|
||||
|
||||
int m_ParallelDownloads = 8;
|
||||
X509Certificate2 m_ClientCert;
|
||||
|
||||
/// <summary>Maximum number of parallel downloads from a single endpoint</summary>
|
||||
public int ParallelDownloads
|
||||
{
|
||||
get { return m_ParallelDownloads; }
|
||||
set { m_ParallelDownloads = value; }
|
||||
}
|
||||
public int ParallelDownloads { get; set; }
|
||||
|
||||
/// <summary>Client certificate</summary>
|
||||
public X509Certificate2 ClientCert
|
||||
@@ -147,8 +142,12 @@ namespace OpenMetaverse
|
||||
request.ServicePoint.MaxIdleTime = 0;
|
||||
// Disable stupid Expect-100: Continue header
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
// Crank up the max number of connections per endpoint (default is 2!)
|
||||
request.ServicePoint.ConnectionLimit = m_ParallelDownloads;
|
||||
// Crank up the max number of connections per endpoint
|
||||
if (request.ServicePoint.ConnectionLimit < Settings.MAX_HTTP_CONNECTIONS)
|
||||
{
|
||||
Logger.Log(string.Format("In DownloadManager.SetupRequest() setting conn limit for {0}:{1} to {2}", address.Host, address.Port, Settings.MAX_HTTP_CONNECTIONS), Helpers.LogLevel.Debug);
|
||||
request.ServicePoint.ConnectionLimit = Settings.MAX_HTTP_CONNECTIONS;
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,20 @@ namespace OpenMetaverse
|
||||
|
||||
/// <summary>Use XML-RPC Login or LLSD Login, default is XML-RPC Login</summary>
|
||||
public bool USE_LLSD_LOGIN = false;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of HTTP connections to open to a particular endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An endpoint is defined as a commbination of network address and port. This is used for Caps.
|
||||
/// This is a static variable which applies to all instances.
|
||||
/// </remarks>
|
||||
public static int MAX_HTTP_CONNECTIONS = 32;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Inventory
|
||||
|
||||
/// <summary>
|
||||
/// InventoryManager requests inventory information on login,
|
||||
/// GridClient initializes an Inventory store for main inventory.
|
||||
@@ -74,7 +86,9 @@ namespace OpenMetaverse
|
||||
/// Use Caps for fetching inventory where available
|
||||
/// </summary>
|
||||
public bool HTTP_INVENTORY = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Timeouts and Intervals
|
||||
|
||||
/// <summary>Number of milliseconds before an asset transfer will time
|
||||
|
||||
Reference in New Issue
Block a user