aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/WebUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/WebUtil.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index f90df12..71a56e5 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -63,6 +63,31 @@ namespace OpenSim.Framework
63 // a "long" call for warning & debugging purposes 63 // a "long" call for warning & debugging purposes
64 public const int LongCallTime = 500; 64 public const int LongCallTime = 500;
65 65
66 // dictionary of end points
67 private static Dictionary<string,object> m_endpointSerializer = new Dictionary<string,object>();
68
69
70 private static object EndPointLock(string url)
71 {
72 System.Uri uri = new System.Uri(url);
73 string endpoint = string.Format("{0}:{1}",uri.Host,uri.Port);
74
75 lock (m_endpointSerializer)
76 {
77 object eplock = null;
78
79 if (! m_endpointSerializer.TryGetValue(endpoint,out eplock))
80 {
81 eplock = new object();
82 m_endpointSerializer.Add(endpoint,eplock);
83 // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint);
84 }
85
86 return eplock;
87 }
88 }
89
90
66 #region JSONRequest 91 #region JSONRequest
67 92
68 /// <summary> 93 /// <summary>
@@ -96,6 +121,14 @@ namespace OpenSim.Framework
96 121
97 public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) 122 public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed)
98 { 123 {
124 lock (EndPointLock(url))
125 {
126 return ServiceOSDRequestWorker(url,data,method,timeout,compressed);
127 }
128 }
129
130 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
131 {
99 int reqnum = m_requestNumber++; 132 int reqnum = m_requestNumber++;
100 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 133 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method);
101 134
@@ -249,6 +282,14 @@ namespace OpenSim.Framework
249 282
250 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) 283 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout)
251 { 284 {
285 lock (EndPointLock(url))
286 {
287 return ServiceFormRequestWorker(url,data,timeout);
288 }
289 }
290
291 private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout)
292 {
252 int reqnum = m_requestNumber++; 293 int reqnum = m_requestNumber++;
253 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; 294 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
254 // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); 295 // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method);