From 9f93bef1110e4f0152713e0ff0472bc55890d962 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 00:15:10 +0200 Subject: Allow setting connection limits, part 2 --- OpenSim/Framework/WebUtil.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 6a40cd5..8094b6d 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -695,6 +695,13 @@ namespace OpenSim.Framework public static void MakeRequest(string verb, string requestUrl, TRequest obj, Action action) { + MakeRequest(verb, requestUrl, obj, action, 0); + } + + public static void MakeRequest(string verb, + string requestUrl, TRequest obj, Action action, + int maxConnections) + { int reqnum = WebUtil.RequestNumber++; // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); @@ -706,6 +713,10 @@ namespace OpenSim.Framework Type type = typeof(TRequest); WebRequest request = WebRequest.Create(requestUrl); + HttpWebRequest ht = (HttpWebRequest)request; + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) + ht.ServicePoint.ConnectionLimit = maxConnections; + WebResponse response = null; TResponse deserial = default(TResponse); XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); @@ -1003,6 +1014,11 @@ namespace OpenSim.Framework public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout) { + return MakeRequest(verb, requestUrl, obj, pTimeout, 0); + } + + public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) + { int reqnum = WebUtil.RequestNumber++; // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); @@ -1013,6 +1029,10 @@ namespace OpenSim.Framework TResponse deserial = default(TResponse); WebRequest request = WebRequest.Create(requestUrl); + HttpWebRequest ht = (HttpWebRequest)request; + if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) + ht.ServicePoint.ConnectionLimit = maxConnections; + request.Method = verb; if (pTimeout != 0) request.Timeout = pTimeout * 1000; -- cgit v1.1