From 7b8e9d88e38ed0f7e50c6bfca6e2bbf82855ef09 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 27 Feb 2012 20:04:11 -0800 Subject: Serialize all web requests to a particular host:port pair; only applied to the PostToService variants. --- OpenSim/Framework/WebUtil.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index af25da9..77f3d9b 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -63,6 +63,31 @@ namespace OpenSim.Framework // a "long" call for warning & debugging purposes public const int LongCallTime = 500; + // dictionary of end points + private static Dictionary m_endpointSerializer = new Dictionary(); + + + private static object EndPointLock(string url) + { + System.Uri uri = new System.Uri(url); + string endpoint = string.Format("{0}:{1}",uri.Host,uri.Port); + + lock (m_endpointSerializer) + { + object eplock = null; + + if (! m_endpointSerializer.TryGetValue(endpoint,out eplock)) + { + eplock = new object(); + m_endpointSerializer.Add(endpoint,eplock); + // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint); + } + + return eplock; + } + } + + #region JSONRequest /// @@ -96,6 +121,14 @@ 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); + } + } + + private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) + { int reqnum = m_requestNumber++; // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); @@ -248,6 +281,14 @@ namespace OpenSim.Framework public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) { + lock (EndPointLock(url)) + { + return ServiceFormRequestWorker(url,data,timeout); + } + } + + private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout) + { int reqnum = m_requestNumber++; string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); -- cgit v1.1