aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/Application.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs209
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
4 files changed, 123 insertions, 93 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index ebfebc4..78636c4 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Net;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using log4net.Config; 33using log4net.Config;
@@ -73,6 +74,7 @@ namespace OpenSim
73 AppDomain.CurrentDomain.UnhandledException += 74 AppDomain.CurrentDomain.UnhandledException +=
74 new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 75 new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
75 76
77 ServicePointManager.DefaultConnectionLimit = 6;
76 78
77 // Add the arguments supplied when running the application to the configuration 79 // Add the arguments supplied when running the application to the configuration
78 ArgvConfigSource configSource = new ArgvConfigSource(args); 80 ArgvConfigSource configSource = new ArgvConfigSource(args);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 2475b1f..4908c2c 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using Caps = OpenSim.Framework.Capabilities.Caps; 43using Caps = OpenSim.Framework.Capabilities.Caps;
44using OpenSim.Capabilities.Handlers; 44using OpenSim.Capabilities.Handlers;
45using OpenSim.Framework.Monitoring;
45 46
46namespace OpenSim.Region.ClientStack.Linden 47namespace OpenSim.Region.ClientStack.Linden
47{ 48{
@@ -58,14 +59,13 @@ namespace OpenSim.Region.ClientStack.Linden
58 private IInventoryService m_InventoryService; 59 private IInventoryService m_InventoryService;
59 private ILibraryService m_LibraryService; 60 private ILibraryService m_LibraryService;
60 61
61 private WebFetchInvDescHandler m_webFetchHandler; 62 private static WebFetchInvDescHandler m_webFetchHandler;
62
63// private ManualResetEvent m_ev = new ManualResetEvent(true);
64 private object m_lock = new object();
65 63
66 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 64 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
67 private Dictionary<UUID, Hashtable> m_requests = new Dictionary<UUID, Hashtable>(); 65 private static Thread[] m_workerThreads = null;
68 bool m_busy = false; 66
67 private static OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs> m_queue =
68 new OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs>();
69 69
70 #region ISharedRegionModule Members 70 #region ISharedRegionModule Members
71 71
@@ -95,6 +95,22 @@ namespace OpenSim.Region.ClientStack.Linden
95 95
96 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 96 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
97 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; 97 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
98
99 if (m_workerThreads == null)
100 {
101 m_workerThreads = new Thread[2];
102
103 for (uint i = 0; i < 2; i++)
104 {
105 m_workerThreads[i] = Watchdog.StartThread(DoInventoryRequests,
106 String.Format("InventoryWorkerThread{0}", i),
107 ThreadPriority.Normal,
108 false,
109 true,
110 null,
111 int.MaxValue);
112 }
113 }
98 } 114 }
99 115
100 public void PostInitialise() 116 public void PostInitialise()
@@ -112,13 +128,103 @@ namespace OpenSim.Region.ClientStack.Linden
112 128
113 #endregion 129 #endregion
114 130
131 ~WebFetchInvDescModule()
132 {
133 foreach (Thread t in m_workerThreads)
134 t.Abort();
135 }
136
137 private class PollServiceInventoryEventArgs : PollServiceEventArgs
138 {
139 private List<Hashtable> requests =
140 new List<Hashtable>();
141 private Dictionary<UUID, Hashtable> responses =
142 new Dictionary<UUID, Hashtable>();
143
144 public PollServiceInventoryEventArgs(UUID pId) :
145 base(null, null, null, null, pId, 30000)
146 {
147 HasEvents = (x, y) => { return this.responses.ContainsKey(x); };
148 GetEvents = (x, y, s) =>
149 {
150 try
151 {
152 return this.responses[x];
153 }
154 finally
155 {
156 responses.Remove(x);
157 }
158 };
159
160 Request = (x, y) =>
161 {
162 y["RequestID"] = x.ToString();
163 lock (this.requests)
164 this.requests.Add(y);
165
166 m_queue.Enqueue(this);
167 };
168
169 NoEvents = (x, y) =>
170 {
171 lock (this.requests)
172 {
173 Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
174 requests.Remove(request);
175 }
176
177 Hashtable response = new Hashtable();
178
179 response["int_response_code"] = 500;
180 response["str_response_string"] = "Script timeout";
181 response["content_type"] = "text/plain";
182 response["keepalive"] = false;
183 response["reusecontext"] = false;
184
185 return response;
186 };
187 }
188
189 public void Process()
190 {
191 Hashtable request = null;
192
193 try
194 {
195 lock (this.requests)
196 {
197 request = requests[0];
198 requests.RemoveAt(0);
199 }
200 }
201 catch
202 {
203 return;
204 }
205
206 UUID requestID = new UUID(request["RequestID"].ToString());
207
208 Hashtable response = new Hashtable();
209
210 response["int_response_code"] = 200;
211 response["content_type"] = "text/plain";
212 response["keepalive"] = false;
213 response["reusecontext"] = false;
214
215 response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null);
216
217 responses[requestID] = response;
218 }
219 }
220
115 private void RegisterCaps(UUID agentID, Caps caps) 221 private void RegisterCaps(UUID agentID, Caps caps)
116 { 222 {
117 string capUrl = "/CAPS/" + UUID.Random() + "/"; 223 string capUrl = "/CAPS/" + UUID.Random() + "/";
118 224
119 // Register this as a poll service 225 // Register this as a poll service
120 // absurd large timeout to tune later to make a bit less than viewer 226 // absurd large timeout to tune later to make a bit less than viewer
121 PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); 227 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID);
122 228
123 args.Type = PollServiceEventArgs.EventType.Inventory; 229 args.Type = PollServiceEventArgs.EventType.Inventory;
124 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); 230 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
@@ -136,8 +242,6 @@ namespace OpenSim.Region.ClientStack.Linden
136 caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); 242 caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
137 243
138 m_capsDict[agentID] = capUrl; 244 m_capsDict[agentID] = capUrl;
139
140 m_busy = false;
141 } 245 }
142 246
143 private void DeregisterCaps(UUID agentID, Caps caps) 247 private void DeregisterCaps(UUID agentID, Caps caps)
@@ -151,93 +255,14 @@ namespace OpenSim.Region.ClientStack.Linden
151 } 255 }
152 } 256 }
153 257
154 public void HttpRequestHandler(UUID requestID, Hashtable request) 258 private void DoInventoryRequests()
155 {
156// m_log.DebugFormat("[FETCH2]: Received request {0}", requestID);
157 lock(m_lock)
158 m_requests[requestID] = request;
159 }
160
161 private bool HasEvents(UUID requestID, UUID sessionID)
162 { 259 {
163 lock (m_lock) 260 while (true)
164 { 261 {
165/* 262 PollServiceInventoryEventArgs args = m_queue.Dequeue();
166 if (m_ev.WaitOne(0))
167 {
168 m_ev.Reset();
169 return true;
170 }
171 return false;
172 */
173 return !m_busy;
174 }
175 }
176
177 private Hashtable NoEvents(UUID requestID, UUID sessionID)
178 {
179 lock(m_lock)
180 m_requests.Remove(requestID);
181
182 Hashtable response = new Hashtable();
183
184 response["int_response_code"] = 500;
185 response["str_response_string"] = "Script timeout";
186 response["content_type"] = "text/plain";
187 response["keepalive"] = false;
188 response["reusecontext"] = false;
189 263
190 lock (m_lock) 264 args.Process();
191 m_busy = false;
192
193 return response;
194 }
195
196 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
197 {
198 lock (m_lock)
199 m_busy = true;
200
201 Hashtable response = new Hashtable();
202
203 response["int_response_code"] = 500;
204 response["str_response_string"] = "Internal error";
205 response["content_type"] = "text/plain";
206 response["keepalive"] = false;
207 response["reusecontext"] = false;
208
209 try
210 {
211
212 Hashtable requestHash;
213 lock (m_lock)
214 {
215 if (!m_requests.TryGetValue(requestID, out requestHash))
216 {
217 m_busy = false;
218 // m_ev.Set();
219 response["str_response_string"] = "Invalid request";
220 return response;
221 }
222 m_requests.Remove(requestID);
223 }
224
225// m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID);
226
227 string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null);
228
229
230 response["int_response_code"] = 200;
231 response["str_response_string"] = reply;
232 } 265 }
233 finally
234 {
235 lock (m_lock)
236// m_ev.Set();
237 m_busy = false;
238 }
239
240 return response;
241 } 266 }
242 } 267 }
243} 268}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 1406aae..0c067d7 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -137,6 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
137 { 137 {
138 UUID toAgentID = new UUID(im.toAgentID); 138 UUID toAgentID = new UUID(im.toAgentID);
139 139
140 if (toAgentID == UUID.Zero)
141 return;
142
140 // Try root avatar only first 143 // Try root avatar only first
141 foreach (Scene scene in m_Scenes) 144 foreach (Scene scene in m_Scenes)
142 { 145 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d5e611c..f9b4bfd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3420,7 +3420,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3420 public void llInstantMessage(string user, string message) 3420 public void llInstantMessage(string user, string message)
3421 { 3421 {
3422 UUID result; 3422 UUID result;
3423 if (!UUID.TryParse(user, out result)) 3423 if (!UUID.TryParse(user, out result) || result == UUID.Zero)
3424 { 3424 {
3425 ShoutError("An invalid key was passed to llInstantMessage"); 3425 ShoutError("An invalid key was passed to llInstantMessage");
3426 ScriptSleep(2000); 3426 ScriptSleep(2000);