diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index af25da9b04..77f3d9b733 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 /// @@ -95,6 +120,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); @@ -247,6 +280,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";