From 52d74cf274fbf002e7ec6ad82fe1a38dc2c02d59 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 00:11:23 +0200 Subject: Allow setting max connections for an endpoint --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 7384e39..57c9d7c 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -640,7 +640,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Every month or so this will wrap and give bad numbers, not really a problem // since its just for reporting int tickdiff = requestEndTick - requestStartTick; - if (tickdiff > 3000) + if (tickdiff > 3000 && requestHandler.Name != "GetTexture") { m_log.InfoFormat( "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", -- cgit v1.1 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') 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 From 387e59ff7f60f2b12526eaacd93581f76abe26e1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 21:24:25 +0200 Subject: Revamp the HTTP textures handler to allow a maximum of four fetches at any time and to drop requests for avatars n longer in the scene --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 47 +++++++++++++++------- .../Servers/HttpServer/PollServiceEventArgs.cs | 3 +- .../HttpServer/PollServiceRequestManager.cs | 3 +- 3 files changed, 36 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 57c9d7c..6121371 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1449,7 +1449,8 @@ namespace OpenSim.Framework.Servers.HttpServer internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) { int responsecode; - string responseString; + string responseString = String.Empty; + byte[] responseData = null; string contentType; if (responsedata == null) @@ -1465,7 +1466,10 @@ namespace OpenSim.Framework.Servers.HttpServer { //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); responsecode = (int)responsedata["int_response_code"]; - responseString = (string)responsedata["str_response_string"]; + if (responsedata["bin_response_data"] != null) + responseData = (byte[])responsedata["bin_response_data"]; + else + responseString = (string)responsedata["str_response_string"]; contentType = (string)responsedata["content_type"]; } catch @@ -1520,25 +1524,40 @@ namespace OpenSim.Framework.Servers.HttpServer response.AddHeader("Content-Type", contentType); + if (responsedata.ContainsKey("headers")) + { + Hashtable headerdata = (Hashtable)responsedata["headers"]; + + foreach (string header in headerdata.Keys) + response.AddHeader(header, (string)headerdata[header]); + } + byte[] buffer; - if (!(contentType.Contains("image") - || contentType.Contains("x-shockwave-flash") - || contentType.Contains("application/x-oar") - || contentType.Contains("application/vnd.ll.mesh"))) + if (responseData != null) { - // Text - buffer = Encoding.UTF8.GetBytes(responseString); + buffer = responseData; } else { - // Binary! - buffer = Convert.FromBase64String(responseString); - } + if (!(contentType.Contains("image") + || contentType.Contains("x-shockwave-flash") + || contentType.Contains("application/x-oar") + || contentType.Contains("application/vnd.ll.mesh"))) + { + // Text + buffer = Encoding.UTF8.GetBytes(responseString); + } + else + { + // Binary! + buffer = Convert.FromBase64String(responseString); + } - response.SendChunked = false; - response.ContentLength64 = buffer.Length; - response.ContentEncoding = Encoding.UTF8; + response.SendChunked = false; + response.ContentLength64 = buffer.Length; + response.ContentEncoding = Encoding.UTF8; + } return buffer; } diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index c24a000..a80b1d7 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -52,7 +52,8 @@ namespace OpenSim.Framework.Servers.HttpServer { Normal = 0, LslHttp = 1, - Inventory = 2 + Inventory = 2, + Texture = 3 } public PollServiceEventArgs( diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index a1dee4e..db088e7 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -231,8 +231,7 @@ namespace OpenSim.Framework.Servers.HttpServer { if (m_running) { - if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp || - req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Inventory) + if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.Normal) { m_requests.Enqueue(req); } -- cgit v1.1