From 47b6e78790be5a4b7d8a0f4c860f1e2f6f87b137 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Jun 2013 21:34:20 +0100 Subject: Implement logging of first 80 characters (debug level 5) or full body data (debug level 6) on outgoing requests, depending on debug level This is set via "debug http out " This matches the existing debug level behaviours for logging incoming http data --- OpenSim/Framework/WebUtil.cs | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 701fbb0..4599f62 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -151,6 +151,39 @@ namespace OpenSim.Framework } } + public static void LogOutgoingDetail(Stream outputStream) + { + using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8)) + { + string output; + + if (DebugLevel == 5) + { + const int sampleLength = 80; + char[] sampleChars = new char[sampleLength]; + reader.Read(sampleChars, 0, sampleLength); + output = new string(sampleChars); + } + else + { + output = reader.ReadToEnd(); + } + + LogOutgoingDetail(output); + } + } + + public static void LogOutgoingDetail(string output) + { + if (DebugLevel == 5) + { + output = output.Substring(0, 80); + output = output + "..."; + } + + m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n")); + } + private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) { int reqnum = RequestNumber++; @@ -178,7 +211,11 @@ namespace OpenSim.Framework // If there is some input, write it into the request if (data != null) { - strBuffer = OSDParser.SerializeJsonString(data); + strBuffer = OSDParser.SerializeJsonString(data); + + if (DebugLevel >= 5) + LogOutgoingDetail(strBuffer); + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); if (compressed) @@ -357,6 +394,10 @@ namespace OpenSim.Framework if (data != null) { queryString = BuildQueryString(data); + + if (DebugLevel >= 5) + LogOutgoingDetail(queryString); + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); request.ContentLength = buffer.Length; @@ -767,6 +808,9 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + request.BeginGetRequestStream(delegate(IAsyncResult res) { Stream requestStream = request.EndGetRequestStream(res); @@ -954,6 +998,9 @@ namespace OpenSim.Framework length = (int)obj.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + Stream requestStream = null; try { @@ -1096,6 +1143,9 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; + if (WebUtil.DebugLevel >= 5) + WebUtil.LogOutgoingDetail(buffer); + Stream requestStream = null; try { @@ -1198,4 +1248,4 @@ namespace OpenSim.Framework return deserial; } } -} +} \ No newline at end of file -- cgit v1.1 From 00093a305d225c98ffe00b656df7943cb50c42b0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 29 Jun 2013 18:35:23 -0700 Subject: Changed HG status notifications timeout down to 15secs from the default 100. --- OpenSim/Framework/WebUtil.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 4599f62..6fb1e0c 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -962,11 +962,12 @@ namespace OpenSim.Framework /// /// /// + /// /// /// /// Thrown if we encounter a network issue while posting /// the request. You'll want to make sure you deal with this as they're not uncommon - public static string MakeRequest(string verb, string requestUrl, string obj) + public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs) { int reqnum = WebUtil.RequestNumber++; @@ -980,6 +981,8 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + if (timeoutsecs > 0) + request.Timeout = timeoutsecs * 1000; string respstring = String.Empty; using (MemoryStream buffer = new MemoryStream()) @@ -1073,6 +1076,11 @@ namespace OpenSim.Framework return respstring; } + + public static string MakeRequest(string verb, string requestUrl, string obj) + { + return MakeRequest(verb, requestUrl, obj, -1); + } } public class SynchronousRestObjectRequester -- cgit v1.1 From c95a23863ab51810ccc01afd3dd641c18a183305 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jul 2013 13:13:52 -0700 Subject: WARNING: BRUTE FORCE DEBUG. AVOID USING THIS COMMIT. --- OpenSim/Framework/WebUtil.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 6fb1e0c..ece3129 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1061,6 +1061,7 @@ namespace OpenSim.Framework int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > WebUtil.LongCallTime) + { m_log.InfoFormat( "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, @@ -1069,6 +1070,9 @@ namespace OpenSim.Framework tickdiff, tickdata, obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); + Util.PrintCallStack(); + + } else if (WebUtil.DebugLevel >= 4) m_log.DebugFormat( "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", -- cgit v1.1 From 33ddb6c246e7a3b8670b759e0799884520b12e9d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 4 Jul 2013 13:25:58 -0700 Subject: Revert "WARNING: BRUTE FORCE DEBUG. AVOID USING THIS COMMIT." This reverts commit c95a23863ab51810ccc01afd3dd641c18a183305. --- OpenSim/Framework/WebUtil.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index ece3129..6fb1e0c 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -1061,7 +1061,6 @@ namespace OpenSim.Framework int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > WebUtil.LongCallTime) - { m_log.InfoFormat( "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, @@ -1070,9 +1069,6 @@ namespace OpenSim.Framework tickdiff, tickdata, obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); - Util.PrintCallStack(); - - } else if (WebUtil.DebugLevel >= 4) m_log.DebugFormat( "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", -- cgit v1.1 From 5198df3aa03eb47bc26b3c86924687612c015dce Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 2 Aug 2013 17:00:18 -0700 Subject: Issue: 10 simultaneous TPs, many not making it. Now bypassing the per-url lock -- we should be "ok" (or, more "ok") now that we have increased the connection limit on the http library. But this is a sensitive part of the code, so it may need reverting. --- OpenSim/Framework/WebUtil.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 6fb1e0c..0e9de59 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -145,10 +145,10 @@ namespace OpenSim.Framework public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) { - lock (EndPointLock(url)) - { + //lock (EndPointLock(url)) + //{ return ServiceOSDRequestWorker(url,data,method,timeout,compressed); - } + //} } public static void LogOutgoingDetail(Stream outputStream) -- cgit v1.1 From 9bcf07279513294d58c3076e7d8a6eb5ee64c759 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Aug 2013 23:44:48 +0100 Subject: Make it possible to switch whether we serialize osd requests per endpoint or not, either via config (SerializeOSDRequests in [Network]) or via the "debug comms set" console command. For debug purposes to assess what impact this has on network response in a heavy test environment. --- OpenSim/Framework/WebUtil.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 0e9de59..706b33f 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -67,6 +67,11 @@ namespace OpenSim.Framework public static int RequestNumber { get; internal set; } /// + /// Control where OSD requests should be serialized per endpoint. + /// + public static bool SerializeOSDRequestsPerEndpoint { get; set; } + + /// /// this is the header field used to communicate the local request id /// used for performance and debugging /// @@ -145,10 +150,17 @@ namespace OpenSim.Framework public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) { - //lock (EndPointLock(url)) - //{ - return ServiceOSDRequestWorker(url,data,method,timeout,compressed); - //} + if (SerializeOSDRequestsPerEndpoint) + { + lock (EndPointLock(url)) + { + return ServiceOSDRequestWorker(url, data, method, timeout, compressed); + } + } + else + { + return ServiceOSDRequestWorker(url, data, method, timeout, compressed); + } } public static void LogOutgoingDetail(Stream outputStream) -- cgit v1.1 From 7cab41f4223b7febd3fdd42fa7cfefef25e4a9c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Nov 2013 21:45:08 +0000 Subject: refactor: replace verbose checks with String.IsNullOrEmpty where applicable. Thanks to Kira for this patch from http://opensimulator.org/mantis/view.php?id=6845 --- OpenSim/Framework/WebUtil.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/WebUtil.cs') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 706b33f..bcf6af8 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -720,7 +720,7 @@ namespace OpenSim.Framework /// public static string[] GetPreferredImageTypes(string accept) { - if (accept == null || accept == string.Empty) + if (string.IsNullOrEmpty(accept)) return new string[0]; string[] types = accept.Split(new char[] { ',' }); -- cgit v1.1