aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs257
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs59
3 files changed, 51 insertions, 271 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
deleted file mode 100644
index af54c1a..0000000
--- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
+++ /dev/null
@@ -1,257 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38using Mono.Addins;
39
40namespace OpenSim.Region.CoreModules.Avatar.Groups
41{
42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
43 public class GroupsModule : ISharedRegionModule
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
49 new Dictionary<UUID, GroupMembershipData>();
50
51 private Dictionary<UUID, IClientAPI> m_ClientMap =
52 new Dictionary<UUID, IClientAPI>();
53
54 private UUID opensimulatorGroupID =
55 new UUID("00000000-68f9-1111-024e-222222111123");
56
57 private List<Scene> m_SceneList = new List<Scene>();
58
59 private static GroupMembershipData osGroup =
60 new GroupMembershipData();
61
62 private bool m_Enabled = false;
63
64 #region ISharedRegionModule Members
65
66 public void Initialise(IConfigSource config)
67 {
68 IConfig groupsConfig = config.Configs["Groups"];
69
70 if (groupsConfig == null)
71 {
72 m_log.Info("[GROUPS]: No configuration found. Using defaults");
73 }
74 else
75 {
76 m_Enabled = groupsConfig.GetBoolean("Enabled", false);
77 if (!m_Enabled)
78 {
79 m_log.Info("[GROUPS]: Groups disabled in configuration");
80 return;
81 }
82
83 if (groupsConfig.GetString("Module", "Default") != "Default")
84 return;
85 }
86
87 }
88
89 public void AddRegion(Scene scene)
90 {
91 if (!m_Enabled)
92 return;
93
94 lock (m_SceneList)
95 {
96 if (!m_SceneList.Contains(scene))
97 {
98 if (m_SceneList.Count == 0)
99 {
100 osGroup.GroupID = opensimulatorGroupID;
101 osGroup.GroupName = "OpenSimulator Testing";
102 osGroup.GroupPowers =
103 (uint)(GroupPowers.AllowLandmark |
104 GroupPowers.AllowSetHome);
105 m_GroupMap[opensimulatorGroupID] = osGroup;
106 }
107 m_SceneList.Add(scene);
108 }
109 }
110
111 scene.EventManager.OnNewClient += OnNewClient;
112 scene.EventManager.OnClientClosed += OnClientClosed;
113 // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
114 }
115
116 public void RemoveRegion(Scene scene)
117 {
118 if (!m_Enabled)
119 return;
120
121 lock (m_SceneList)
122 {
123 if (m_SceneList.Contains(scene))
124 m_SceneList.Remove(scene);
125 }
126
127 scene.EventManager.OnNewClient -= OnNewClient;
128 scene.EventManager.OnClientClosed -= OnClientClosed;
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
133 }
134
135 public void PostInitialise()
136 {
137 }
138
139 public void Close()
140 {
141 if (!m_Enabled)
142 return;
143
144// m_log.Debug("[GROUPS]: Shutting down group module.");
145
146 lock (m_ClientMap)
147 {
148 m_ClientMap.Clear();
149 }
150
151 lock (m_GroupMap)
152 {
153 m_GroupMap.Clear();
154 }
155 }
156
157 public string Name
158 {
159 get { return "GroupsModule"; }
160 }
161
162 public Type ReplaceableInterface
163 {
164 get { return null; }
165 }
166
167 #endregion
168
169 private void OnNewClient(IClientAPI client)
170 {
171 // Subscribe to instant messages
172// client.OnInstantMessage += OnInstantMessage;
173 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
174 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
175 lock (m_ClientMap)
176 {
177 if (!m_ClientMap.ContainsKey(client.AgentId))
178 {
179 m_ClientMap.Add(client.AgentId, client);
180 }
181 }
182
183 GroupMembershipData[] updateGroups = new GroupMembershipData[1];
184 updateGroups[0] = osGroup;
185
186 client.SendGroupMembership(updateGroups);
187 }
188
189 private void OnAgentDataUpdateRequest(IClientAPI remoteClient,
190 UUID AgentID, UUID SessionID)
191 {
192 UUID ActiveGroupID;
193 string ActiveGroupName;
194 ulong ActiveGroupPowers;
195
196 string firstname = remoteClient.FirstName;
197 string lastname = remoteClient.LastName;
198
199 string ActiveGroupTitle = "I IZ N0T";
200
201 ActiveGroupID = osGroup.GroupID;
202 ActiveGroupName = osGroup.GroupName;
203 ActiveGroupPowers = osGroup.GroupPowers;
204
205 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
206 lastname, ActiveGroupPowers, ActiveGroupName,
207 ActiveGroupTitle);
208 }
209
210// private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
211// {
212// }
213
214// private void OnGridInstantMessage(GridInstantMessage msg)
215// {
216// // Trigger the above event handler
217// OnInstantMessage(null, msg);
218// }
219
220 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
221 {
222 string groupnamereply = "Unknown";
223 UUID groupUUID = UUID.Zero;
224
225 lock (m_GroupMap)
226 {
227 if (m_GroupMap.ContainsKey(id))
228 {
229 GroupMembershipData grp = m_GroupMap[id];
230 groupnamereply = grp.GroupName;
231 groupUUID = grp.GroupID;
232 }
233 }
234 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
235 }
236
237 private void OnClientClosed(UUID agentID, Scene scene)
238 {
239 lock (m_ClientMap)
240 {
241 if (m_ClientMap.ContainsKey(agentID))
242 {
243// IClientAPI cli = m_ClientMap[agentID];
244// if (cli != null)
245// {
246// //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name);
247// }
248// else
249// {
250// //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString());
251// }
252 m_ClientMap.Remove(agentID);
253 }
254 }
255 }
256 }
257}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 7e72d47..0c8a2b1 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -150,6 +150,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
150 { 150 {
151 client.OnTeleportHomeRequest += TriggerTeleportHome; 151 client.OnTeleportHomeRequest += TriggerTeleportHome;
152 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 152 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
153 client.OnTeleportCancel += TeleportCancel;
153 } 154 }
154 155
155 public virtual void Close() {} 156 public virtual void Close() {}
@@ -993,6 +994,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
993 return neighbourRegion; 994 return neighbourRegion;
994 } 995 }
995 996
997 private void TeleportCancel(IClientAPI remoteClient)
998 {
999 m_entityTransferStateMachine.ResetFromTransit(remoteClient.AgentId);
1000 }
1001
996 public bool Cross(ScenePresence agent, bool isFlying) 1002 public bool Cross(ScenePresence agent, bool isFlying)
997 { 1003 {
998 uint x; 1004 uint x;
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index a0ae203..708b99d 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -42,6 +42,7 @@ using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using Mono.Addins; 44using Mono.Addins;
45using Amib.Threading;
45 46
46/***************************************************** 47/*****************************************************
47 * 48 *
@@ -102,6 +103,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
102 private Dictionary<UUID, HttpRequestClass> m_pendingRequests; 103 private Dictionary<UUID, HttpRequestClass> m_pendingRequests;
103 private Scene m_scene; 104 private Scene m_scene;
104 // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); 105 // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
106 public static SmartThreadPool ThreadPool = null;
105 107
106 public HttpRequestModule() 108 public HttpRequestModule()
107 { 109 {
@@ -279,7 +281,30 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
279 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 281 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
280 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 282 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
281 283
284 int maxThreads = 50;
285
286 IConfig httpConfig = config.Configs["HttpRequestModule"];
287 if (httpConfig != null)
288 {
289 maxThreads = httpConfig.GetInt("MaxPoolThreads", maxThreads);
290 }
291
282 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); 292 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
293
294 // First instance sets this up for all sims
295 if (ThreadPool == null)
296 {
297 STPStartInfo startInfo = new STPStartInfo();
298 startInfo.IdleTimeout = 20000;
299 startInfo.MaxWorkerThreads = maxThreads;
300 startInfo.MinWorkerThreads = 5;
301 startInfo.ThreadPriority = ThreadPriority.BelowNormal;
302 startInfo.StartSuspended = true;
303
304 ThreadPool = new SmartThreadPool(startInfo);
305
306 ThreadPool.Start();
307 }
283 } 308 }
284 309
285 public void AddRegion(Scene scene) 310 public void AddRegion(Scene scene)
@@ -340,7 +365,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
340 public string HttpMIMEType = "text/plain;charset=utf-8"; 365 public string HttpMIMEType = "text/plain;charset=utf-8";
341 public int HttpTimeout; 366 public int HttpTimeout;
342 public bool HttpVerifyCert = true; 367 public bool HttpVerifyCert = true;
343 private Thread httpThread; 368 public IWorkItemResult WorkItem = null;
344 369
345 // Request info 370 // Request info
346 private UUID _itemID; 371 private UUID _itemID;
@@ -374,12 +399,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
374 399
375 public void Process() 400 public void Process()
376 { 401 {
377 httpThread = new Thread(SendRequest);
378 httpThread.Name = "HttpRequestThread";
379 httpThread.Priority = ThreadPriority.BelowNormal;
380 httpThread.IsBackground = true;
381 _finished = false; 402 _finished = false;
382 httpThread.Start(); 403
404 lock (HttpRequestModule.ThreadPool)
405 WorkItem = HttpRequestModule.ThreadPool.QueueWorkItem(new WorkItemCallback(StpSendWrapper), null);
406 }
407
408 private object StpSendWrapper(object o)
409 {
410 SendRequest();
411 return null;
383 } 412 }
384 413
385 /* 414 /*
@@ -409,13 +438,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
409 { 438 {
410 // We could hijack Connection Group Name to identify 439 // We could hijack Connection Group Name to identify
411 // a desired security exception. But at the moment we'll use a dummy header instead. 440 // a desired security exception. But at the moment we'll use a dummy header instead.
412// Request.ConnectionGroupName = "NoVerify";
413 Request.Headers.Add("NoVerifyCert", "true"); 441 Request.Headers.Add("NoVerifyCert", "true");
414 } 442 }
415// else
416// {
417// Request.ConnectionGroupName="Verify";
418// }
419 if (proxyurl != null && proxyurl.Length > 0) 443 if (proxyurl != null && proxyurl.Length > 0)
420 { 444 {
421 if (proxyexcepts != null && proxyexcepts.Length > 0) 445 if (proxyexcepts != null && proxyexcepts.Length > 0)
@@ -485,9 +509,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
485 509
486 ResponseBody = sb.ToString().Replace("\r", ""); 510 ResponseBody = sb.ToString().Replace("\r", "");
487 } 511 }
488 catch (Exception e) 512 catch (WebException e)
489 { 513 {
490 if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError) 514 if (e.Status == WebExceptionStatus.ProtocolError)
491 { 515 {
492 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; 516 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
493 Status = (int)webRsp.StatusCode; 517 Status = (int)webRsp.StatusCode;
@@ -512,6 +536,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
512 _finished = true; 536 _finished = true;
513 return; 537 return;
514 } 538 }
539 catch (Exception e)
540 {
541 // Don't crash on anything else
542 }
515 finally 543 finally
516 { 544 {
517 if (response != null) 545 if (response != null)
@@ -525,7 +553,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
525 { 553 {
526 try 554 try
527 { 555 {
528 httpThread.Abort(); 556 if (!WorkItem.Cancel())
557 {
558 WorkItem.Abort();
559 }
529 } 560 }
530 catch (Exception) 561 catch (Exception)
531 { 562 {