aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Framework
parentAdd a build script. (diff)
downloadopensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs10
-rw-r--r--OpenSim/Framework/AgentUpdateArgs.cs2
-rw-r--r--OpenSim/Framework/AnimationSet.cs186
-rw-r--r--OpenSim/Framework/AssemblyInfo.cs2
-rw-r--r--OpenSim/Framework/AssetBase.cs19
-rw-r--r--OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Framework/AssetRequestToClient.cs6
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs162
-rw-r--r--OpenSim/Framework/AvatarWearable.cs38
-rw-r--r--OpenSim/Framework/BasicDOSProtector.cs14
-rw-r--r--OpenSim/Framework/BlockingQueue.cs8
-rw-r--r--OpenSim/Framework/Cache.cs83
-rw-r--r--OpenSim/Framework/CapsUtil.cs2
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs337
-rw-r--r--OpenSim/Framework/CircularBuffer.cs20
-rw-r--r--OpenSim/Framework/Client/IClientIPEndpoint.cs2
-rw-r--r--OpenSim/Framework/ClientInfo.cs10
-rw-r--r--OpenSim/Framework/ClientManager.cs48
-rw-r--r--OpenSim/Framework/CnmMemoryCache.cs140
-rw-r--r--OpenSim/Framework/CnmSynchronizedCache.cs106
-rw-r--r--OpenSim/Framework/ColliderData.cs1
-rw-r--r--OpenSim/Framework/ConfigurationMember.cs530
-rw-r--r--OpenSim/Framework/Console/AssemblyInfo.cs2
-rw-r--r--OpenSim/Framework/Console/CommandConsole.cs44
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/Console/ConsoleBase.cs8
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/Console/ConsolePluginCommand.cs0
-rw-r--r--OpenSim/Framework/Console/ConsoleUtil.cs22
-rw-r--r--OpenSim/Framework/Console/LocalConsole.cs24
-rw-r--r--OpenSim/Framework/Console/MockConsole.cs4
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs317
-rw-r--r--OpenSim/Framework/Constants.cs12
-rw-r--r--OpenSim/Framework/Crc32.cs139
-rw-r--r--OpenSim/Framework/CustomTypes.cs43
-rw-r--r--OpenSim/Framework/DAMap.cs40
-rw-r--r--OpenSim/Framework/DOMap.cs2
-rw-r--r--OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs193
-rw-r--r--OpenSim/Framework/EntityTransferContext.cs70
-rw-r--r--OpenSim/Framework/EstateBan.cs2
-rw-r--r--OpenSim/Framework/EstateSettings.cs109
-rw-r--r--OpenSim/Framework/GridInstantMessage.cs2
-rw-r--r--OpenSim/Framework/IAssetCache.cs (renamed from OpenSim/Framework/IImprovedAssetCache.cs)15
-rw-r--r--OpenSim/Framework/IClientAPI.cs221
-rw-r--r--OpenSim/Framework/ICnmCache.cs106
-rw-r--r--OpenSim/Framework/ILandChannel.cs11
-rw-r--r--OpenSim/Framework/ILandObject.cs94
-rw-r--r--OpenSim/Framework/IMoneyModule.cs9
-rw-r--r--OpenSim/Framework/IPrimCounts.cs14
-rw-r--r--OpenSim/Framework/IRegistryCore.cs2
-rw-r--r--OpenSim/Framework/IScene.cs4
-rw-r--r--OpenSim/Framework/ISceneAgent.cs17
-rw-r--r--OpenSim/Framework/InventoryFolderImpl.cs2
-rw-r--r--OpenSim/Framework/InventoryItemBase.cs110
-rw-r--r--OpenSim/Framework/InventoryNodeBase.cs8
-rw-r--r--OpenSim/Framework/LandData.cs58
-rw-r--r--OpenSim/Framework/LandUpdateArgs.cs3
-rw-r--r--OpenSim/Framework/Lazy.cs4
-rw-r--r--OpenSim/Framework/LocklessQueue.cs16
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/LogWriter.cs0
-rw-r--r--OpenSim/Framework/MapAndArray.cs12
-rw-r--r--OpenSim/Framework/MapItemReplyStruct.cs2
-rw-r--r--OpenSim/Framework/MetricsCollector.cs8
-rw-r--r--OpenSim/Framework/Monitoring/BaseStatsCollector.cs26
-rw-r--r--OpenSim/Framework/Monitoring/Checks/Check.cs8
-rw-r--r--OpenSim/Framework/Monitoring/ChecksManager.cs45
-rw-r--r--OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs2
-rw-r--r--OpenSim/Framework/Monitoring/JobEngine.cs162
-rw-r--r--OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Framework/Monitoring/ServerStatsCollector.cs77
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs56
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/Monitoring/Stats/CounterStat.cs0
-rwxr-xr-x[-rw-r--r--]OpenSim/Framework/Monitoring/Stats/EventHistogram.cs346
-rw-r--r--OpenSim/Framework/Monitoring/Stats/Stat.cs51
-rw-r--r--OpenSim/Framework/Monitoring/StatsLogger.cs6
-rw-r--r--OpenSim/Framework/Monitoring/StatsManager.cs106
-rw-r--r--OpenSim/Framework/Monitoring/Watchdog.cs61
-rw-r--r--OpenSim/Framework/Monitoring/WorkManager.cs48
-rw-r--r--OpenSim/Framework/MuteData.cs41
-rw-r--r--OpenSim/Framework/NetworkServersInfo.cs2
-rw-r--r--OpenSim/Framework/NetworkUtil.cs4
-rw-r--r--OpenSim/Framework/OSChatMessage.cs21
-rw-r--r--OpenSim/Framework/ObjectChangeData.cs80
-rw-r--r--OpenSim/Framework/OutboundUrlFilter.cs30
-rw-r--r--OpenSim/Framework/ParcelMediaCommandEnum.cs2
-rw-r--r--OpenSim/Framework/PermissionsUtil.cs57
-rw-r--r--OpenSim/Framework/PhysicsInertia.cs263
-rw-r--r--OpenSim/Framework/PluginLoader.cs17
-rw-r--r--OpenSim/Framework/PluginManager.cs54
-rw-r--r--OpenSim/Framework/PrimeNumberHelper.cs2
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs153
-rw-r--r--OpenSim/Framework/PriorityQueue.cs88
-rw-r--r--OpenSim/Framework/RegionInfo.cs419
-rw-r--r--OpenSim/Framework/RegionSettings.cs42
-rw-r--r--OpenSim/Framework/RestClient.cs36
-rw-r--r--OpenSim/Framework/SLUtil.cs14
-rw-r--r--OpenSim/Framework/Serialization/ArchiveConstants.cs4
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs9
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs1
-rw-r--r--OpenSim/Framework/Serialization/External/OspResolver.cs44
-rw-r--r--OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs35
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs24
-rw-r--r--OpenSim/Framework/Serialization/External/UserProfileSerializer.cs12
-rw-r--r--OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Framework/Serialization/TarArchiveWriter.cs12
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs73
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs204
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs14
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandlerBasicDOSProtector.cs8
-rw-r--r--OpenSim/Framework/Servers/HttpServer/GenericHTTPBasicDOSProtector.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs34
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs7
-rw-r--r--OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs12
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpStatusCodes.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs10
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs85
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs327
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestSessionService.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs7
-rw-r--r--OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs82
-rw-r--r--OpenSim/Framework/Servers/HttpServer/XmlRpcBasicDOSProtector.cs6
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs26
-rw-r--r--OpenSim/Framework/Servers/Properties/AssemblyInfo.cs8
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs180
-rw-r--r--OpenSim/Framework/Servers/Tests/OSHttpTests.cs341
-rw-r--r--OpenSim/Framework/Servers/Tests/VersionInfoTests.cs2
-rw-r--r--OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs2
-rw-r--r--OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs2
-rw-r--r--OpenSim/Framework/SimStats.cs24
-rw-r--r--OpenSim/Framework/TaskInventoryDictionary.cs196
-rw-r--r--OpenSim/Framework/TaskInventoryItem.cs11
-rw-r--r--OpenSim/Framework/TerrainData.cs324
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitDataTest.cs11
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitManagerTests.cs2
-rw-r--r--OpenSim/Framework/Tests/AnimationTests.cs2
-rw-r--r--OpenSim/Framework/Tests/CacheTests.cs4
-rw-r--r--OpenSim/Framework/Tests/LocationTest.cs2
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs23
-rw-r--r--OpenSim/Framework/Tests/PrimeNumberHelperTests.cs6
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs13
-rw-r--r--OpenSim/Framework/ThrottleOutPacketType.cs2
-rw-r--r--OpenSim/Framework/UserProfileData.cs8
-rw-r--r--OpenSim/Framework/UserProfiles.cs27
-rw-r--r--OpenSim/Framework/Util.cs735
-rw-r--r--OpenSim/Framework/VersionInfo.cs32
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs77
-rw-r--r--OpenSim/Framework/WebUtil.cs220
151 files changed, 6548 insertions, 2604 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 0d053e4..5a9eeb5 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Framework
77 public bool child; 77 public bool child;
78 78
79 /// <summary> 79 /// <summary>
80 /// Number given to the client when they log-in that they provide 80 /// Number given to the client when they log-in that they provide
81 /// as credentials to the UDP server 81 /// as credentials to the UDP server
82 /// </summary> 82 /// </summary>
83 public uint circuitcode; 83 public uint circuitcode;
@@ -184,7 +184,7 @@ namespace OpenSim.Framework
184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json 184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json
185 /// </summary> 185 /// </summary>
186 /// <returns>map of the agent circuit data</returns> 186 /// <returns>map of the agent circuit data</returns>
187 public OSDMap PackAgentCircuitData() 187 public OSDMap PackAgentCircuitData(EntityTransferContext ctx)
188 { 188 {
189 OSDMap args = new OSDMap(); 189 OSDMap args = new OSDMap();
190 args["agent_id"] = OSD.FromUUID(AgentID); 190 args["agent_id"] = OSD.FromUUID(AgentID);
@@ -224,7 +224,7 @@ namespace OpenSim.Framework
224 { 224 {
225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); 225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
226 226
227 OSDMap appmap = Appearance.Pack(); 227 OSDMap appmap = Appearance.Pack(ctx);
228 args["packed_appearance"] = appmap; 228 args["packed_appearance"] = appmap;
229 } 229 }
230 230
@@ -328,7 +328,7 @@ namespace OpenSim.Framework
328 Vector3.TryParse(args["start_pos"].AsString(), out startpos); 328 Vector3.TryParse(args["start_pos"].AsString(), out startpos);
329 329
330 //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos); 330 //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);
331 331
332 try 332 try
333 { 333 {
334 // Unpack various appearance elements 334 // Unpack various appearance elements
@@ -353,7 +353,7 @@ namespace OpenSim.Framework
353 { 353 {
354 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message); 354 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
355 } 355 }
356 356
357 ServiceURLs = new Dictionary<string, object>(); 357 ServiceURLs = new Dictionary<string, object>();
358 // Try parse the new way, OSDMap 358 // Try parse the new way, OSDMap
359 if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map) 359 if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
diff --git a/OpenSim/Framework/AgentUpdateArgs.cs b/OpenSim/Framework/AgentUpdateArgs.cs
index 660bc32..f04d692 100644
--- a/OpenSim/Framework/AgentUpdateArgs.cs
+++ b/OpenSim/Framework/AgentUpdateArgs.cs
@@ -81,6 +81,8 @@ namespace OpenSim.Framework
81 81
82 public Vector3 ClientAgentPosition; 82 public Vector3 ClientAgentPosition;
83 public bool UseClientAgentPosition; 83 public bool UseClientAgentPosition;
84 public bool NeedsCameraCollision;
85 public uint lastpacketSequence;
84 86
85 public AgentUpdateArgs() 87 public AgentUpdateArgs()
86 { 88 {
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs
new file mode 100644
index 0000000..8753088
--- /dev/null
+++ b/OpenSim/Framework/AnimationSet.cs
@@ -0,0 +1,186 @@
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 OpenMetaverse;
31
32namespace OpenSim.Framework
33{
34// public delegate bool AnimationSetValidator(UUID animID);
35 public delegate uint AnimationSetValidator(UUID animID);
36
37 public class AnimationSet
38 {
39 private bool m_parseError = false;
40
41 public const uint createBasePermitions = (uint)(PermissionMask.All); // no export ?
42 public const uint createNextPermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
43
44 public const uint allowedBasePermitions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
45 public const uint allowedNextPermitions = 0;
46
47 public static void setCreateItemPermitions(InventoryItemBase it)
48 {
49 if (it == null)
50 return;
51
52 it.BasePermissions = createBasePermitions;
53 it.CurrentPermissions = createBasePermitions;
54 // it.GroupPermissions &= allowedPermitions;
55 it.NextPermissions = createNextPermitions;
56 // it.EveryOnePermissions &= allowedPermitions;
57 it.GroupPermissions = 0;
58 it.EveryOnePermissions = 0;
59 }
60
61 public static void enforceItemPermitions(InventoryItemBase it, bool IsCreator)
62 {
63 if (it == null)
64 return;
65
66 uint bp;
67 uint np;
68
69 if (IsCreator)
70 {
71 bp = createBasePermitions;
72 np = createNextPermitions;
73 }
74 else
75 {
76 bp = allowedBasePermitions;
77 np = allowedNextPermitions;
78 }
79
80 it.BasePermissions &= bp;
81 it.CurrentPermissions &= bp;
82 // it.GroupPermissions &= allowedPermitions;
83 it.NextPermissions &= np;
84 // it.EveryOnePermissions &= allowedPermitions;
85 it.GroupPermissions = 0;
86 it.EveryOnePermissions = 0;
87 }
88
89 public int AnimationCount { get; private set; }
90 private Dictionary<string, KeyValuePair<string, UUID>> m_animations = new Dictionary<string, KeyValuePair<string, UUID>>();
91
92 public UUID GetAnimation(string index)
93 {
94 KeyValuePair<string, UUID> val;
95 if (m_animations.TryGetValue(index, out val))
96 return val.Value;
97
98 return UUID.Zero;
99 }
100
101 public string GetAnimationName(string index)
102 {
103 KeyValuePair<string, UUID> val;
104 if (m_animations.TryGetValue(index, out val))
105 return val.Key;
106
107 return String.Empty;
108 }
109
110 public void SetAnimation(string index, string name, UUID anim)
111 {
112 if (anim == UUID.Zero)
113 {
114 m_animations.Remove(index);
115 return;
116 }
117
118 m_animations[index] = new KeyValuePair<string, UUID>(name, anim);
119 }
120
121 public AnimationSet(Byte[] data)
122 {
123 string assetData = System.Text.Encoding.ASCII.GetString(data);
124 Console.WriteLine("--------------------");
125 Console.WriteLine("AnimationSet length {0} bytes", assetData.Length);
126 Console.WriteLine(assetData);
127 Console.WriteLine("--------------------");
128 }
129
130 public Byte[] ToBytes()
131 {
132 // If there was an error parsing the input, we give back an
133 // empty set rather than the original data.
134 if (m_parseError)
135 {
136 string dummy = "version 1\ncount 0\n";
137 return System.Text.Encoding.ASCII.GetBytes(dummy);
138 }
139
140 string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count);
141 foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
142 assetData += String.Format("{0} {1} {2}\n", kvp.Key, kvp.Value.Value.ToString(), kvp.Value.Key);
143 return System.Text.Encoding.ASCII.GetBytes(assetData);
144 }
145/*
146 public bool Validate(AnimationSetValidator val)
147 {
148 if (m_parseError)
149 return false;
150
151 List<string> badAnims = new List<string>();
152
153 bool allOk = true;
154 foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
155 {
156 if (!val(kvp.Value.Value))
157 {
158 allOk = false;
159 badAnims.Add(kvp.Key);
160 }
161 }
162
163 foreach (string idx in badAnims)
164 m_animations.Remove(idx);
165
166 return allOk;
167 }
168*/
169 public uint Validate(AnimationSetValidator val)
170 {
171 if (m_parseError)
172 return 0;
173
174 uint ret = 0x7fffffff;
175 uint t;
176 foreach (KeyValuePair<string, KeyValuePair<string, UUID>> kvp in m_animations)
177 {
178 t = val(kvp.Value.Value);
179 if (t == 0)
180 return 0;
181 ret &= t;
182 }
183 return ret;
184 }
185 }
186}
diff --git a/OpenSim/Framework/AssemblyInfo.cs b/OpenSim/Framework/AssemblyInfo.cs
index a797424..c4835be 100644
--- a/OpenSim/Framework/AssemblyInfo.cs
+++ b/OpenSim/Framework/AssemblyInfo.cs
@@ -59,4 +59,4 @@ using System.Runtime.InteropServices;
59// Revision 59// Revision
60// 60//
61 61
62[assembly : AssemblyVersion("0.8.2.*")] 62[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 2f04d2e..88edf2f 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -63,6 +63,8 @@ namespace OpenSim.Framework
63 /// </summary> 63 /// </summary>
64 private AssetMetadata m_metadata; 64 private AssetMetadata m_metadata;
65 65
66 private int m_uploadAttempts;
67
66 // This is needed for .NET serialization!!! 68 // This is needed for .NET serialization!!!
67 // Do NOT "Optimize" away! 69 // Do NOT "Optimize" away!
68 public AssetBase() 70 public AssetBase()
@@ -110,7 +112,7 @@ namespace OpenSim.Framework
110 { 112 {
111 get 113 get
112 { 114 {
113 return 115 return
114 IsTextualAsset && ( 116 IsTextualAsset && (
115 Type != (sbyte)AssetType.Notecard 117 Type != (sbyte)AssetType.Notecard
116 && Type != (sbyte)AssetType.CallingCard 118 && Type != (sbyte)AssetType.CallingCard
@@ -135,7 +137,7 @@ namespace OpenSim.Framework
135 { 137 {
136 get 138 get
137 { 139 {
138 return 140 return
139 (Type == (sbyte)AssetType.Animation || 141 (Type == (sbyte)AssetType.Animation ||
140 Type == (sbyte)AssetType.Gesture || 142 Type == (sbyte)AssetType.Gesture ||
141 Type == (sbyte)AssetType.Simstate || 143 Type == (sbyte)AssetType.Simstate ||
@@ -148,11 +150,12 @@ namespace OpenSim.Framework
148 Type == (sbyte)AssetType.Folder || 150 Type == (sbyte)AssetType.Folder ||
149 Type == (sbyte)AssetType.ImageJPEG || 151 Type == (sbyte)AssetType.ImageJPEG ||
150 Type == (sbyte)AssetType.ImageTGA || 152 Type == (sbyte)AssetType.ImageTGA ||
151 Type == (sbyte)AssetType.LSLBytecode); 153 Type == (sbyte)AssetType.Mesh ||
154 Type == (sbyte) AssetType.LSLBytecode);
152 } 155 }
153 } 156 }
154 157
155 public virtual byte[] Data 158 public byte[] Data
156 { 159 {
157 get { return m_data; } 160 get { return m_data; }
158 set { m_data = value; } 161 set { m_data = value; }
@@ -197,6 +200,12 @@ namespace OpenSim.Framework
197 set { m_metadata.Type = value; } 200 set { m_metadata.Type = value; }
198 } 201 }
199 202
203 public int UploadAttempts
204 {
205 get { return m_uploadAttempts; }
206 set { m_uploadAttempts = value; }
207 }
208
200 /// <summary> 209 /// <summary>
201 /// Is this a region only asset, or does this exist on the asset server also 210 /// Is this a region only asset, or does this exist on the asset server also
202 /// </summary> 211 /// </summary>
@@ -273,7 +282,7 @@ namespace OpenSim.Framework
273 282
274 return m_id; 283 return m_id;
275 } 284 }
276 285
277 set 286 set
278 { 287 {
279 UUID uuid = UUID.Zero; 288 UUID uuid = UUID.Zero;
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs
index 76df564..b6ea077 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Framework.AssetLoader.Filesystem")] 8[assembly: AssemblyTitle("OpenSim.Framework.AssetLoader.Filesystem")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Framework/AssetRequestToClient.cs b/OpenSim/Framework/AssetRequestToClient.cs
index d602c1f..3dfbb91 100644
--- a/OpenSim/Framework/AssetRequestToClient.cs
+++ b/OpenSim/Framework/AssetRequestToClient.cs
@@ -31,10 +31,10 @@ namespace OpenSim.Framework
31{ 31{
32 /// <summary> 32 /// <summary>
33 /// This class was created to refactor OutPacket out of AssetCache 33 /// This class was created to refactor OutPacket out of AssetCache
34 /// There is a conflict between 34 /// There is a conflict between
35 /// OpenSim.Framework.Communications.Cache.AssetRequest and OpenSim.Framework.AssetRequest 35 /// OpenSim.Framework.Communications.Cache.AssetRequest and OpenSim.Framework.AssetRequest
36 /// and unifying them results in a prebuild chicken and egg problem with OpenSim.Framework requiring 36 /// and unifying them results in a prebuild chicken and egg problem with OpenSim.Framework requiring
37 /// OpenSim.Framework.Communications.Cache while OpenSim.Framework.Communications.Cache 37 /// OpenSim.Framework.Communications.Cache while OpenSim.Framework.Communications.Cache
38 /// requiring OpenSim.Framework 38 /// requiring OpenSim.Framework
39 /// </summary> 39 /// </summary>
40 public class AssetRequestToClient 40 public class AssetRequestToClient
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 26dd5df..77a7621 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -53,7 +53,11 @@ namespace OpenSim.Framework
53 // should be only used as initial default value ( V1 viewers ) 53 // should be only used as initial default value ( V1 viewers )
54 public readonly static int VISUALPARAM_COUNT = 218; 54 public readonly static int VISUALPARAM_COUNT = 218;
55 55
56 public readonly static int TEXTURE_COUNT = 21; 56// public readonly static int TEXTURE_COUNT = 21
57 // 21 bad, make it be updated as libovm gets update
58 // also keeping in sync with it
59 public readonly static int TEXTURE_COUNT = Primitive.TextureEntry.MAX_FACES;
60
57 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 61 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
58 62
59 protected int m_serial = 0; 63 protected int m_serial = 0;
@@ -69,8 +73,6 @@ namespace OpenSim.Framework
69 protected WearableCacheItem[] m_cacheitems; 73 protected WearableCacheItem[] m_cacheitems;
70 protected bool m_cacheItemsDirty = true; 74 protected bool m_cacheItemsDirty = true;
71 75
72
73 public bool PackLegacyWearables {get; set; }
74 public virtual int Serial 76 public virtual int Serial
75 { 77 {
76 get { return m_serial; } 78 get { return m_serial; }
@@ -119,7 +121,7 @@ namespace OpenSim.Framework
119 get { return m_avatarHeight; } 121 get { return m_avatarHeight; }
120 set { m_avatarHeight = value; } 122 set { m_avatarHeight = value; }
121 } 123 }
122 124
123 public virtual WearableCacheItem[] WearableCacheItems 125 public virtual WearableCacheItem[] WearableCacheItems
124 { 126 {
125 get { return m_cacheitems; } 127 get { return m_cacheitems; }
@@ -135,7 +137,7 @@ namespace OpenSim.Framework
135 public AvatarAppearance() 137 public AvatarAppearance()
136 { 138 {
137// m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance"); 139// m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance");
138 PackLegacyWearables = false; 140
139 m_serial = 0; 141 m_serial = 0;
140 SetDefaultWearables(); 142 SetDefaultWearables();
141 SetDefaultTexture(); 143 SetDefaultTexture();
@@ -181,11 +183,16 @@ namespace OpenSim.Framework
181 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 183 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
182 } 184 }
183 185
184 public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) 186 public AvatarAppearance(AvatarAppearance appearance): this(appearance, true,true)
185 { 187 {
186 } 188 }
187 189
188 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables) 190 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
191 : this(appearance, copyWearables, true)
192 {
193 }
194
195 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables, bool copyBaked)
189 { 196 {
190// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); 197// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");
191 198
@@ -204,24 +211,29 @@ namespace OpenSim.Framework
204 211
205 m_serial = appearance.Serial; 212 m_serial = appearance.Serial;
206 213
207 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
208 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
209 m_wearables[i] = new AvatarWearable();
210
211 if (copyWearables && (appearance.Wearables != null)) 214 if (copyWearables && (appearance.Wearables != null))
212 { 215 {
213 int len = appearance.Wearables.Length; 216 m_wearables = new AvatarWearable[appearance.Wearables.Length];
214 if(len > AvatarWearable.MAX_WEARABLES) 217 for (int i = 0; i < appearance.Wearables.Length; i++)
215 len = AvatarWearable.MAX_WEARABLES; 218 {
216 for (int i = 0; i < len; i++) 219 m_wearables[i] = new AvatarWearable();
217 SetWearable(i,appearance.Wearables[i]); 220 AvatarWearable wearable = appearance.Wearables[i];
221 for (int j = 0; j < wearable.Count; j++)
222 m_wearables[i].Add(wearable[j].ItemID, wearable[j].AssetID);
223 }
218 } 224 }
225 else
226 ClearWearables();
219 227
220 m_texture = null; 228 m_texture = null;
221 if (appearance.Texture != null) 229 if (appearance.Texture != null)
222 { 230 {
223 byte[] tbytes = appearance.Texture.GetBytes(); 231 byte[] tbytes = appearance.Texture.GetBytes();
224 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); 232 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
233 if (copyBaked && appearance.m_cacheitems != null)
234 m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone();
235 else
236 m_cacheitems = null;
225 } 237 }
226 238
227 m_visualparams = null; 239 m_visualparams = null;
@@ -239,9 +251,17 @@ namespace OpenSim.Framework
239 251
240 public void GetAssetsFrom(AvatarAppearance app) 252 public void GetAssetsFrom(AvatarAppearance app)
241 { 253 {
242 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 254 int len = m_wearables.Length;
255 if(len > app.m_wearables.Length)
256 len = app.m_wearables.Length;
257
258 for (int i = 0; i < len; i++)
243 { 259 {
244 for (int j = 0; j < m_wearables[i].Count; j++) 260 int count = m_wearables[i].Count;
261 if(count > app.m_wearables[i].Count)
262 count = app.m_wearables[i].Count;
263
264 for (int j = 0; j < count; j++)
245 { 265 {
246 UUID itemID = m_wearables[i][j].ItemID; 266 UUID itemID = m_wearables[i][j].ItemID;
247 UUID assetID = app.Wearables[i].GetAsset(itemID); 267 UUID assetID = app.Wearables[i].GetAsset(itemID);
@@ -254,8 +274,8 @@ namespace OpenSim.Framework
254 274
255 public void ClearWearables() 275 public void ClearWearables()
256 { 276 {
257 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 277 m_wearables = new AvatarWearable[AvatarWearable.LEGACY_VERSION_MAX_WEARABLES];
258 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 278 for (int i = 0; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; i++)
259 m_wearables[i] = new AvatarWearable(); 279 m_wearables[i] = new AvatarWearable();
260 } 280 }
261 281
@@ -271,18 +291,18 @@ namespace OpenSim.Framework
271 public virtual void ResetAppearance() 291 public virtual void ResetAppearance()
272 { 292 {
273// m_log.WarnFormat("[AVATAR APPEARANCE]: Reset appearance"); 293// m_log.WarnFormat("[AVATAR APPEARANCE]: Reset appearance");
274 294
275 m_serial = 0; 295 m_serial = 0;
276 296
277 SetDefaultTexture(); 297 SetDefaultTexture();
278 298
279 //for (int i = 0; i < BAKE_INDICES.Length; i++) 299 //for (int i = 0; i < BAKE_INDICES.Length; i++)
280 // { 300 // {
281 // int idx = BAKE_INDICES[i]; 301 // int idx = BAKE_INDICES[i];
282 // m_texture.FaceTextures[idx].TextureID = UUID.Zero; 302 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
283 // } 303 // }
284 } 304 }
285 305
286 protected virtual void SetDefaultParams() 306 protected virtual void SetDefaultParams()
287 { 307 {
288 m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 }; 308 m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 };
@@ -299,14 +319,14 @@ namespace OpenSim.Framework
299 public virtual void ResetBakedTextures() 319 public virtual void ResetBakedTextures()
300 { 320 {
301 SetDefaultTexture(); 321 SetDefaultTexture();
302 322
303 //for (int i = 0; i < BAKE_INDICES.Length; i++) 323 //for (int i = 0; i < BAKE_INDICES.Length; i++)
304 // { 324 // {
305 // int idx = BAKE_INDICES[i]; 325 // int idx = BAKE_INDICES[i];
306 // m_texture.FaceTextures[idx].TextureID = UUID.Zero; 326 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
307 // } 327 // }
308 } 328 }
309 329
310 protected virtual void SetDefaultTexture() 330 protected virtual void SetDefaultTexture()
311 { 331 {
312 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); 332 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
@@ -351,7 +371,7 @@ namespace OpenSim.Framework
351 } 371 }
352 372
353 m_texture = textureEntry; 373 m_texture = textureEntry;
354 374
355 return changed; 375 return changed;
356 } 376 }
357 377
@@ -462,12 +482,16 @@ namespace OpenSim.Framework
462// DEBUG ON 482// DEBUG ON
463// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); 483// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID);
464// DEBUG OFF 484// DEBUG OFF
485 if (wearableId >= m_wearables.Length)
486 {
487 int currentLength = m_wearables.Length;
488 Array.Resize(ref m_wearables, wearableId + 1);
489 for (int i = currentLength ; i < m_wearables.Length ; i++)
490 m_wearables[i] = new AvatarWearable();
491 }
465 m_wearables[wearableId].Clear(); 492 m_wearables[wearableId].Clear();
466 int count = wearable.Count; 493 for (int i = 0; i < wearable.Count; i++)
467 if (count > AvatarWearable.MAX_WEARABLES) 494 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
468 count = AvatarWearable.MAX_WEARABLES;
469 for (int i = 0; i < count; i++)
470 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
471 } 495 }
472 496
473// DEBUG ON 497// DEBUG ON
@@ -507,14 +531,14 @@ namespace OpenSim.Framework
507 { 531 {
508 lock (m_attachments) 532 lock (m_attachments)
509 { 533 {
510 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 534 List<AvatarAttachment> alist = new List<AvatarAttachment>();
511 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 535 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
512 { 536 {
513 foreach (AvatarAttachment attach in kvp.Value) 537 foreach (AvatarAttachment attach in kvp.Value)
514 alist.Add(new AvatarAttachment(attach)); 538 alist.Add(new AvatarAttachment(attach));
515 } 539 }
516 return alist; 540 return alist;
517 } 541 }
518 } 542 }
519 543
520 internal void AppendAttachment(AvatarAttachment attach) 544 internal void AppendAttachment(AvatarAttachment attach)
@@ -527,7 +551,7 @@ namespace OpenSim.Framework
527 { 551 {
528 if (!m_attachments.ContainsKey(attach.AttachPoint)) 552 if (!m_attachments.ContainsKey(attach.AttachPoint))
529 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 553 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
530 554
531 foreach (AvatarAttachment prev in m_attachments[attach.AttachPoint]) 555 foreach (AvatarAttachment prev in m_attachments[attach.AttachPoint])
532 { 556 {
533 if (prev.ItemID == attach.ItemID) 557 if (prev.ItemID == attach.ItemID)
@@ -584,7 +608,7 @@ namespace OpenSim.Framework
584 m_attachments.Remove(attachpoint); 608 m_attachments.Remove(attachpoint);
585 return true; 609 return true;
586 } 610 }
587 611
588 return false; 612 return false;
589 } 613 }
590 614
@@ -598,13 +622,13 @@ namespace OpenSim.Framework
598 if (existingAttachment != null) 622 if (existingAttachment != null)
599 { 623 {
600// m_log.DebugFormat( 624// m_log.DebugFormat(
601// "[AVATAR APPEARANCE]: Found existing attachment for {0}, asset {1} at point {2}", 625// "[AVATAR APPEARANCE]: Found existing attachment for {0}, asset {1} at point {2}",
602// existingAttachment.ItemID, existingAttachment.AssetID, existingAttachment.AttachPoint); 626// existingAttachment.ItemID, existingAttachment.AssetID, existingAttachment.AttachPoint);
603 627
604 if (existingAttachment.AssetID != UUID.Zero && existingAttachment.AttachPoint == (attachpoint & 0x7F)) 628 if (existingAttachment.AssetID != UUID.Zero && existingAttachment.AttachPoint == (attachpoint & 0x7F))
605 { 629 {
606 m_log.DebugFormat( 630 m_log.DebugFormat(
607 "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}", 631 "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}",
608 item, attachpoint); 632 item, attachpoint);
609 633
610 return false; 634 return false;
@@ -616,7 +640,7 @@ namespace OpenSim.Framework
616 DetachAttachment(existingAttachment.ItemID); 640 DetachAttachment(existingAttachment.ItemID);
617 } 641 }
618 } 642 }
619 643
620 // check if this is an append or a replace, 0x80 marks it as an append 644 // check if this is an append or a replace, 0x80 marks it as an append
621 if ((attachpoint & 0x80) > 0) 645 if ((attachpoint & 0x80) > 0)
622 { 646 {
@@ -677,16 +701,16 @@ namespace OpenSim.Framework
677 if (index >= 0) 701 if (index >= 0)
678 { 702 {
679// m_log.DebugFormat( 703// m_log.DebugFormat(
680// "[AVATAR APPEARANCE]: Detaching attachment {0}, index {1}, point {2}", 704// "[AVATAR APPEARANCE]: Detaching attachment {0}, index {1}, point {2}",
681// m_attachments[kvp.Key][index].ItemID, index, m_attachments[kvp.Key][index].AttachPoint); 705// m_attachments[kvp.Key][index].ItemID, index, m_attachments[kvp.Key][index].AttachPoint);
682 706
683 // Remove it from the list of attachments at that attach point 707 // Remove it from the list of attachments at that attach point
684 m_attachments[kvp.Key].RemoveAt(index); 708 m_attachments[kvp.Key].RemoveAt(index);
685 709
686 // And remove the list if there are no more attachments here 710 // And remove the list if there are no more attachments here
687 if (m_attachments[kvp.Key].Count == 0) 711 if (m_attachments[kvp.Key].Count == 0)
688 m_attachments.Remove(kvp.Key); 712 m_attachments.Remove(kvp.Key);
689 713
690 return true; 714 return true;
691 } 715 }
692 } 716 }
@@ -706,7 +730,7 @@ namespace OpenSim.Framework
706 /// <summary> 730 /// <summary>
707 /// Create an OSDMap from the appearance data 731 /// Create an OSDMap from the appearance data
708 /// </summary> 732 /// </summary>
709 public OSDMap Pack() 733 public OSDMap Pack(EntityTransferContext ctx)
710 { 734 {
711 OSDMap data = new OSDMap(); 735 OSDMap data = new OSDMap();
712 736
@@ -714,16 +738,22 @@ namespace OpenSim.Framework
714 data["height"] = OSD.FromReal(m_avatarHeight); 738 data["height"] = OSD.FromReal(m_avatarHeight);
715 739
716 // Wearables 740 // Wearables
741 //
742 // This will send as many or as few wearables as we have, unless a count
743 // is given. Used for legacy (pre 0.4) versions.
744 int count = ctx.WearablesCount;
745 if (ctx.WearablesCount == -1)
746 count = m_wearables.Length;
747 OSDArray wears = new OSDArray(count);
748 for (int i = 0; i < count; i++)
749 {
750 AvatarWearable dummyWearable = new AvatarWearable();
717 751
718 int wearsCount; 752 if (i < m_wearables.Length)
719 if(PackLegacyWearables) 753 wears.Add(m_wearables[i].Pack());
720 wearsCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; 754 else
721 else 755 wears.Add(dummyWearable.Pack());
722 wearsCount = AvatarWearable.MAX_WEARABLES; 756 }
723
724 OSDArray wears = new OSDArray(wearsCount);
725 for (int i = 0; i < wearsCount; i++)
726 wears.Add(m_wearables[i].Pack());
727 data["wearables"] = wears; 757 data["wearables"] = wears;
728 758
729 // Avatar Textures 759 // Avatar Textures
@@ -737,6 +767,13 @@ namespace OpenSim.Framework
737 } 767 }
738 data["textures"] = textures; 768 data["textures"] = textures;
739 769
770 if (m_cacheitems != null)
771 {
772 OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems);
773 if (baked != null)
774 data["bakedcache"] = baked;
775 }
776
740 // Visual Parameters 777 // Visual Parameters
741 OSDBinary visualparams = new OSDBinary(m_visualparams); 778 OSDBinary visualparams = new OSDBinary(m_visualparams);
742 data["visualparams"] = visualparams; 779 data["visualparams"] = visualparams;
@@ -774,8 +811,8 @@ namespace OpenSim.Framework
774 OSDArray wears = (OSDArray)(data["wearables"]); 811 OSDArray wears = (OSDArray)(data["wearables"]);
775 812
776 int count = wears.Count; 813 int count = wears.Count;
777 if (count > AvatarWearable.MAX_WEARABLES) 814
778 count = AvatarWearable.MAX_WEARABLES; 815 m_wearables = new AvatarWearable[count];
779 816
780 for (int i = 0; i < count; i++) 817 for (int i = 0; i < count; i++)
781 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 818 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
@@ -803,6 +840,12 @@ namespace OpenSim.Framework
803 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); 840 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
804 } 841 }
805 842
843 if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array)
844 {
845 OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]);
846 m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
847 }
848
806 // Visual Parameters 849 // Visual Parameters
807 SetDefaultParams(); 850 SetDefaultParams();
808 if ((data != null) && (data["visualparams"] != null)) 851 if ((data != null) && (data["visualparams"] != null))
@@ -824,7 +867,7 @@ namespace OpenSim.Framework
824 { 867 {
825 AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); 868 AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
826 AppendAttachment(att); 869 AppendAttachment(att);
827 870
828// m_log.DebugFormat( 871// m_log.DebugFormat(
829// "[AVATAR APPEARANCE]: Unpacked attachment itemID {0}, assetID {1}, point {2}", 872// "[AVATAR APPEARANCE]: Unpacked attachment itemID {0}, assetID {1}, point {2}",
830// att.ItemID, att.AssetID, att.AttachPoint); 873// att.ItemID, att.AssetID, att.AttachPoint);
@@ -1601,14 +1644,14 @@ namespace OpenSim.Framework
1601 SHAPE_EYELID_INNER_CORNER_UP = 214, 1644 SHAPE_EYELID_INNER_CORNER_UP = 214,
1602 SKIRT_SKIRT_RED = 215, 1645 SKIRT_SKIRT_RED = 215,
1603 SKIRT_SKIRT_GREEN = 216, 1646 SKIRT_SKIRT_GREEN = 216,
1604 SKIRT_SKIRT_BLUE = 217, 1647 SKIRT_SKIRT_BLUE = 217,
1605 1648
1606 /// <summary> 1649 /// <summary>
1607 /// Avatar Physics section. These are 0 type visual params which get transmitted. 1650 /// Avatar Physics section. These are 0 type visual params which get transmitted.
1608 /// </summary> 1651 /// </summary>
1609 1652
1610 /// <summary> 1653 /// <summary>
1611 /// Breast Part 1 1654 /// Breast Part 1
1612 /// </summary> 1655 /// </summary>
1613 BREAST_PHYSICS_MASS = 218, 1656 BREAST_PHYSICS_MASS = 218,
1614 BREAST_PHYSICS_GRAVITY = 219, 1657 BREAST_PHYSICS_GRAVITY = 219,
@@ -1652,7 +1695,12 @@ namespace OpenSim.Framework
1652 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247, 1695 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
1653 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248, 1696 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
1654 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249, 1697 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
1655 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250 1698 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250,
1699
1700 // Ubit: 07/96/2013 new parameters
1701 _APPEARANCEMESSAGE_VERSION = 251, //ID 11000
1702
1703 SHAPE_HOVER = 252, //ID 11001
1656 } 1704 }
1657 #endregion 1705 #endregion
1658 } 1706 }
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index e7615f2..0e8f960 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -62,12 +62,16 @@ namespace OpenSim.Framework
62 public static readonly int UNDERSHIRT = 10; 62 public static readonly int UNDERSHIRT = 10;
63 public static readonly int UNDERPANTS = 11; 63 public static readonly int UNDERPANTS = 11;
64 public static readonly int SKIRT = 12; 64 public static readonly int SKIRT = 12;
65
66 public static readonly int MAX_BASICWEARABLES = 13;
67
65 public static readonly int ALPHA = 13; 68 public static readonly int ALPHA = 13;
66 public static readonly int TATTOO = 14; 69 public static readonly int TATTOO = 14;
67 70
68 public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15; 71 public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15;
69 public static readonly int PHYSICS = 15; 72// public static readonly int PHYSICS = 15;
70 public static readonly int MAX_WEARABLES = 16; 73// public static int MAX_WEARABLES = 16;
74
71 75
72 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); 76 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
73 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); 77 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
@@ -78,6 +82,9 @@ namespace OpenSim.Framework
78 public static readonly UUID DEFAULT_SKIN_ITEM = new UUID("77c41e39-38f9-f75a-024e-585989bfabc9"); 82 public static readonly UUID DEFAULT_SKIN_ITEM = new UUID("77c41e39-38f9-f75a-024e-585989bfabc9");
79 public static readonly UUID DEFAULT_SKIN_ASSET = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"); 83 public static readonly UUID DEFAULT_SKIN_ASSET = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb");
80 84
85 public static readonly UUID DEFAULT_EYES_ITEM = new UUID("cdc31054-eed8-4021-994f-4e0c6e861b50");
86 public static readonly UUID DEFAULT_EYES_ASSET = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
87
81 public static readonly UUID DEFAULT_SHIRT_ITEM = new UUID("77c41e39-38f9-f75a-0000-585989bf0000"); 88 public static readonly UUID DEFAULT_SHIRT_ITEM = new UUID("77c41e39-38f9-f75a-0000-585989bf0000");
82 public static readonly UUID DEFAULT_SHIRT_ASSET = new UUID("00000000-38f9-1111-024e-222222111110"); 89 public static readonly UUID DEFAULT_SHIRT_ASSET = new UUID("00000000-38f9-1111-024e-222222111110");
83 90
@@ -89,7 +96,7 @@ namespace OpenSim.Framework
89 96
90// public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1"); 97// public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1");
91// public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007"); 98// public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007");
92 99
93 protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); 100 protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>();
94 protected List<UUID> m_ids = new List<UUID>(); 101 protected List<UUID> m_ids = new List<UUID>();
95 102
@@ -221,33 +228,40 @@ namespace OpenSim.Framework
221 { 228 {
222 get 229 get
223 { 230 {
224 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these 231 // We use the legacy count here because this is just a fallback anyway
225 for (int i = 0; i < MAX_WEARABLES; i++) 232 AvatarWearable[] defaultWearables = new AvatarWearable[LEGACY_VERSION_MAX_WEARABLES];
233 for (int i = 0; i < LEGACY_VERSION_MAX_WEARABLES; i++)
226 { 234 {
227 defaultWearables[i] = new AvatarWearable(); 235 defaultWearables[i] = new AvatarWearable();
228 } 236 }
229 237
230 // Body 238 // Body
231 defaultWearables[BODY].Add(DEFAULT_BODY_ITEM, DEFAULT_BODY_ASSET); 239 defaultWearables[BODY].Add(DEFAULT_BODY_ITEM, DEFAULT_BODY_ASSET);
232 240
233 // Hair 241 // Hair
234 defaultWearables[HAIR].Add(DEFAULT_HAIR_ITEM, DEFAULT_HAIR_ASSET); 242 defaultWearables[HAIR].Add(DEFAULT_HAIR_ITEM, DEFAULT_HAIR_ASSET);
235 243
236 // Skin 244 // Skin
237 defaultWearables[SKIN].Add(DEFAULT_SKIN_ITEM, DEFAULT_SKIN_ASSET); 245 defaultWearables[SKIN].Add(DEFAULT_SKIN_ITEM, DEFAULT_SKIN_ASSET);
238 246
247 // Eyes
248 defaultWearables[EYES].Add(DEFAULT_EYES_ITEM, DEFAULT_EYES_ASSET);
249
239 // Shirt 250 // Shirt
240 defaultWearables[SHIRT].Add(DEFAULT_SHIRT_ITEM, DEFAULT_SHIRT_ASSET); 251 defaultWearables[SHIRT].Add(DEFAULT_SHIRT_ITEM, DEFAULT_SHIRT_ASSET);
241 252
242 // Pants 253 // Pants
243 defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET); 254 defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET);
244 255
245// // Alpha 256// // Alpha
246// defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET); 257// defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET);
247 258
248// // Tattoo 259 // // Tattoo
249// defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET); 260 // defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
250 261
262 // // Physics
263 // defaultWearables[PHYSICS].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
264
251 return defaultWearables; 265 return defaultWearables;
252 } 266 }
253 } 267 }
diff --git a/OpenSim/Framework/BasicDOSProtector.cs b/OpenSim/Framework/BasicDOSProtector.cs
index 89bfa94..f1ff18f 100644
--- a/OpenSim/Framework/BasicDOSProtector.cs
+++ b/OpenSim/Framework/BasicDOSProtector.cs
@@ -31,7 +31,7 @@ using log4net;
31 31
32namespace OpenSim.Framework 32namespace OpenSim.Framework
33{ 33{
34 34
35 public class BasicDOSProtector 35 public class BasicDOSProtector
36 { 36 {
37 public enum ThrottleAction 37 public enum ThrottleAction
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
43 private readonly BasicDosProtectorOptions _options; 43 private readonly BasicDosProtectorOptions _options;
44 private readonly Dictionary<string, CircularBuffer<int>> _deeperInspection; // per client request checker 44 private readonly Dictionary<string, CircularBuffer<int>> _deeperInspection; // per client request checker
45 private readonly Dictionary<string, int> _tempBlocked; // blocked list 45 private readonly Dictionary<string, int> _tempBlocked; // blocked list
46 private readonly Dictionary<string, int> _sessions; 46 private readonly Dictionary<string, int> _sessions;
47 private readonly System.Timers.Timer _forgetTimer; // Cleanup timer 47 private readonly System.Timers.Timer _forgetTimer; // Cleanup timer
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 private readonly System.Threading.ReaderWriterLockSlim _blockLockSlim = new System.Threading.ReaderWriterLockSlim(); 49 private readonly System.Threading.ReaderWriterLockSlim _blockLockSlim = new System.Threading.ReaderWriterLockSlim();
@@ -133,7 +133,7 @@ namespace OpenSim.Framework
133 else 133 else
134 throw new System.Security.SecurityException("Throttled"); 134 throw new System.Security.SecurityException("Throttled");
135 } 135 }
136 136
137 _blockLockSlim.ExitReadLock(); 137 _blockLockSlim.ExitReadLock();
138 138
139 lock (_generalRequestTimes) 139 lock (_generalRequestTimes)
@@ -169,10 +169,10 @@ namespace OpenSim.Framework
169 _blockLockSlim.ExitWriteLock(); 169 _blockLockSlim.ExitWriteLock();
170 170
171 } 171 }
172 172
173 173
174 } 174 }
175 else 175 else
176 ProcessConcurrency(key, endpoint); 176 ProcessConcurrency(key, endpoint);
177 } 177 }
178 if (_generalRequestTimes.Size == _generalRequestTimes.Capacity && 178 if (_generalRequestTimes.Size == _generalRequestTimes.Capacity &&
@@ -194,7 +194,7 @@ namespace OpenSim.Framework
194 _sessionLockSlim.EnterWriteLock(); 194 _sessionLockSlim.EnterWriteLock();
195 if (_sessions.ContainsKey(key)) 195 if (_sessions.ContainsKey(key))
196 _sessions[key] = _sessions[key] + 1; 196 _sessions[key] = _sessions[key] + 1;
197 else 197 else
198 _sessions.Add(key,1); 198 _sessions.Add(key,1);
199 _sessionLockSlim.ExitWriteLock(); 199 _sessionLockSlim.ExitWriteLock();
200 } 200 }
@@ -209,7 +209,7 @@ namespace OpenSim.Framework
209 } 209 }
210 else 210 else
211 _sessions.Add(key, 1); 211 _sessions.Add(key, 1);
212 212
213 _sessionLockSlim.ExitWriteLock(); 213 _sessionLockSlim.ExitWriteLock();
214 } 214 }
215 215
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index d11ad11..2461049 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Framework
65 65
66 if (m_pqueue.Count > 0) 66 if (m_pqueue.Count > 0)
67 return m_pqueue.Dequeue(); 67 return m_pqueue.Dequeue();
68 68
69 if (m_queue.Count > 0) 69 if (m_queue.Count > 0)
70 return m_queue.Dequeue(); 70 return m_queue.Dequeue();
71 return default(T); 71 return default(T);
@@ -76,10 +76,10 @@ namespace OpenSim.Framework
76 { 76 {
77 lock (m_queueSync) 77 lock (m_queueSync)
78 { 78 {
79 bool success = true; 79 if (m_queue.Count < 1 && m_pqueue.Count < 1)
80 while (m_queue.Count < 1 && m_pqueue.Count < 1 && success)
81 { 80 {
82 success = Monitor.Wait(m_queueSync, msTimeout); 81 if(!Monitor.Wait(m_queueSync, msTimeout))
82 return default(T);
83 } 83 }
84 84
85 if (m_pqueue.Count > 0) 85 if (m_pqueue.Count > 0)
diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs
index 31cab4a..3ca85d7 100644
--- a/OpenSim/Framework/Cache.cs
+++ b/OpenSim/Framework/Cache.cs
@@ -89,14 +89,14 @@ namespace OpenSim.Framework
89 public CacheItemBase(string index) 89 public CacheItemBase(string index)
90 { 90 {
91 uuid = index; 91 uuid = index;
92 entered = DateTime.Now; 92 entered = DateTime.UtcNow;
93 lastUsed = entered; 93 lastUsed = entered;
94 } 94 }
95 95
96 public CacheItemBase(string index, DateTime ttl) 96 public CacheItemBase(string index, DateTime ttl)
97 { 97 {
98 uuid = index; 98 uuid = index;
99 entered = DateTime.Now; 99 entered = DateTime.UtcNow;
100 lastUsed = entered; 100 lastUsed = entered;
101 expires = ttl; 101 expires = ttl;
102 } 102 }
@@ -215,6 +215,8 @@ namespace OpenSim.Framework
215 private CacheFlags m_Flags = 0; 215 private CacheFlags m_Flags = 0;
216 private int m_Size = 1024; 216 private int m_Size = 1024;
217 private TimeSpan m_DefaultTTL = new TimeSpan(0); 217 private TimeSpan m_DefaultTTL = new TimeSpan(0);
218 private DateTime m_nextExpire;
219 private TimeSpan m_expiresTime = new TimeSpan(0,0,30);
218 public ExpireDelegate OnExpire; 220 public ExpireDelegate OnExpire;
219 221
220 // Comparison interfaces 222 // Comparison interfaces
@@ -233,6 +235,21 @@ namespace OpenSim.Framework
233 return(a.lastUsed.CompareTo(b.lastUsed)); 235 return(a.lastUsed.CompareTo(b.lastUsed));
234 } 236 }
235 } 237 }
238 // same as above, reverse order
239 private class SortLRUrev : IComparer<CacheItemBase>
240 {
241 public int Compare(CacheItemBase a, CacheItemBase b)
242 {
243 if (a == null && b == null)
244 return 0;
245 if (a == null)
246 return -1;
247 if (b == null)
248 return 1;
249
250 return(b.lastUsed.CompareTo(a.lastUsed));
251 }
252 }
236 253
237 // Convenience constructors 254 // Convenience constructors
238 // 255 //
@@ -241,6 +258,8 @@ namespace OpenSim.Framework
241 m_Strategy = CacheStrategy.Balanced; 258 m_Strategy = CacheStrategy.Balanced;
242 m_Medium = CacheMedium.Memory; 259 m_Medium = CacheMedium.Memory;
243 m_Flags = 0; 260 m_Flags = 0;
261 m_nextExpire = DateTime.UtcNow + m_expiresTime;
262 m_Strategy = CacheStrategy.Aggressive;
244 } 263 }
245 264
246 public Cache(CacheMedium medium) : 265 public Cache(CacheMedium medium) :
@@ -295,19 +314,23 @@ namespace OpenSim.Framework
295 { 314 {
296 lock (m_Index) 315 lock (m_Index)
297 { 316 {
298 if (Count <= Size) 317 int target = newSize;
299 return; 318 if(m_Strategy == CacheStrategy.Aggressive)
319 target = (int)(newSize * 0.9);
300 320
301 m_Index.Sort(new SortLRU()); 321 if(Count > target)
302 m_Index.Reverse(); 322 {
323 m_Index.Sort(new SortLRUrev());
303 324
304 m_Index.RemoveRange(newSize, Count - newSize); 325 m_Index.RemoveRange(newSize, Count - target);
305 m_Size = newSize;
306 326
307 m_Lookup.Clear(); 327 m_Lookup.Clear();
328
329 foreach (CacheItemBase item in m_Index)
330 m_Lookup[item.uuid] = item;
331 }
332 m_Size = newSize;
308 333
309 foreach (CacheItemBase item in m_Index)
310 m_Lookup[item.uuid] = item;
311 } 334 }
312 } 335 }
313 336
@@ -333,10 +356,10 @@ namespace OpenSim.Framework
333 Expire(true); 356 Expire(true);
334 return null; 357 return null;
335 } 358 }
336 359
337 item.hits++; 360 item.hits++;
338 item.lastUsed = DateTime.Now; 361 item.lastUsed = DateTime.UtcNow;
339 362
340 Expire(true); 363 Expire(true);
341 } 364 }
342 365
@@ -361,14 +384,15 @@ namespace OpenSim.Framework
361 // 384 //
362 public virtual Object Get(string index, FetchDelegate fetch) 385 public virtual Object Get(string index, FetchDelegate fetch)
363 { 386 {
364 Object item = Get(index); 387 CacheItemBase item = GetItem(index);
365 if (item != null) 388 if (item != null)
366 return item; 389 return item.Retrieve();
367 390
368 Object data = fetch(index); 391 Object data = fetch(index);
392
369 if (data == null) 393 if (data == null)
370 { 394 {
371 if ((m_Flags & CacheFlags.CacheMissing) != 0) 395 if((m_Flags & CacheFlags.CacheMissing) != 0)
372 { 396 {
373 lock (m_Index) 397 lock (m_Index)
374 { 398 {
@@ -384,7 +408,6 @@ namespace OpenSim.Framework
384 } 408 }
385 409
386 Store(index, data); 410 Store(index, data);
387
388 return data; 411 return data;
389 } 412 }
390 413
@@ -442,9 +465,9 @@ namespace OpenSim.Framework
442 item = GetItem(index); 465 item = GetItem(index);
443 466
444 item.hits++; 467 item.hits++;
445 item.lastUsed = DateTime.Now; 468 item.lastUsed = DateTime.UtcNow;
446 if (m_DefaultTTL.Ticks != 0) 469 if (m_DefaultTTL.Ticks != 0)
447 item.expires = DateTime.Now + m_DefaultTTL; 470 item.expires = DateTime.UtcNow + m_DefaultTTL;
448 471
449 item.Store(data); 472 item.Store(data);
450 } 473 }
@@ -455,7 +478,7 @@ namespace OpenSim.Framework
455 parameters); 478 parameters);
456 479
457 if (m_DefaultTTL.Ticks != 0) 480 if (m_DefaultTTL.Ticks != 0)
458 item.expires = DateTime.Now + m_DefaultTTL; 481 item.expires = DateTime.UtcNow + m_DefaultTTL;
459 482
460 m_Index.Add(item); 483 m_Index.Add(item);
461 m_Lookup[index] = item; 484 m_Lookup[index] = item;
@@ -476,10 +499,14 @@ namespace OpenSim.Framework
476 if (getting && (m_Strategy == CacheStrategy.Aggressive)) 499 if (getting && (m_Strategy == CacheStrategy.Aggressive))
477 return; 500 return;
478 501
502 DateTime now = DateTime.UtcNow;
503 if(now < m_nextExpire)
504 return;
505
506 m_nextExpire = now + m_expiresTime;
507
479 if (m_DefaultTTL.Ticks != 0) 508 if (m_DefaultTTL.Ticks != 0)
480 { 509 {
481 DateTime now= DateTime.Now;
482
483 foreach (CacheItemBase item in new List<CacheItemBase>(m_Index)) 510 foreach (CacheItemBase item in new List<CacheItemBase>(m_Index))
484 { 511 {
485 if (item.expires.Ticks == 0 || 512 if (item.expires.Ticks == 0 ||
@@ -494,15 +521,13 @@ namespace OpenSim.Framework
494 switch (m_Strategy) 521 switch (m_Strategy)
495 { 522 {
496 case CacheStrategy.Aggressive: 523 case CacheStrategy.Aggressive:
497 if (Count < Size) 524 int target = (int)((float)Size * 0.9);
525 if (Count < target) // Cover ridiculous cache sizes
498 return; 526 return;
499 527
500 m_Index.Sort(new SortLRU()); 528 target = (int)((float)Size * 0.8);
501 m_Index.Reverse();
502 529
503 int target = (int)((float)Size * 0.9); 530 m_Index.Sort(new SortLRUrev());
504 if (target == Count) // Cover ridiculous cache sizes
505 return;
506 531
507 ExpireDelegate doExpire = OnExpire; 532 ExpireDelegate doExpire = OnExpire;
508 533
diff --git a/OpenSim/Framework/CapsUtil.cs b/OpenSim/Framework/CapsUtil.cs
index 4baf505..020f6e2 100644
--- a/OpenSim/Framework/CapsUtil.cs
+++ b/OpenSim/Framework/CapsUtil.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
43 { 43 {
44 return "CAPS/" + capsObjectPath + "0000/"; 44 return "CAPS/" + capsObjectPath + "0000/";
45 } 45 }
46 46
47 /// <summary> 47 /// <summary>
48 /// Get a random CAPS object path component that will be used as the identifying part of all future CAPS requests 48 /// Get a random CAPS object path component that will be used as the identifying part of all future CAPS requests
49 /// </summary> 49 /// </summary>
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 1504f21..ee5007a 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -61,8 +61,8 @@ namespace OpenSim.Framework
61 { 61 {
62 UUID AgentID { get; set; } 62 UUID AgentID { get; set; }
63 63
64 OSDMap Pack(); 64 OSDMap Pack(EntityTransferContext ctx);
65 void Unpack(OSDMap map, IScene scene); 65 void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx);
66 } 66 }
67 67
68 /// <summary> 68 /// <summary>
@@ -89,13 +89,16 @@ namespace OpenSim.Framework
89 public Vector3 AtAxis; 89 public Vector3 AtAxis;
90 public Vector3 LeftAxis; 90 public Vector3 LeftAxis;
91 public Vector3 UpAxis; 91 public Vector3 UpAxis;
92 //public int GodLevel;
93 public OSD GodData = null;
92 public bool ChangedGrid; 94 public bool ChangedGrid;
93 95
94 // This probably shouldn't be here 96 // This probably shouldn't be here
95 public byte[] Throttles; 97 public byte[] Throttles;
96 98
99 public Dictionary<ulong, string> ChildrenCapSeeds = null;
97 100
98 public OSDMap Pack() 101 public OSDMap Pack(EntityTransferContext ctx)
99 { 102 {
100 OSDMap args = new OSDMap(); 103 OSDMap args = new OSDMap();
101 args["message_type"] = OSD.FromString("AgentPosition"); 104 args["message_type"] = OSD.FromString("AgentPosition");
@@ -115,14 +118,37 @@ namespace OpenSim.Framework
115 118
116 args["far"] = OSD.FromReal(Far); 119 args["far"] = OSD.FromReal(Far);
117 args["changed_grid"] = OSD.FromBoolean(ChangedGrid); 120 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
121 //args["god_level"] = OSD.FromString(GodLevel.ToString());
122 if(GodData != null)
123 {
124 args["god_data"] = GodData;
125 OSDMap g = (OSDMap)GodData;
126 // Set legacy value
127 // TODO: remove after 0.9 is superseded
128 if (g.ContainsKey("ViewerUiIsGod"))
129 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;
130 }
118 131
119 if ((Throttles != null) && (Throttles.Length > 0)) 132 if ((Throttles != null) && (Throttles.Length > 0))
120 args["throttles"] = OSD.FromBinary(Throttles); 133 args["throttles"] = OSD.FromBinary(Throttles);
121 134
135 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
136 {
137 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
138 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
139 {
140 OSDMap pair = new OSDMap();
141 pair["handle"] = OSD.FromString(kvp.Key.ToString());
142 pair["seed"] = OSD.FromString(kvp.Value);
143 childrenSeeds.Add(pair);
144 }
145 args["children_seeds"] = childrenSeeds;
146 }
147
122 return args; 148 return args;
123 } 149 }
124 150
125 public void Unpack(OSDMap args, IScene scene) 151 public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
126 { 152 {
127 if (args.ContainsKey("region_handle")) 153 if (args.ContainsKey("region_handle"))
128 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); 154 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -160,11 +186,40 @@ namespace OpenSim.Framework
160 if (args["changed_grid"] != null) 186 if (args["changed_grid"] != null)
161 ChangedGrid = args["changed_grid"].AsBoolean(); 187 ChangedGrid = args["changed_grid"].AsBoolean();
162 188
189 //if (args["god_level"] != null)
190 // Int32.TryParse(args["god_level"].AsString(), out GodLevel);
191 if (args.ContainsKey("god_data") && args["god_data"] != null)
192 GodData = args["god_data"];
193
163 if (args["far"] != null) 194 if (args["far"] != null)
164 Far = (float)(args["far"].AsReal()); 195 Far = (float)(args["far"].AsReal());
165 196
166 if (args["throttles"] != null) 197 if (args["throttles"] != null)
167 Throttles = args["throttles"].AsBinary(); 198 Throttles = args["throttles"].AsBinary();
199
200 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
201 (args["children_seeds"].Type == OSDType.Array))
202 {
203 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
204 ChildrenCapSeeds = new Dictionary<ulong, string>();
205 foreach (OSD o in childrenSeeds)
206 {
207 if (o.Type == OSDType.Map)
208 {
209 ulong handle = 0;
210 string seed = "";
211 OSDMap pair = (OSDMap)o;
212 if (pair["handle"] != null)
213 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
214 continue;
215 if (pair["seed"] != null)
216 seed = pair["seed"].AsString();
217 if (!ChildrenCapSeeds.ContainsKey(handle))
218 ChildrenCapSeeds.Add(handle, seed);
219 }
220 }
221 }
222
168 } 223 }
169 224
170 /// <summary> 225 /// <summary>
@@ -294,7 +349,7 @@ namespace OpenSim.Framework
294 public Vector3 UpAxis; 349 public Vector3 UpAxis;
295 350
296 /// <summary> 351 /// <summary>
297 /// Signal on a V2 teleport that Scene.IncomingChildAgentDataUpdate(AgentData ad) should wait for the 352 /// Signal on a V2 teleport that Scene.IncomingChildAgentDataUpdate(AgentData ad) should wait for the
298 /// scene presence to become root (triggered when the viewer sends a CompleteAgentMovement UDP packet after 353 /// scene presence to become root (triggered when the viewer sends a CompleteAgentMovement UDP packet after
299 /// establishing the connection triggered by it's receipt of a TeleportFinish EQ message). 354 /// establishing the connection triggered by it's receipt of a TeleportFinish EQ message).
300 /// </summary> 355 /// </summary>
@@ -310,18 +365,24 @@ namespace OpenSim.Framework
310 public Quaternion BodyRotation; 365 public Quaternion BodyRotation;
311 public uint ControlFlags; 366 public uint ControlFlags;
312 public float EnergyLevel; 367 public float EnergyLevel;
313 public Byte GodLevel; 368 public OSD GodData = null;
369 //public Byte GodLevel;
314 public bool AlwaysRun; 370 public bool AlwaysRun;
315 public UUID PreyAgent; 371 public UUID PreyAgent;
316 public Byte AgentAccess; 372 public Byte AgentAccess;
317 public UUID ActiveGroupID; 373 public UUID ActiveGroupID;
374 public string ActiveGroupName;
375 public string ActiveGroupTitle = null;
376 public UUID agentCOF;
377 public byte CrossingFlags;
378 public byte CrossExtraFlags;
318 379
319 public AgentGroupData[] Groups; 380 public Dictionary<ulong, string> ChildrenCapSeeds = null;
320 public Animation[] Anims; 381 public Animation[] Anims;
321 public Animation DefaultAnim = null; 382 public Animation DefaultAnim = null;
322 public Animation AnimState = null; 383 public Animation AnimState = null;
384 public Byte MotionState = 0;
323 385
324 public UUID GranterID;
325 public UUID ParentPart; 386 public UUID ParentPart;
326 public Vector3 SitOffset; 387 public Vector3 SitOffset;
327 388
@@ -334,12 +395,6 @@ namespace OpenSim.Framework
334 MethodBase.GetCurrentMethod().DeclaringType); 395 MethodBase.GetCurrentMethod().DeclaringType);
335// DEBUG OFF 396// DEBUG OFF
336 397
337/*
338 public byte[] AgentTextures;
339 public byte[] VisualParams;
340 public UUID[] Wearables;
341 public AvatarAttachment[] Attachments;
342*/
343 // Scripted 398 // Scripted
344 public ControllerData[] Controllers; 399 public ControllerData[] Controllers;
345 400
@@ -349,7 +404,9 @@ namespace OpenSim.Framework
349 public List<ISceneObject> AttachmentObjects; 404 public List<ISceneObject> AttachmentObjects;
350 public List<string> AttachmentObjectStates; 405 public List<string> AttachmentObjectStates;
351 406
352 public virtual OSDMap Pack() 407 public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
408
409 public virtual OSDMap Pack(EntityTransferContext ctx)
353 { 410 {
354// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); 411// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
355 412
@@ -384,19 +441,39 @@ namespace OpenSim.Framework
384 args["control_flags"] = OSD.FromString(ControlFlags.ToString()); 441 args["control_flags"] = OSD.FromString(ControlFlags.ToString());
385 442
386 args["energy_level"] = OSD.FromReal(EnergyLevel); 443 args["energy_level"] = OSD.FromReal(EnergyLevel);
387 args["god_level"] = OSD.FromString(GodLevel.ToString()); 444 //args["god_level"] = OSD.FromString(GodLevel.ToString());
445 if(GodData != null)
446 {
447 args["god_data"] = GodData;
448 OSDMap g = (OSDMap)GodData;
449 if (g.ContainsKey("ViewerUiIsGod"))
450 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;;
451 }
388 args["always_run"] = OSD.FromBoolean(AlwaysRun); 452 args["always_run"] = OSD.FromBoolean(AlwaysRun);
389 args["prey_agent"] = OSD.FromUUID(PreyAgent); 453 args["prey_agent"] = OSD.FromUUID(PreyAgent);
390 args["agent_access"] = OSD.FromString(AgentAccess.ToString()); 454 args["agent_access"] = OSD.FromString(AgentAccess.ToString());
391 455
456 args["agent_cof"] = OSD.FromUUID(agentCOF);
457 args["crossingflags"] = OSD.FromInteger(CrossingFlags);
458 if(CrossingFlags != 0)
459 args["crossExtraFlags"] = OSD.FromInteger(CrossExtraFlags);
460
392 args["active_group_id"] = OSD.FromUUID(ActiveGroupID); 461 args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
393 462 args["active_group_name"] = OSD.FromString(ActiveGroupName);
394 if ((Groups != null) && (Groups.Length > 0)) 463 if(ActiveGroupTitle != null)
464 args["active_group_title"] = OSD.FromString(ActiveGroupTitle);
465
466 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
395 { 467 {
396 OSDArray groups = new OSDArray(Groups.Length); 468 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
397 foreach (AgentGroupData agd in Groups) 469 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
398 groups.Add(agd.PackUpdateMessage()); 470 {
399 args["groups"] = groups; 471 OSDMap pair = new OSDMap();
472 pair["handle"] = OSD.FromString(kvp.Key.ToString());
473 pair["seed"] = OSD.FromString(kvp.Value);
474 childrenSeeds.Add(pair);
475 }
476 args["children_seeds"] = childrenSeeds;
400 } 477 }
401 478
402 if ((Anims != null) && (Anims.Length > 0)) 479 if ((Anims != null) && (Anims.Length > 0))
@@ -417,57 +494,28 @@ namespace OpenSim.Framework
417 args["animation_state"] = AnimState.PackUpdateMessage(); 494 args["animation_state"] = AnimState.PackUpdateMessage();
418 } 495 }
419 496
420 if (Appearance != null) 497 if (MovementAnimationOverRides.Count > 0)
421 args["packed_appearance"] = Appearance.Pack();
422
423 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
424 //{
425 // OSDArray textures = new OSDArray(AgentTextures.Length);
426 // foreach (UUID uuid in AgentTextures)
427 // textures.Add(OSD.FromUUID(uuid));
428 // args["agent_textures"] = textures;
429 //}
430
431 // The code to pack textures, visuals, wearables and attachments
432 // should be removed; packed appearance contains the full appearance
433 // This is retained for backward compatibility only
434 if (Appearance.Texture != null)
435 { 498 {
436 byte[] rawtextures = Appearance.Texture.GetBytes(); 499 OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count);
437 args["texture_entry"] = OSD.FromBinary(rawtextures); 500 {
501 foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides)
502 {
503 OSDMap ao = new OSDMap(2);
504 ao["state"] = OSD.FromString(kvp.Key);
505 ao["uuid"] = OSD.FromUUID(kvp.Value);
506 AOs.Add(ao);
507 }
508 }
509 args["movementAO"] = AOs;
438 } 510 }
439 511
440 if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) 512 if (MotionState != 0)
441 args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
442
443 // We might not pass this in all cases...
444 if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
445 { 513 {
446 int wearsCount; 514 args["motion_state"] = OSD.FromInteger(MotionState);
447 if(Appearance.PackLegacyWearables)
448 wearsCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES;
449 else
450 wearsCount = AvatarWearable.MAX_WEARABLES;
451
452 if(wearsCount > Appearance.Wearables.Length)
453 wearsCount = Appearance.Wearables.Length;
454
455 OSDArray wears = new OSDArray(wearsCount);
456 for(int i = 0; i < wearsCount ; i++)
457 wears.Add(Appearance.Wearables[i].Pack());
458
459 args["wearables"] = wears;
460 } 515 }
461 516
462 List<AvatarAttachment> attachments = Appearance.GetAttachments(); 517 if (Appearance != null)
463 if ((attachments != null) && (attachments.Count > 0)) 518 args["packed_appearance"] = Appearance.Pack(ctx);
464 {
465 OSDArray attachs = new OSDArray(attachments.Count);
466 foreach (AvatarAttachment att in attachments)
467 attachs.Add(att.Pack());
468 args["attachments"] = attachs;
469 }
470 // End of code to remove
471 519
472 if ((Controllers != null) && (Controllers.Length > 0)) 520 if ((Controllers != null) && (Controllers.Length > 0))
473 { 521 {
@@ -516,7 +564,7 @@ namespace OpenSim.Framework
516 /// Avoiding reflection makes it painful to write, but that's the price! 564 /// Avoiding reflection makes it painful to write, but that's the price!
517 /// </summary> 565 /// </summary>
518 /// <param name="hash"></param> 566 /// <param name="hash"></param>
519 public virtual void Unpack(OSDMap args, IScene scene) 567 public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
520 { 568 {
521 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); 569 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
522 570
@@ -580,8 +628,11 @@ namespace OpenSim.Framework
580 if (args["energy_level"] != null) 628 if (args["energy_level"] != null)
581 EnergyLevel = (float)(args["energy_level"].AsReal()); 629 EnergyLevel = (float)(args["energy_level"].AsReal());
582 630
583 if (args["god_level"] != null) 631 //if (args["god_level"] != null)
584 Byte.TryParse(args["god_level"].AsString(), out GodLevel); 632 // Byte.TryParse(args["god_level"].AsString(), out GodLevel);
633
634 if (args.ContainsKey("god_data") && args["god_data"] != null)
635 GodData = args["god_data"];
585 636
586 if (args["always_run"] != null) 637 if (args["always_run"] != null)
587 AlwaysRun = args["always_run"].AsBoolean(); 638 AlwaysRun = args["always_run"].AsBoolean();
@@ -592,19 +643,46 @@ namespace OpenSim.Framework
592 if (args["agent_access"] != null) 643 if (args["agent_access"] != null)
593 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); 644 Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
594 645
595 if (args["active_group_id"] != null) 646 if (args.ContainsKey("agent_cof") && args["agent_cof"] != null)
647 agentCOF = args["agent_cof"].AsUUID();
648
649 if (args.ContainsKey("crossingflags") && args["crossingflags"] != null)
650 CrossingFlags = (byte)args["crossingflags"].AsInteger();
651
652 if(CrossingFlags != 0)
653 {
654 if (args.ContainsKey("crossExtraFlags") && args["crossExtraFlags"] != null)
655 CrossExtraFlags = (byte)args["crossExtraFlags"].AsInteger();
656 }
657
658 if (args.ContainsKey("active_group_id") && args["active_group_id"] != null)
596 ActiveGroupID = args["active_group_id"].AsUUID(); 659 ActiveGroupID = args["active_group_id"].AsUUID();
597 660
598 if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) 661 if (args.ContainsKey("active_group_name") && args["active_group_name"] != null)
662 ActiveGroupName = args["active_group_name"].AsString();
663
664 if(args.ContainsKey("active_group_title") && args["active_group_title"] != null)
665 ActiveGroupTitle = args["active_group_title"].AsString();
666
667 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
668 (args["children_seeds"].Type == OSDType.Array))
599 { 669 {
600 OSDArray groups = (OSDArray)(args["groups"]); 670 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
601 Groups = new AgentGroupData[groups.Count]; 671 ChildrenCapSeeds = new Dictionary<ulong, string>();
602 int i = 0; 672 foreach (OSD o in childrenSeeds)
603 foreach (OSD o in groups)
604 { 673 {
605 if (o.Type == OSDType.Map) 674 if (o.Type == OSDType.Map)
606 { 675 {
607 Groups[i++] = new AgentGroupData((OSDMap)o); 676 ulong handle = 0;
677 string seed = "";
678 OSDMap pair = (OSDMap)o;
679 if (pair["handle"] != null)
680 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
681 continue;
682 if (pair["seed"] != null)
683 seed = pair["seed"].AsString();
684 if (!ChildrenCapSeeds.ContainsKey(handle))
685 ChildrenCapSeeds.Add(handle, seed);
608 } 686 }
609 } 687 }
610 } 688 }
@@ -647,6 +725,28 @@ namespace OpenSim.Framework
647 } 725 }
648 } 726 }
649 727
728 MovementAnimationOverRides.Clear();
729
730 if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array)
731 {
732 OSDArray AOs = (OSDArray)(args["movementAO"]);
733 int count = AOs.Count;
734
735 for (int i = 0; i < count; i++)
736 {
737 OSDMap ao = (OSDMap)AOs[i];
738 if (ao["state"] != null && ao["uuid"] != null)
739 {
740 string state = ao["state"].AsString();
741 UUID id = ao["uuid"].AsUUID();
742 MovementAnimationOverRides[state] = id;
743 }
744 }
745 }
746
747 if (args.ContainsKey("motion_state"))
748 MotionState = (byte)args["motion_state"].AsInteger();
749
650 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) 750 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
651 //{ 751 //{
652 // OSDArray textures = (OSDArray)(args["agent_textures"]); 752 // OSDArray textures = (OSDArray)(args["agent_textures"]);
@@ -656,58 +756,67 @@ namespace OpenSim.Framework
656 // AgentTextures[i++] = o.AsUUID(); 756 // AgentTextures[i++] = o.AsUUID();
657 //} 757 //}
658 758
659 Appearance = new AvatarAppearance();
660 759
661 // The code to unpack textures, visuals, wearables and attachments 760 // packed_appearence should contain all appearance information
662 // should be removed; packed appearance contains the full appearance 761 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
663 // This is retained for backward compatibility only
664 if (args["texture_entry"] != null)
665 { 762 {
666 byte[] rawtextures = args["texture_entry"].AsBinary(); 763 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance");
667 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length); 764 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
668 Appearance.SetTextureEntries(textures);
669 } 765 }
766 else
767 {
768 // if missing try the old pack method
769 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method");
670 770
671 if (args["visual_params"] != null) 771 Appearance = new AvatarAppearance();
672 Appearance.SetVisualParams(args["visual_params"].AsBinary());
673 772
674 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) 773 // The code to unpack textures, visuals, wearables and attachments
675 { 774 // should be removed; packed appearance contains the full appearance
676 OSDArray wears = (OSDArray)(args["wearables"]); 775 // This is retained for backward compatibility only
776 if (args["texture_entry"] != null)
777 {
778 byte[] rawtextures = args["texture_entry"].AsBinary();
779 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
780 Appearance.SetTextureEntries(textures);
781 }
677 782
678 int count = wears.Count; 783 if (args["visual_params"] != null)
679 if (count > AvatarWearable.MAX_WEARABLES) 784 Appearance.SetVisualParams(args["visual_params"].AsBinary());
680 count = AvatarWearable.MAX_WEARABLES;
681 785
682 for (int i = 0; i < count / 2; i++) 786 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
683 { 787 {
684 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); 788 OSDArray wears = (OSDArray)(args["wearables"]);
685 Appearance.SetWearable(i,awear); 789
790 for (int i = 0; i < wears.Count / 2; i++)
791 {
792 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
793 Appearance.SetWearable(i, awear);
794 }
686 } 795 }
687 }
688 796
689 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 797 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
690 {
691 OSDArray attachs = (OSDArray)(args["attachments"]);
692 foreach (OSD o in attachs)
693 { 798 {
694 if (o.Type == OSDType.Map) 799 OSDArray attachs = (OSDArray)(args["attachments"]);
800 foreach (OSD o in attachs)
695 { 801 {
696 // We know all of these must end up as attachments so we 802 if (o.Type == OSDType.Map)
697 // append rather than replace to ensure multiple attachments 803 {
698 // per point continues to work 804 // We know all of these must end up as attachments so we
699// m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); 805 // append rather than replace to ensure multiple attachments
700 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); 806 // per point continues to work
807 // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
808 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
809 }
701 } 810 }
702 } 811 }
812 // end of code to remove
703 } 813 }
704 // end of code to remove 814/* moved above
705
706 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) 815 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
707 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); 816 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
708 else 817 else
709 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); 818 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
710 819*/
711 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 820 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
712 { 821 {
713 OSDArray controls = (OSDArray)(args["controllers"]); 822 OSDArray controls = (OSDArray)(args["controllers"]);
@@ -771,14 +880,14 @@ namespace OpenSim.Framework
771 880
772 public class CompleteAgentData : AgentData 881 public class CompleteAgentData : AgentData
773 { 882 {
774 public override OSDMap Pack() 883 public override OSDMap Pack(EntityTransferContext ctx)
775 { 884 {
776 return base.Pack(); 885 return base.Pack(ctx);
777 } 886 }
778 887
779 public override void Unpack(OSDMap map, IScene scene) 888 public override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
780 { 889 {
781 base.Unpack(map, scene); 890 base.Unpack(map, scene, ctx);
782 } 891 }
783 } 892 }
784} 893}
diff --git a/OpenSim/Framework/CircularBuffer.cs b/OpenSim/Framework/CircularBuffer.cs
index e919337..e101938 100644
--- a/OpenSim/Framework/CircularBuffer.cs
+++ b/OpenSim/Framework/CircularBuffer.cs
@@ -1,21 +1,21 @@
1/* 1/*
2Copyright (c) 2012, Alex Regueiro 2Copyright (c) 2012, Alex Regueiro
3All rights reserved. 3All rights reserved.
4Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 4Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5following conditions are met: 5following conditions are met:
6 6
7Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 8Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
9in the documentation and/or other materials provided with the distribution. 9in the documentation and/or other materials provided with the distribution.
10 10
11THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 11THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
12BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 12BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 13IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
14OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 14OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
15OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 15OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
16OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 16OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
17POSSIBILITY OF SUCH DAMAGE. 17POSSIBILITY OF SUCH DAMAGE.
18*/ 18*/
19using System; 19using System;
20using System.Collections; 20using System.Collections;
21using System.Collections.Generic; 21using System.Collections.Generic;
diff --git a/OpenSim/Framework/Client/IClientIPEndpoint.cs b/OpenSim/Framework/Client/IClientIPEndpoint.cs
index 2b99bf0..2194616 100644
--- a/OpenSim/Framework/Client/IClientIPEndpoint.cs
+++ b/OpenSim/Framework/Client/IClientIPEndpoint.cs
@@ -34,6 +34,6 @@ namespace OpenSim.Framework.Client
34{ 34{
35 public interface IClientIPEndpoint 35 public interface IClientIPEndpoint
36 { 36 {
37 IPAddress EndPoint { get; } 37 IPEndPoint RemoteEndPoint { get; }
38 } 38 }
39} 39}
diff --git a/OpenSim/Framework/ClientInfo.cs b/OpenSim/Framework/ClientInfo.cs
index 98e4465..a1ca9bc 100644
--- a/OpenSim/Framework/ClientInfo.cs
+++ b/OpenSim/Framework/ClientInfo.cs
@@ -36,14 +36,8 @@ namespace OpenSim.Framework
36 public readonly DateTime StartedTime = DateTime.Now; 36 public readonly DateTime StartedTime = DateTime.Now;
37 public AgentCircuitData agentcircuit = null; 37 public AgentCircuitData agentcircuit = null;
38 38
39 public Dictionary<uint, byte[]> needAck;
40
41 public List<byte[]> out_packets = new List<byte[]>();
42 public Dictionary<uint, uint> pendingAcks = new Dictionary<uint,uint>();
43 public EndPoint proxyEP; 39 public EndPoint proxyEP;
44 40
45 public uint sequence;
46 public byte[] usecircuit;
47 public EndPoint userEP; 41 public EndPoint userEP;
48 42
49 public int resendThrottle; 43 public int resendThrottle;
@@ -59,9 +53,5 @@ namespace OpenSim.Framework
59 public int targetThrottle; 53 public int targetThrottle;
60 54
61 public int maxThrottle; 55 public int maxThrottle;
62
63 public Dictionary<string, int> SyncRequests = new Dictionary<string,int>();
64 public Dictionary<string, int> AsyncRequests = new Dictionary<string,int>();
65 public Dictionary<string, int> GenericRequests = new Dictionary<string,int>();
66 } 56 }
67} 57}
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index baff2f4..45c54e4 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -27,10 +27,8 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using System.Net; 30using System.Net;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenMetaverse.Packets;
34 32
35namespace OpenSim.Framework 33namespace OpenSim.Framework
36{ 34{
@@ -76,20 +74,16 @@ namespace OpenSim.Framework
76 { 74 {
77 lock (m_syncRoot) 75 lock (m_syncRoot)
78 { 76 {
79 if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint)) 77 // allow self healing
80 return false; 78// if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
79// return false;
81 80
82 m_dict1[value.AgentId] = value; 81 m_dict1[value.AgentId] = value;
83 m_dict2[value.RemoteEndPoint] = value; 82 m_dict2[value.RemoteEndPoint] = value;
84 83
85 IClientAPI[] oldArray = m_array; 84 // dict1 is the master
86 int oldLength = oldArray.Length; 85 IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
87 86 m_dict1.Values.CopyTo(newArray, 0);
88 IClientAPI[] newArray = new IClientAPI[oldLength + 1];
89 for (int i = 0; i < oldLength; i++)
90 newArray[i] = oldArray[i];
91 newArray[oldLength] = value;
92
93 m_array = newArray; 87 m_array = newArray;
94 } 88 }
95 89
@@ -112,22 +106,12 @@ namespace OpenSim.Framework
112 m_dict1.Remove(key); 106 m_dict1.Remove(key);
113 m_dict2.Remove(value.RemoteEndPoint); 107 m_dict2.Remove(value.RemoteEndPoint);
114 108
115 IClientAPI[] oldArray = m_array; 109 IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
116 int oldLength = oldArray.Length; 110 m_dict1.Values.CopyTo(newArray, 0);
117
118 IClientAPI[] newArray = new IClientAPI[oldLength - 1];
119 int j = 0;
120 for (int i = 0; i < oldLength; i++)
121 {
122 if (oldArray[i] != value)
123 newArray[j++] = oldArray[i];
124 }
125
126 m_array = newArray; 111 m_array = newArray;
127 return true; 112 return true;
128 } 113 }
129 } 114 }
130
131 return false; 115 return false;
132 } 116 }
133 117
@@ -197,25 +181,11 @@ namespace OpenSim.Framework
197 } 181 }
198 182
199 /// <summary> 183 /// <summary>
200 /// Performs a given task in parallel for each of the elements in the
201 /// collection
202 /// </summary>
203 /// <param name="action">Action to perform on each element</param>
204 public void ForEach(Action<IClientAPI> action)
205 {
206 IClientAPI[] localArray = m_array;
207 Parallel.For(0, localArray.Length,
208 delegate(int i)
209 { action(localArray[i]); }
210 );
211 }
212
213 /// <summary>
214 /// Performs a given task synchronously for each of the elements in 184 /// Performs a given task synchronously for each of the elements in
215 /// the collection 185 /// the collection
216 /// </summary> 186 /// </summary>
217 /// <param name="action">Action to perform on each element</param> 187 /// <param name="action">Action to perform on each element</param>
218 public void ForEachSync(Action<IClientAPI> action) 188 public void ForEach(Action<IClientAPI> action)
219 { 189 {
220 IClientAPI[] localArray = m_array; 190 IClientAPI[] localArray = m_array;
221 for (int i = 0; i < localArray.Length; i++) 191 for (int i = 0; i < localArray.Length; i++)
diff --git a/OpenSim/Framework/CnmMemoryCache.cs b/OpenSim/Framework/CnmMemoryCache.cs
index 92af331..f996cb0 100644
--- a/OpenSim/Framework/CnmMemoryCache.cs
+++ b/OpenSim/Framework/CnmMemoryCache.cs
@@ -36,14 +36,14 @@ namespace OpenSim.Framework
36 /// Cenome memory based cache to store key/value pairs (elements) limited time and/or limited size. 36 /// Cenome memory based cache to store key/value pairs (elements) limited time and/or limited size.
37 /// </summary> 37 /// </summary>
38 /// <typeparam name="TKey"> 38 /// <typeparam name="TKey">
39 /// The type of keys in the cache. 39 /// The type of keys in the cache.
40 /// </typeparam> 40 /// </typeparam>
41 /// <typeparam name="TValue"> 41 /// <typeparam name="TValue">
42 /// The type of values in the dictionary. 42 /// The type of values in the dictionary.
43 /// </typeparam> 43 /// </typeparam>
44 /// <remarks> 44 /// <remarks>
45 /// <para> 45 /// <para>
46 /// Cenome memory cache stores elements to hash table generations. When new element is being added to cache, and new size would exceed 46 /// Cenome memory cache stores elements to hash table generations. When new element is being added to cache, and new size would exceed
47 /// maximal allowed size or maximal amount of allowed element count, then elements in oldest generation are deleted. Last access time 47 /// maximal allowed size or maximal amount of allowed element count, then elements in oldest generation are deleted. Last access time
48 /// is also tracked in generation level - thus it is possible that some elements are staying in cache far beyond their expiration time. 48 /// is also tracked in generation level - thus it is possible that some elements are staying in cache far beyond their expiration time.
49 /// If elements in older generations are accessed through <see cref="TryGetValue"/> method, they are moved to newest generation. 49 /// If elements in older generations are accessed through <see cref="TryGetValue"/> method, they are moved to newest generation.
@@ -176,7 +176,7 @@ namespace OpenSim.Framework
176 } 176 }
177 177
178 /// <summary> 178 /// <summary>
179 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class. 179 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
180 /// </summary> 180 /// </summary>
181 /// <param name="maximalSize"> 181 /// <param name="maximalSize">
182 /// Maximal cache size. 182 /// Maximal cache size.
@@ -201,7 +201,7 @@ namespace OpenSim.Framework
201 } 201 }
202 202
203 /// <summary> 203 /// <summary>
204 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class. 204 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
205 /// </summary> 205 /// </summary>
206 /// <param name="maximalSize"> 206 /// <param name="maximalSize">
207 /// Maximal cache size. 207 /// Maximal cache size.
@@ -218,7 +218,7 @@ namespace OpenSim.Framework
218 } 218 }
219 219
220 /// <summary> 220 /// <summary>
221 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class. 221 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
222 /// </summary> 222 /// </summary>
223 /// <param name="maximalSize"> 223 /// <param name="maximalSize">
224 /// Maximal cache size. 224 /// Maximal cache size.
@@ -336,7 +336,7 @@ namespace OpenSim.Framework
336 /// </summary> 336 /// </summary>
337 private void CheckExpired() 337 private void CheckExpired()
338 { 338 {
339 // Do this only one in every m_operationsBetweenTimeChecks 339 // Do this only one in every m_operationsBetweenTimeChecks
340 // Fetching time is using several millisecons - it is better not to do all time. 340 // Fetching time is using several millisecons - it is better not to do all time.
341 m_operationsBetweenTimeChecks--; 341 m_operationsBetweenTimeChecks--;
342 if (m_operationsBetweenTimeChecks <= 0) 342 if (m_operationsBetweenTimeChecks <= 0)
@@ -394,7 +394,7 @@ namespace OpenSim.Framework
394 new IEnumerator<KeyValuePair<TKey, TValue>>[2]; 394 new IEnumerator<KeyValuePair<TKey, TValue>>[2];
395 395
396 /// <summary> 396 /// <summary>
397 /// Initializes a new instance of the <see cref="Enumerator"/> class. 397 /// Initializes a new instance of the <see cref="Enumerator"/> class.
398 /// </summary> 398 /// </summary>
399 /// <param name="cache"> 399 /// <param name="cache">
400 /// The cache. 400 /// The cache.
@@ -456,7 +456,7 @@ namespace OpenSim.Framework
456 /// <see langword="true"/>if the enumerator was successfully advanced to the next element; <see langword="false"/> if the enumerator has passed the end of the collection. 456 /// <see langword="true"/>if the enumerator was successfully advanced to the next element; <see langword="false"/> if the enumerator has passed the end of the collection.
457 /// </returns> 457 /// </returns>
458 /// <exception cref="T:System.InvalidOperationException"> 458 /// <exception cref="T:System.InvalidOperationException">
459 /// The collection was modified after the enumerator was created. 459 /// The collection was modified after the enumerator was created.
460 /// </exception> 460 /// </exception>
461 /// <filterpriority>2</filterpriority> 461 /// <filterpriority>2</filterpriority>
462 public bool MoveNext() 462 public bool MoveNext()
@@ -479,7 +479,7 @@ namespace OpenSim.Framework
479 /// Sets the enumerator to its initial position, which is before the first element in the collection. 479 /// Sets the enumerator to its initial position, which is before the first element in the collection.
480 /// </summary> 480 /// </summary>
481 /// <exception cref="T:System.InvalidOperationException"> 481 /// <exception cref="T:System.InvalidOperationException">
482 /// The collection was modified after the enumerator was created. 482 /// The collection was modified after the enumerator was created.
483 /// </exception> 483 /// </exception>
484 /// <filterpriority>2</filterpriority> 484 /// <filterpriority>2</filterpriority>
485 public void Reset() 485 public void Reset()
@@ -548,7 +548,7 @@ namespace OpenSim.Framework
548 private DateTime m_expirationTime1; 548 private DateTime m_expirationTime1;
549 549
550 /// <summary> 550 /// <summary>
551 /// Index to first free element. 551 /// Index to first free element.
552 /// </summary> 552 /// </summary>
553 private int m_firstFreeElement; 553 private int m_firstFreeElement;
554 554
@@ -681,8 +681,8 @@ namespace OpenSim.Framework
681 /// Next element in chain. 681 /// Next element in chain.
682 /// </summary> 682 /// </summary>
683 /// <remarks> 683 /// <remarks>
684 /// When element have value (something is stored to it), this is index of 684 /// When element have value (something is stored to it), this is index of
685 /// next element with same bucket index. When element is free, this 685 /// next element with same bucket index. When element is free, this
686 /// is index of next element in free element's list. 686 /// is index of next element in free element's list.
687 /// </remarks> 687 /// </remarks>
688 public int Next; 688 public int Next;
@@ -696,7 +696,7 @@ namespace OpenSim.Framework
696 public long Size; 696 public long Size;
697 697
698 /// <summary> 698 /// <summary>
699 /// Element's value. 699 /// Element's value.
700 /// </summary> 700 /// </summary>
701 /// <remarks> 701 /// <remarks>
702 /// It is possible that this value is <see langword="null"/> even when element 702 /// It is possible that this value is <see langword="null"/> even when element
@@ -812,7 +812,7 @@ namespace OpenSim.Framework
812 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. 812 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
813 /// </returns> 813 /// </returns>
814 /// <exception cref="InvalidOperationException"> 814 /// <exception cref="InvalidOperationException">
815 /// The collection was modified after the enumerator was created. 815 /// The collection was modified after the enumerator was created.
816 /// </exception> 816 /// </exception>
817 public bool MoveNext() 817 public bool MoveNext()
818 { 818 {
@@ -841,7 +841,7 @@ namespace OpenSim.Framework
841 /// Sets the enumerator to its initial position, which is before the first element in the collection. 841 /// Sets the enumerator to its initial position, which is before the first element in the collection.
842 /// </summary> 842 /// </summary>
843 /// <exception cref="InvalidOperationException"> 843 /// <exception cref="InvalidOperationException">
844 /// The collection was modified after the enumerator was created. 844 /// The collection was modified after the enumerator was created.
845 /// </exception> 845 /// </exception>
846 /// <filterpriority>2</filterpriority> 846 /// <filterpriority>2</filterpriority>
847 public void Reset() 847 public void Reset()
@@ -931,7 +931,7 @@ namespace OpenSim.Framework
931 /// The key to locate in the <see cref="IGeneration"/>. 931 /// The key to locate in the <see cref="IGeneration"/>.
932 /// </param> 932 /// </param>
933 /// <returns> 933 /// <returns>
934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
935 /// otherwise <see langword="false"/>. 935 /// otherwise <see langword="false"/>.
936 /// </returns> 936 /// </returns>
937 public bool Contains(int bucketIndex, TKey key) 937 public bool Contains(int bucketIndex, TKey key)
@@ -1014,7 +1014,7 @@ namespace OpenSim.Framework
1014 /// </returns> 1014 /// </returns>
1015 /// <remarks> 1015 /// <remarks>
1016 /// <para> 1016 /// <para>
1017 /// If element was already existing in generation and new element size fits to collection limits, 1017 /// If element was already existing in generation and new element size fits to collection limits,
1018 /// then it's value is replaced with new one and size information is updated. If element didn't 1018 /// then it's value is replaced with new one and size information is updated. If element didn't
1019 /// exists in generation before, then generation must have empty space for a new element and 1019 /// exists in generation before, then generation must have empty space for a new element and
1020 /// size must fit generation's limits, before element is added to generation. 1020 /// size must fit generation's limits, before element is added to generation.
@@ -1070,7 +1070,7 @@ namespace OpenSim.Framework
1070 if (Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize) 1070 if (Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize)
1071 { 1071 {
1072 // Generation is full 1072 // Generation is full
1073 // Remove existing element, because generation is going to be recycled to 1073 // Remove existing element, because generation is going to be recycled to
1074 // old generation and element is stored to new generation 1074 // old generation and element is stored to new generation
1075 RemoveElement(bucketIndex, elementIndex, previousIndex); 1075 RemoveElement(bucketIndex, elementIndex, previousIndex);
1076 return false; 1076 return false;
@@ -1110,12 +1110,12 @@ namespace OpenSim.Framework
1110 /// <remarks> 1110 /// <remarks>
1111 /// <para> 1111 /// <para>
1112 /// If element is not found from generation then <paramref name="value"/> and <paramref name="size"/> 1112 /// If element is not found from generation then <paramref name="value"/> and <paramref name="size"/>
1113 /// are set to default value (default(TValue) and 0). 1113 /// are set to default value (default(TValue) and 0).
1114 /// </para> 1114 /// </para>
1115 /// </remarks> 1115 /// </remarks>
1116 public bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size) 1116 public bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size)
1117 { 1117 {
1118 // Find entry index, 1118 // Find entry index,
1119 int previousIndex; 1119 int previousIndex;
1120 int elementIndex = FindElementIndex(bucketIndex, key, m_newGeneration, out previousIndex); 1120 int elementIndex = FindElementIndex(bucketIndex, key, m_newGeneration, out previousIndex);
1121 if (elementIndex == -1) 1121 if (elementIndex == -1)
@@ -1166,7 +1166,7 @@ namespace OpenSim.Framework
1166 /// </para> 1166 /// </para>
1167 /// <para> 1167 /// <para>
1168 /// There are two kind generations: "new generation" and "old generation(s)". All new elements 1168 /// There are two kind generations: "new generation" and "old generation(s)". All new elements
1169 /// are added to "new generation". 1169 /// are added to "new generation".
1170 /// </para> 1170 /// </para>
1171 /// </remarks> 1171 /// </remarks>
1172 protected interface IGeneration : IEnumerable<KeyValuePair<TKey, TValue>> 1172 protected interface IGeneration : IEnumerable<KeyValuePair<TKey, TValue>>
@@ -1211,7 +1211,7 @@ namespace OpenSim.Framework
1211 /// The key to locate in the <see cref="IGeneration"/>. 1211 /// The key to locate in the <see cref="IGeneration"/>.
1212 /// </param> 1212 /// </param>
1213 /// <returns> 1213 /// <returns>
1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
1215 /// otherwise <see langword="false"/>. 1215 /// otherwise <see langword="false"/>.
1216 /// </returns> 1216 /// </returns>
1217 bool Contains(int bucketIndex, TKey key); 1217 bool Contains(int bucketIndex, TKey key);
@@ -1259,7 +1259,7 @@ namespace OpenSim.Framework
1259 /// </returns> 1259 /// </returns>
1260 /// <remarks> 1260 /// <remarks>
1261 /// <para> 1261 /// <para>
1262 /// If element was already existing in generation and new element size fits to collection limits, 1262 /// If element was already existing in generation and new element size fits to collection limits,
1263 /// then it's value is replaced with new one and size information is updated. If element didn't 1263 /// then it's value is replaced with new one and size information is updated. If element didn't
1264 /// exists in generation before, then generation must have empty space for a new element and 1264 /// exists in generation before, then generation must have empty space for a new element and
1265 /// size must fit generation's limits, before element is added to generation. 1265 /// size must fit generation's limits, before element is added to generation.
@@ -1288,7 +1288,7 @@ namespace OpenSim.Framework
1288 /// <remarks> 1288 /// <remarks>
1289 /// <para> 1289 /// <para>
1290 /// If element is not found from generation then <paramref name="value"/> and <paramref name="size"/> 1290 /// If element is not found from generation then <paramref name="value"/> and <paramref name="size"/>
1291 /// are set to default value (default(TValue) and 0). 1291 /// are set to default value (default(TValue) and 0).
1292 /// </para> 1292 /// </para>
1293 /// </remarks> 1293 /// </remarks>
1294 bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size); 1294 bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size);
@@ -1303,8 +1303,8 @@ namespace OpenSim.Framework
1303 /// </summary> 1303 /// </summary>
1304 /// <remarks> 1304 /// <remarks>
1305 /// <para> 1305 /// <para>
1306 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 1306 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
1307 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1307 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1308 /// </para> 1308 /// </para>
1309 /// </remarks> 1309 /// </remarks>
1310 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 1310 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
@@ -1324,13 +1324,13 @@ namespace OpenSim.Framework
1324 /// </value> 1324 /// </value>
1325 /// <remarks> 1325 /// <remarks>
1326 /// <para> 1326 /// <para>
1327 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 1327 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
1328 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is 1328 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is
1329 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the 1329 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the
1330 /// <see cref="ICnmCache{TKey,TValue}"/>. 1330 /// <see cref="ICnmCache{TKey,TValue}"/>.
1331 /// </para> 1331 /// </para>
1332 /// <para> 1332 /// <para>
1333 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time, 1333 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time,
1334 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>. 1334 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>.
1335 /// </para> 1335 /// </para>
1336 /// <para> 1336 /// <para>
@@ -1375,17 +1375,17 @@ namespace OpenSim.Framework
1375 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements. 1375 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements.
1376 /// </summary> 1376 /// </summary>
1377 /// <value> 1377 /// <value>
1378 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited; 1378 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited;
1379 /// otherwise, <see langword="false"/>. 1379 /// otherwise, <see langword="false"/>.
1380 /// </value> 1380 /// </value>
1381 /// <remarks> 1381 /// <remarks>
1382 /// <para> 1382 /// <para>
1383 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 1383 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
1384 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1384 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1385 /// </para> 1385 /// </para>
1386 /// </remarks> 1386 /// </remarks>
1387 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/> 1387 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/>
1388 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 1388 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
1389 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 1389 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
1390 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 1390 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
1391 public bool IsCountLimited 1391 public bool IsCountLimited
@@ -1397,13 +1397,13 @@ namespace OpenSim.Framework
1397 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements. 1397 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements.
1398 /// </summary> 1398 /// </summary>
1399 /// <value> 1399 /// <value>
1400 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited; 1400 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited;
1401 /// otherwise, <see langword="false"/>. 1401 /// otherwise, <see langword="false"/>.
1402 /// </value> 1402 /// </value>
1403 /// <remarks> 1403 /// <remarks>
1404 /// <para> 1404 /// <para>
1405 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 1405 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
1406 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1406 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1407 /// </para> 1407 /// </para>
1408 /// </remarks> 1408 /// </remarks>
1409 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 1409 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
@@ -1420,12 +1420,12 @@ namespace OpenSim.Framework
1420 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe). 1420 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe).
1421 /// </summary> 1421 /// </summary>
1422 /// <value> 1422 /// <value>
1423 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe); 1423 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe);
1424 /// otherwise, <see langword="false"/>. 1424 /// otherwise, <see langword="false"/>.
1425 /// </value> 1425 /// </value>
1426 /// <remarks> 1426 /// <remarks>
1427 /// <para> 1427 /// <para>
1428 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use 1428 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use
1429 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class 1429 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class
1430 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object. 1430 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object.
1431 /// </para> 1431 /// </para>
@@ -1441,13 +1441,13 @@ namespace OpenSim.Framework
1441 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time. 1441 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time.
1442 /// </summary> 1442 /// </summary>
1443 /// <value> 1443 /// <value>
1444 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements; 1444 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements;
1445 /// otherwise, <see langword="false"/>. 1445 /// otherwise, <see langword="false"/>.
1446 /// </value> 1446 /// </value>
1447 /// <remarks> 1447 /// <remarks>
1448 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/> 1448 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/>
1449 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from 1449 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from
1450 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may 1450 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may
1451 /// stay longer in cache. 1451 /// stay longer in cache.
1452 /// </remarks> 1452 /// </remarks>
1453 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 1453 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
@@ -1463,13 +1463,13 @@ namespace OpenSim.Framework
1463 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>. 1463 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>.
1464 /// </summary> 1464 /// </summary>
1465 /// <value> 1465 /// <value>
1466 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements; 1466 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements;
1467 /// otherwise maximal allowed count of elements. 1467 /// otherwise maximal allowed count of elements.
1468 /// </value> 1468 /// </value>
1469 /// <remarks> 1469 /// <remarks>
1470 /// <para> 1470 /// <para>
1471 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 1471 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
1472 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1472 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1473 /// </para> 1473 /// </para>
1474 /// </remarks> 1474 /// </remarks>
1475 public int MaxCount 1475 public int MaxCount
@@ -1496,7 +1496,7 @@ namespace OpenSim.Framework
1496 /// </value> 1496 /// </value>
1497 /// <remarks> 1497 /// <remarks>
1498 /// <para> 1498 /// <para>
1499 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 1499 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
1500 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>. 1500 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>.
1501 /// </para> 1501 /// </para>
1502 /// </remarks> 1502 /// </remarks>
@@ -1522,8 +1522,8 @@ namespace OpenSim.Framework
1522 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure. 1522 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure.
1523 /// </para> 1523 /// </para>
1524 /// <para> 1524 /// <para>
1525 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 1525 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
1526 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1526 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1527 /// </para> 1527 /// </para>
1528 /// </remarks> 1528 /// </remarks>
1529 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 1529 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
@@ -1556,11 +1556,11 @@ namespace OpenSim.Framework
1556 /// Normally bytes, but can be any suitable unit of measure. 1556 /// Normally bytes, but can be any suitable unit of measure.
1557 /// </para> 1557 /// </para>
1558 /// <para> 1558 /// <para>
1559 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method. 1559 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method.
1560 /// </para> 1560 /// </para>
1561 /// <para> 1561 /// <para>
1562 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 1562 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
1563 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 1563 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
1564 /// </para> 1564 /// </para>
1565 /// </remarks> 1565 /// </remarks>
1566 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 1566 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
@@ -1581,8 +1581,8 @@ namespace OpenSim.Framework
1581 /// </value> 1581 /// </value>
1582 /// <remarks> 1582 /// <remarks>
1583 /// <para> 1583 /// <para>
1584 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/> 1584 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/>
1585 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to 1585 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to
1586 /// <see cref="ICnmCache{TKey,TValue}"/>. 1586 /// <see cref="ICnmCache{TKey,TValue}"/>.
1587 /// </para> 1587 /// </para>
1588 /// </remarks> 1588 /// </remarks>
@@ -1735,7 +1735,7 @@ namespace OpenSim.Framework
1735 } 1735 }
1736 1736
1737 /// <summary> 1737 /// <summary>
1738 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to 1738 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to
1739 /// <see cref="ICnmCache{TKey,TValue}"/>. 1739 /// <see cref="ICnmCache{TKey,TValue}"/>.
1740 /// </summary> 1740 /// </summary>
1741 /// <param name="key"> 1741 /// <param name="key">
@@ -1748,7 +1748,7 @@ namespace OpenSim.Framework
1748 /// The element's size. Normally bytes, but can be any suitable unit of measure. 1748 /// The element's size. Normally bytes, but can be any suitable unit of measure.
1749 /// </param> 1749 /// </param>
1750 /// <returns> 1750 /// <returns>
1751 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>; 1751 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>;
1752 /// otherwise <see langword="false"/>. 1752 /// otherwise <see langword="false"/>.
1753 /// </returns> 1753 /// </returns>
1754 /// <exception cref="ArgumentNullException"> 1754 /// <exception cref="ArgumentNullException">
@@ -1759,17 +1759,17 @@ namespace OpenSim.Framework
1759 /// </exception> 1759 /// </exception>
1760 /// <remarks> 1760 /// <remarks>
1761 /// <para> 1761 /// <para>
1762 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 1762 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
1763 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is 1763 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is
1764 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>. 1764 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>.
1765 /// </para> 1765 /// </para>
1766 /// <para> 1766 /// <para>
1767 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 1767 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
1768 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 1768 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
1769 /// </para> 1769 /// </para>
1770 /// <para> 1770 /// <para>
1771 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 1771 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
1772 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 1772 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
1773 /// </para> 1773 /// </para>
1774 /// </remarks> 1774 /// </remarks>
1775 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 1775 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
@@ -1809,15 +1809,15 @@ namespace OpenSim.Framework
1809 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>. 1809 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>.
1810 /// </summary> 1810 /// </summary>
1811 /// <returns> 1811 /// <returns>
1812 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with 1812 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with
1813 /// the specified key; otherwise, <see langword="false"/>. 1813 /// the specified key; otherwise, <see langword="false"/>.
1814 /// </returns> 1814 /// </returns>
1815 /// <param name="key"> 1815 /// <param name="key">
1816 /// The key whose <paramref name="value"/> to get. 1816 /// The key whose <paramref name="value"/> to get.
1817 /// </param> 1817 /// </param>
1818 /// <param name="value"> 1818 /// <param name="value">
1819 /// When this method returns, the value associated with the specified <paramref name="key"/>, 1819 /// When this method returns, the value associated with the specified <paramref name="key"/>,
1820 /// if the <paramref name="key"/> is found; otherwise, the 1820 /// if the <paramref name="key"/> is found; otherwise, the
1821 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized. 1821 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.
1822 /// </param> 1822 /// </param>
1823 /// <exception cref="ArgumentNullException"> 1823 /// <exception cref="ArgumentNullException">
diff --git a/OpenSim/Framework/CnmSynchronizedCache.cs b/OpenSim/Framework/CnmSynchronizedCache.cs
index 2bafbe9..b33f4f7 100644
--- a/OpenSim/Framework/CnmSynchronizedCache.cs
+++ b/OpenSim/Framework/CnmSynchronizedCache.cs
@@ -36,10 +36,10 @@ namespace OpenSim.Framework
36 /// Synchronized Cenome cache wrapper. 36 /// Synchronized Cenome cache wrapper.
37 /// </summary> 37 /// </summary>
38 /// <typeparam name="TKey"> 38 /// <typeparam name="TKey">
39 /// The type of keys in the cache. 39 /// The type of keys in the cache.
40 /// </typeparam> 40 /// </typeparam>
41 /// <typeparam name="TValue"> 41 /// <typeparam name="TValue">
42 /// The type of values in the cache. 42 /// The type of values in the cache.
43 /// </typeparam> 43 /// </typeparam>
44 /// <remarks> 44 /// <remarks>
45 /// <para> 45 /// <para>
@@ -60,7 +60,7 @@ namespace OpenSim.Framework
60 private readonly object m_syncRoot; 60 private readonly object m_syncRoot;
61 61
62 /// <summary> 62 /// <summary>
63 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class. 63 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class.
64 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class. 64 /// Initializes a new instance of the <see cref="CnmSynchronizedCache{TKey,TValue}"/> class.
65 /// </summary> 65 /// </summary>
66 /// <param name="cache"> 66 /// <param name="cache">
@@ -73,13 +73,13 @@ namespace OpenSim.Framework
73 } 73 }
74 74
75 /// <summary> 75 /// <summary>
76 /// Returns a <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe). 76 /// Returns a <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe).
77 /// </summary> 77 /// </summary>
78 /// <param name="cache"> 78 /// <param name="cache">
79 /// The <see cref="ICnmCache{TKey,TValue}"/> to synchronize. 79 /// The <see cref="ICnmCache{TKey,TValue}"/> to synchronize.
80 /// </param> 80 /// </param>
81 /// <returns> 81 /// <returns>
82 /// A <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe). 82 /// A <see cref="ICnmCache{TKey,TValue}"/> wrapper that is synchronized (thread safe).
83 /// </returns> 83 /// </returns>
84 /// <exception cref="ArgumentNullException"> 84 /// <exception cref="ArgumentNullException">
85 /// <paramref name="cache"/>is null. 85 /// <paramref name="cache"/>is null.
@@ -125,7 +125,7 @@ namespace OpenSim.Framework
125 } 125 }
126 126
127 /// <summary> 127 /// <summary>
128 /// Finalizes an instance of the <see cref="SynchronizedEnumerator"/> class. 128 /// Finalizes an instance of the <see cref="SynchronizedEnumerator"/> class.
129 /// </summary> 129 /// </summary>
130 ~SynchronizedEnumerator() 130 ~SynchronizedEnumerator()
131 { 131 {
@@ -184,7 +184,7 @@ namespace OpenSim.Framework
184 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. 184 /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
185 /// </returns> 185 /// </returns>
186 /// <exception cref="InvalidOperationException"> 186 /// <exception cref="InvalidOperationException">
187 /// The collection was modified after the enumerator was created. 187 /// The collection was modified after the enumerator was created.
188 /// </exception> 188 /// </exception>
189 public bool MoveNext() 189 public bool MoveNext()
190 { 190 {
@@ -195,7 +195,7 @@ namespace OpenSim.Framework
195 /// Sets the enumerator to its initial position, which is before the first element in the collection. 195 /// Sets the enumerator to its initial position, which is before the first element in the collection.
196 /// </summary> 196 /// </summary>
197 /// <exception cref="InvalidOperationException"> 197 /// <exception cref="InvalidOperationException">
198 /// The collection was modified after the enumerator was created. 198 /// The collection was modified after the enumerator was created.
199 /// </exception> 199 /// </exception>
200 public void Reset() 200 public void Reset()
201 { 201 {
@@ -214,8 +214,8 @@ namespace OpenSim.Framework
214 /// </summary> 214 /// </summary>
215 /// <remarks> 215 /// <remarks>
216 /// <para> 216 /// <para>
217 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 217 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
218 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 218 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
219 /// </para> 219 /// </para>
220 /// </remarks> 220 /// </remarks>
221 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 221 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
@@ -241,13 +241,13 @@ namespace OpenSim.Framework
241 /// </value> 241 /// </value>
242 /// <remarks> 242 /// <remarks>
243 /// <para> 243 /// <para>
244 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 244 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
245 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is 245 /// and it is not accessed through <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> method or element's value is
246 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the 246 /// not replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method, then it is automatically removed from the
247 /// <see cref="ICnmCache{TKey,TValue}"/>. 247 /// <see cref="ICnmCache{TKey,TValue}"/>.
248 /// </para> 248 /// </para>
249 /// <para> 249 /// <para>
250 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time, 250 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time,
251 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>. 251 /// because total size or count of elements stored to cache is larger than <see cref="ICnmCache{TKey,TValue}.MaxSize"/> or <see cref="ICnmCache{TKey,TValue}.MaxCount"/>.
252 /// </para> 252 /// </para>
253 /// <para> 253 /// <para>
@@ -291,17 +291,17 @@ namespace OpenSim.Framework
291 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements. 291 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements.
292 /// </summary> 292 /// </summary>
293 /// <value> 293 /// <value>
294 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited; 294 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited;
295 /// otherwise, <see langword="false"/>. 295 /// otherwise, <see langword="false"/>.
296 /// </value> 296 /// </value>
297 /// <remarks> 297 /// <remarks>
298 /// <para> 298 /// <para>
299 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 299 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
300 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 300 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
301 /// </para> 301 /// </para>
302 /// </remarks> 302 /// </remarks>
303 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/> 303 /// <seealso cref="ICnmCache{TKey,TValue}.Count"/>
304 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/> 304 /// <seealso cref="ICnmCache{TKey,TValue}.MaxCount"/>
305 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 305 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
306 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/> 306 /// <seealso cref="ICnmCache{TKey,TValue}.IsTimeLimited"/>
307 public bool IsCountLimited 307 public bool IsCountLimited
@@ -319,13 +319,13 @@ namespace OpenSim.Framework
319 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements. 319 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements.
320 /// </summary> 320 /// </summary>
321 /// <value> 321 /// <value>
322 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited; 322 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited;
323 /// otherwise, <see langword="false"/>. 323 /// otherwise, <see langword="false"/>.
324 /// </value> 324 /// </value>
325 /// <remarks> 325 /// <remarks>
326 /// <para> 326 /// <para>
327 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 327 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
328 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 328 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
329 /// </para> 329 /// </para>
330 /// </remarks> 330 /// </remarks>
331 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 331 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
@@ -348,12 +348,12 @@ namespace OpenSim.Framework
348 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe). 348 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe).
349 /// </summary> 349 /// </summary>
350 /// <value> 350 /// <value>
351 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe); 351 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe);
352 /// otherwise, <see langword="false"/>. 352 /// otherwise, <see langword="false"/>.
353 /// </value> 353 /// </value>
354 /// <remarks> 354 /// <remarks>
355 /// <para> 355 /// <para>
356 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use 356 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use
357 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class 357 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class
358 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object. 358 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object.
359 /// </para> 359 /// </para>
@@ -369,13 +369,13 @@ namespace OpenSim.Framework
369 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time. 369 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time.
370 /// </summary> 370 /// </summary>
371 /// <value> 371 /// <value>
372 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements; 372 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements;
373 /// otherwise, <see langword="false"/>. 373 /// otherwise, <see langword="false"/>.
374 /// </value> 374 /// </value>
375 /// <remarks> 375 /// <remarks>
376 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/> 376 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="ICnmCache{TKey,TValue}.Set"/>
377 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from 377 /// or <see cref="ICnmCache{TKey,TValue}.TryGetValue"/> methods in <see cref="ICnmCache{TKey,TValue}.ExpirationTime"/> , then element is automatically removed from
378 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may 378 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may
379 /// stay longer in cache. 379 /// stay longer in cache.
380 /// </remarks> 380 /// </remarks>
381 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/> 381 /// <seealso cref="ICnmCache{TKey,TValue}.ExpirationTime"/>
@@ -397,13 +397,13 @@ namespace OpenSim.Framework
397 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>. 397 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>.
398 /// </summary> 398 /// </summary>
399 /// <value> 399 /// <value>
400 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements; 400 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements;
401 /// otherwise maximal allowed count of elements. 401 /// otherwise maximal allowed count of elements.
402 /// </value> 402 /// </value>
403 /// <remarks> 403 /// <remarks>
404 /// <para> 404 /// <para>
405 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 405 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
406 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 406 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
407 /// </para> 407 /// </para>
408 /// </remarks> 408 /// </remarks>
409 public int MaxCount 409 public int MaxCount
@@ -433,7 +433,7 @@ namespace OpenSim.Framework
433 /// </value> 433 /// </value>
434 /// <remarks> 434 /// <remarks>
435 /// <para> 435 /// <para>
436 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 436 /// If element's size is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
437 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>. 437 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>.
438 /// </para> 438 /// </para>
439 /// </remarks> 439 /// </remarks>
@@ -463,8 +463,8 @@ namespace OpenSim.Framework
463 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure. 463 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure.
464 /// </para> 464 /// </para>
465 /// <para> 465 /// <para>
466 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 466 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
467 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 467 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
468 /// </para> 468 /// </para>
469 /// </remarks> 469 /// </remarks>
470 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception> 470 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception>
@@ -501,11 +501,11 @@ namespace OpenSim.Framework
501 /// Normally bytes, but can be any suitable unit of measure. 501 /// Normally bytes, but can be any suitable unit of measure.
502 /// </para> 502 /// </para>
503 /// <para> 503 /// <para>
504 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method. 504 /// Element's size is given when element is added or replaced by <see cref="ICnmCache{TKey,TValue}.Set"/> method.
505 /// </para> 505 /// </para>
506 /// <para> 506 /// <para>
507 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 507 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
508 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 508 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
509 /// </para> 509 /// </para>
510 /// </remarks> 510 /// </remarks>
511 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/> 511 /// <seealso cref="ICnmCache{TKey,TValue}.MaxElementSize"/>
@@ -532,8 +532,8 @@ namespace OpenSim.Framework
532 /// </value> 532 /// </value>
533 /// <remarks> 533 /// <remarks>
534 /// <para> 534 /// <para>
535 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/> 535 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/>
536 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to 536 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to
537 /// <see cref="ICnmCache{TKey,TValue}"/>. 537 /// <see cref="ICnmCache{TKey,TValue}"/>.
538 /// </para> 538 /// </para>
539 /// </remarks> 539 /// </remarks>
@@ -647,7 +647,7 @@ namespace OpenSim.Framework
647 } 647 }
648 648
649 /// <summary> 649 /// <summary>
650 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to 650 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to
651 /// <see cref="ICnmCache{TKey,TValue}"/>. 651 /// <see cref="ICnmCache{TKey,TValue}"/>.
652 /// </summary> 652 /// </summary>
653 /// <param name="key"> 653 /// <param name="key">
@@ -660,7 +660,7 @@ namespace OpenSim.Framework
660 /// The element's size. Normally bytes, but can be any suitable unit of measure. 660 /// The element's size. Normally bytes, but can be any suitable unit of measure.
661 /// </param> 661 /// </param>
662 /// <returns> 662 /// <returns>
663 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>; 663 /// <see langword="true"/>if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>;
664 /// otherwise <see langword="false"/>. 664 /// otherwise <see langword="false"/>.
665 /// </returns> 665 /// </returns>
666 /// <exception cref="ArgumentNullException"> 666 /// <exception cref="ArgumentNullException">
@@ -671,17 +671,17 @@ namespace OpenSim.Framework
671 /// </exception> 671 /// </exception>
672 /// <remarks> 672 /// <remarks>
673 /// <para> 673 /// <para>
674 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is 674 /// If element's <paramref name="size"/> is larger than <see cref="ICnmCache{TKey,TValue}.MaxElementSize"/>, then element is
675 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is 675 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is
676 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>. 676 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>.
677 /// </para> 677 /// </para>
678 /// <para> 678 /// <para>
679 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 679 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
680 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 680 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
681 /// </para> 681 /// </para>
682 /// <para> 682 /// <para>
683 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 683 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
684 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 684 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
685 /// </para> 685 /// </para>
686 /// </remarks> 686 /// </remarks>
687 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/> 687 /// <seealso cref="ICnmCache{TKey,TValue}.IsSizeLimited"/>
@@ -703,15 +703,15 @@ namespace OpenSim.Framework
703 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>. 703 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>.
704 /// </summary> 704 /// </summary>
705 /// <returns> 705 /// <returns>
706 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with 706 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with
707 /// the specified key; otherwise, <see langword="false"/>. 707 /// the specified key; otherwise, <see langword="false"/>.
708 /// </returns> 708 /// </returns>
709 /// <param name="key"> 709 /// <param name="key">
710 /// The key whose <paramref name="value"/> to get. 710 /// The key whose <paramref name="value"/> to get.
711 /// </param> 711 /// </param>
712 /// <param name="value"> 712 /// <param name="value">
713 /// When this method returns, the value associated with the specified <paramref name="key"/>, 713 /// When this method returns, the value associated with the specified <paramref name="key"/>,
714 /// if the <paramref name="key"/> is found; otherwise, the 714 /// if the <paramref name="key"/> is found; otherwise, the
715 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized. 715 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.
716 /// </param> 716 /// </param>
717 /// <exception cref="ArgumentNullException"> 717 /// <exception cref="ArgumentNullException">
diff --git a/OpenSim/Framework/ColliderData.cs b/OpenSim/Framework/ColliderData.cs
index 1b7b682..00013e1 100644
--- a/OpenSim/Framework/ColliderData.cs
+++ b/OpenSim/Framework/ColliderData.cs
@@ -42,6 +42,7 @@ namespace OpenSim.Framework
42 public Vector3 velVector = Vector3.Zero; 42 public Vector3 velVector = Vector3.Zero;
43 public string nameStr = String.Empty; 43 public string nameStr = String.Empty;
44 public int colliderType = 0; 44 public int colliderType = 0;
45 public int linkNumber;
45 } 46 }
46 47
47 public class ColliderArgs : EventArgs 48 public class ColliderArgs : EventArgs
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs
new file mode 100644
index 0000000..7afa68a
--- /dev/null
+++ b/OpenSim/Framework/ConfigurationMember.cs
@@ -0,0 +1,530 @@
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.Globalization;
31using System.Net;
32using System.Reflection;
33using System.Xml;
34using log4net;
35using OpenMetaverse;
36//using OpenSim.Framework.Console;
37
38namespace OpenSim.Framework
39{
40 public class ConfigurationMember
41 {
42 #region Delegates
43
44 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
45
46 public delegate void ConfigurationOptionsLoad();
47
48 #endregion
49
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private int cE = 0;
52
53 private string configurationDescription = String.Empty;
54 private string configurationFilename = String.Empty;
55 private XmlNode configurationFromXMLNode = null;
56 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
57 private IGenericConfig configurationPlugin = null;
58
59 /// <summary>
60 /// This is the default configuration DLL loaded
61 /// </summary>
62 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
63
64 private ConfigurationOptionsLoad loadFunction;
65 private ConfigurationOptionResult resultFunction;
66
67 private bool useConsoleToPromptOnError = true;
68
69 public ConfigurationMember(string configuration_filename, string configuration_description,
70 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error)
71 {
72 configurationFilename = configuration_filename;
73 configurationDescription = configuration_description;
74 loadFunction = load_function;
75 resultFunction = result_function;
76 useConsoleToPromptOnError = use_console_to_prompt_on_error;
77 }
78
79 public ConfigurationMember(XmlNode configuration_xml, string configuration_description,
80 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function, bool use_console_to_prompt_on_error)
81 {
82 configurationFilename = String.Empty;
83 configurationFromXMLNode = configuration_xml;
84 configurationDescription = configuration_description;
85 loadFunction = load_function;
86 resultFunction = result_function;
87 useConsoleToPromptOnError = use_console_to_prompt_on_error;
88 }
89
90 public void setConfigurationFilename(string filename)
91 {
92 configurationFilename = filename;
93 }
94
95 public void setConfigurationDescription(string desc)
96 {
97 configurationDescription = desc;
98 }
99
100 public void setConfigurationResultFunction(ConfigurationOptionResult result)
101 {
102 resultFunction = result;
103 }
104
105 public void forceConfigurationPluginLibrary(string dll_filename)
106 {
107 configurationPluginFilename = dll_filename;
108 }
109
110 private void checkAndAddConfigOption(ConfigurationOption option)
111 {
112 if ((option.configurationKey != String.Empty && option.configurationQuestion != String.Empty) ||
113 (option.configurationKey != String.Empty && option.configurationUseDefaultNoPrompt))
114 {
115 if (!configurationOptions.Contains(option))
116 {
117 configurationOptions.Add(option);
118 }
119 }
120 else
121 {
122 m_log.Info(
123 "Required fields for adding a configuration option is invalid. Will not add this option (" +
124 option.configurationKey + ")");
125 }
126 }
127
128 public void addConfigurationOption(string configuration_key,
129 ConfigurationOption.ConfigurationTypes configuration_type,
130 string configuration_question, string configuration_default,
131 bool use_default_no_prompt)
132 {
133 ConfigurationOption configOption = new ConfigurationOption();
134 configOption.configurationKey = configuration_key;
135 configOption.configurationQuestion = configuration_question;
136 configOption.configurationDefault = configuration_default;
137 configOption.configurationType = configuration_type;
138 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
139 configOption.shouldIBeAsked = null; //Assumes true, I can ask whenever
140 checkAndAddConfigOption(configOption);
141 }
142
143 public void addConfigurationOption(string configuration_key,
144 ConfigurationOption.ConfigurationTypes configuration_type,
145 string configuration_question, string configuration_default,
146 bool use_default_no_prompt,
147 ConfigurationOption.ConfigurationOptionShouldBeAsked shouldIBeAskedDelegate)
148 {
149 ConfigurationOption configOption = new ConfigurationOption();
150 configOption.configurationKey = configuration_key;
151 configOption.configurationQuestion = configuration_question;
152 configOption.configurationDefault = configuration_default;
153 configOption.configurationType = configuration_type;
154 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
155 configOption.shouldIBeAsked = shouldIBeAskedDelegate;
156 checkAndAddConfigOption(configOption);
157 }
158
159 // TEMP - REMOVE
160 public void performConfigurationRetrieve()
161 {
162 if (cE > 1)
163 m_log.Error("READING CONFIGURATION COUT: " + cE.ToString());
164
165
166 configurationPlugin = LoadConfigDll(configurationPluginFilename);
167 configurationOptions.Clear();
168 if (loadFunction == null)
169 {
170 m_log.Error("Load Function for '" + configurationDescription +
171 "' is null. Refusing to run configuration.");
172 return;
173 }
174
175 if (resultFunction == null)
176 {
177 m_log.Error("Result Function for '" + configurationDescription +
178 "' is null. Refusing to run configuration.");
179 return;
180 }
181
182 //m_log.Debug("[CONFIG]: Calling Configuration Load Function...");
183 loadFunction();
184
185 if (configurationOptions.Count <= 0)
186 {
187 m_log.Error("[CONFIG]: No configuration options were specified for '" + configurationOptions +
188 "'. Refusing to continue configuration.");
189 return;
190 }
191
192 bool useFile = true;
193 if (configurationPlugin == null)
194 {
195 m_log.Error("[CONFIG]: Configuration Plugin NOT LOADED!");
196 return;
197 }
198
199 if (configurationFilename.Trim() != String.Empty)
200 {
201 configurationPlugin.SetFileName(configurationFilename);
202 try
203 {
204 configurationPlugin.LoadData();
205 useFile = true;
206 }
207 catch (XmlException e)
208 {
209 m_log.WarnFormat("[CONFIG] Not using {0}: {1}",
210 configurationFilename,
211 e.Message.ToString());
212 //m_log.Error("Error loading " + configurationFilename + ": " + e.ToString());
213 useFile = false;
214 }
215 }
216 else
217 {
218 if (configurationFromXMLNode != null)
219 {
220 m_log.Info("Loading from XML Node, will not save to the file");
221 configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml);
222 }
223
224 m_log.Info("XML Configuration Filename is not valid; will not save to the file.");
225 useFile = false;
226 }
227
228 foreach (ConfigurationOption configOption in configurationOptions)
229 {
230 bool convertSuccess = false;
231 object return_result = null;
232 string errorMessage = String.Empty;
233 bool ignoreNextFromConfig = false;
234 while (convertSuccess == false)
235 {
236 string console_result = String.Empty;
237 string attribute = null;
238 if (useFile || configurationFromXMLNode != null)
239 {
240 if (!ignoreNextFromConfig)
241 {
242 attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
243 }
244 else
245 {
246 ignoreNextFromConfig = false;
247 }
248 }
249
250 if (attribute == null)
251 {
252 if (configOption.configurationUseDefaultNoPrompt || useConsoleToPromptOnError == false)
253 {
254 console_result = configOption.configurationDefault;
255 }
256 else
257 {
258 if ((configOption.shouldIBeAsked != null &&
259 configOption.shouldIBeAsked(configOption.configurationKey)) ||
260 configOption.shouldIBeAsked == null)
261 {
262 if (configurationDescription.Trim() != String.Empty)
263 {
264 console_result =
265 MainConsole.Instance.CmdPrompt(
266 configurationDescription + ": " + configOption.configurationQuestion,
267 configOption.configurationDefault);
268 }
269 else
270 {
271 console_result =
272 MainConsole.Instance.CmdPrompt(configOption.configurationQuestion,
273 configOption.configurationDefault);
274 }
275 }
276 else
277 {
278 //Dont Ask! Just use default
279 console_result = configOption.configurationDefault;
280 }
281 }
282 }
283 else
284 {
285 console_result = attribute;
286 }
287
288 // if the first character is a "$", assume it's the name
289 // of an environment variable and substitute with the value of that variable
290 if (console_result.StartsWith("$"))
291 console_result = Environment.GetEnvironmentVariable(console_result.Substring(1));
292
293 switch (configOption.configurationType)
294 {
295 case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
296 return_result = console_result;
297 convertSuccess = true;
298 break;
299 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
300 if (console_result.Length > 0)
301 {
302 return_result = console_result;
303 convertSuccess = true;
304 }
305 errorMessage = "a string that is not empty";
306 break;
307 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
308 bool boolResult;
309 if (Boolean.TryParse(console_result, out boolResult))
310 {
311 convertSuccess = true;
312 return_result = boolResult;
313 }
314 errorMessage = "'true' or 'false' (Boolean)";
315 break;
316 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
317 byte byteResult;
318 if (Byte.TryParse(console_result, out byteResult))
319 {
320 convertSuccess = true;
321 return_result = byteResult;
322 }
323 errorMessage = "a byte (Byte)";
324 break;
325 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
326 char charResult;
327 if (Char.TryParse(console_result, out charResult))
328 {
329 convertSuccess = true;
330 return_result = charResult;
331 }
332 errorMessage = "a character (Char)";
333 break;
334 case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
335 short shortResult;
336 if (Int16.TryParse(console_result, out shortResult))
337 {
338 convertSuccess = true;
339 return_result = shortResult;
340 }
341 errorMessage = "a signed 32 bit integer (short)";
342 break;
343 case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
344 int intResult;
345 if (Int32.TryParse(console_result, out intResult))
346 {
347 convertSuccess = true;
348 return_result = intResult;
349 }
350 errorMessage = "a signed 32 bit integer (int)";
351 break;
352 case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
353 long longResult;
354 if (Int64.TryParse(console_result, out longResult))
355 {
356 convertSuccess = true;
357 return_result = longResult;
358 }
359 errorMessage = "a signed 32 bit integer (long)";
360 break;
361 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
362 IPAddress ipAddressResult;
363 if (IPAddress.TryParse(console_result, out ipAddressResult))
364 {
365 convertSuccess = true;
366 return_result = ipAddressResult;
367 }
368 errorMessage = "an IP Address (IPAddress)";
369 break;
370 case ConfigurationOption.ConfigurationTypes.TYPE_UUID:
371 UUID uuidResult;
372 if (UUID.TryParse(console_result, out uuidResult))
373 {
374 convertSuccess = true;
375 return_result = uuidResult;
376 }
377 errorMessage = "a UUID (UUID)";
378 break;
379 case ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE:
380 UUID uuidResult2;
381 if (UUID.TryParse(console_result, out uuidResult2))
382 {
383 convertSuccess = true;
384
385 if (uuidResult2 == UUID.Zero)
386 uuidResult2 = UUID.Random();
387
388 return_result = uuidResult2;
389 }
390 errorMessage = "a non-null UUID (UUID)";
391 break;
392 case ConfigurationOption.ConfigurationTypes.TYPE_Vector3:
393 Vector3 vectorResult;
394 if (Vector3.TryParse(console_result, out vectorResult))
395 {
396 convertSuccess = true;
397 return_result = vectorResult;
398 }
399 errorMessage = "a vector (Vector3)";
400 break;
401 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
402 ushort ushortResult;
403 if (UInt16.TryParse(console_result, out ushortResult))
404 {
405 convertSuccess = true;
406 return_result = ushortResult;
407 }
408 errorMessage = "an unsigned 16 bit integer (ushort)";
409 break;
410 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
411 uint uintResult;
412 if (UInt32.TryParse(console_result, out uintResult))
413 {
414 convertSuccess = true;
415 return_result = uintResult;
416 }
417 errorMessage = "an unsigned 32 bit integer (uint)";
418 break;
419 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
420 ulong ulongResult;
421 if (UInt64.TryParse(console_result, out ulongResult))
422 {
423 convertSuccess = true;
424 return_result = ulongResult;
425 }
426 errorMessage = "an unsigned 64 bit integer (ulong)";
427 break;
428 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
429 float floatResult;
430 if (
431 float.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
432 out floatResult))
433 {
434 convertSuccess = true;
435 return_result = floatResult;
436 }
437 errorMessage = "a single-precision floating point number (float)";
438 break;
439 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
440 double doubleResult;
441 if (
442 Double.TryParse(console_result, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, Culture.NumberFormatInfo,
443 out doubleResult))
444 {
445 convertSuccess = true;
446 return_result = doubleResult;
447 }
448 errorMessage = "an double-precision floating point number (double)";
449 break;
450 }
451
452 if (convertSuccess)
453 {
454 if (useFile)
455 {
456 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
457 }
458
459 if (!resultFunction(configOption.configurationKey, return_result))
460 {
461 m_log.Info(
462 "The handler for the last configuration option denied that input, please try again.");
463 convertSuccess = false;
464 ignoreNextFromConfig = true;
465 }
466 }
467 else
468 {
469 if (configOption.configurationUseDefaultNoPrompt)
470 {
471 m_log.Error(string.Format(
472 "[CONFIG]: [{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n",
473 configOption.configurationKey, console_result, errorMessage,
474 configurationFilename));
475 convertSuccess = true;
476 }
477 else
478 {
479 m_log.Warn(string.Format(
480 "[CONFIG]: [{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n",
481 configOption.configurationKey, console_result, errorMessage,
482 configurationFilename));
483 ignoreNextFromConfig = true;
484 }
485 }
486 }
487 }
488
489 if (useFile)
490 {
491 configurationPlugin.Commit();
492 configurationPlugin.Close();
493 }
494 }
495
496 private static IGenericConfig LoadConfigDll(string dllName)
497 {
498 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
499 IGenericConfig plug = null;
500
501 foreach (Type pluginType in pluginAssembly.GetTypes())
502 {
503 if (pluginType.IsPublic)
504 {
505 if (!pluginType.IsAbstract)
506 {
507 Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
508
509 if (typeInterface != null)
510 {
511 plug =
512 (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
513 }
514 }
515 }
516 }
517
518 pluginAssembly = null;
519 return plug;
520 }
521
522 public void forceSetConfigurationOption(string configuration_key, string configuration_value)
523 {
524 configurationPlugin.LoadData();
525 configurationPlugin.SetAttribute(configuration_key, configuration_value);
526 configurationPlugin.Commit();
527 configurationPlugin.Close();
528 }
529 }
530}
diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs
index 67af471..c53d92b 100644
--- a/OpenSim/Framework/Console/AssemblyInfo.cs
+++ b/OpenSim/Framework/Console/AssemblyInfo.cs
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices;
55// You can specify all values by your own or you can build default build and revision 55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default): 56// numbers with the '*' character (the default):
57 57
58[assembly : AssemblyVersion("0.8.2.*")] 58[assembly : AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index 0f68afe..52360b4 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -52,27 +52,27 @@ namespace OpenSim.Framework.Console
52 /// The module from which this command comes 52 /// The module from which this command comes
53 /// </value> 53 /// </value>
54 public string module; 54 public string module;
55 55
56 /// <value> 56 /// <value>
57 /// Whether the module is shared 57 /// Whether the module is shared
58 /// </value> 58 /// </value>
59 public bool shared; 59 public bool shared;
60 60
61 /// <value> 61 /// <value>
62 /// Very short BNF description 62 /// Very short BNF description
63 /// </value> 63 /// </value>
64 public string help_text; 64 public string help_text;
65 65
66 /// <value> 66 /// <value>
67 /// Longer one line help text 67 /// Longer one line help text
68 /// </value> 68 /// </value>
69 public string long_help; 69 public string long_help;
70 70
71 /// <value> 71 /// <value>
72 /// Full descriptive help for this command 72 /// Full descriptive help for this command
73 /// </value> 73 /// </value>
74 public string descriptive_help; 74 public string descriptive_help;
75 75
76 /// <value> 76 /// <value>
77 /// The method to invoke for this command 77 /// The method to invoke for this command
78 /// </value> 78 /// </value>
@@ -83,8 +83,8 @@ namespace OpenSim.Framework.Console
83 = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; 83 = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n";
84 84
85 public const string ItemHelpText 85 public const string ItemHelpText
86= @"For more information, type 'help all' to get a list of all commands, 86 = @"For more information, type 'help all' to get a list of all commands,
87 or type help <item>' where <item> is one of the following:"; 87 or type help <item>' where <item> is one of the following:";
88 88
89 /// <value> 89 /// <value>
90 /// Commands organized by keyword in a tree 90 /// Commands organized by keyword in a tree
@@ -106,7 +106,7 @@ namespace OpenSim.Framework.Console
106 { 106 {
107 List<string> help = new List<string>(); 107 List<string> help = new List<string>();
108 List<string> helpParts = new List<string>(cmd); 108 List<string> helpParts = new List<string>(cmd);
109 109
110 // Remove initial help keyword 110 // Remove initial help keyword
111 helpParts.RemoveAt(0); 111 helpParts.RemoveAt(0);
112 112
@@ -154,7 +154,7 @@ namespace OpenSim.Framework.Console
154 154
155 return help; 155 return help;
156 } 156 }
157 157
158 /// <summary> 158 /// <summary>
159 /// See if we can find the requested command in order to display longer help 159 /// See if we can find the requested command in order to display longer help
160 /// </summary> 160 /// </summary>
@@ -171,23 +171,23 @@ namespace OpenSim.Framework.Console
171 help.Insert(0, ItemHelpText); 171 help.Insert(0, ItemHelpText);
172 return help; 172 return help;
173 } 173 }
174 174
175 Dictionary<string, object> dict = tree; 175 Dictionary<string, object> dict = tree;
176 while (helpParts.Count > 0) 176 while (helpParts.Count > 0)
177 { 177 {
178 string helpPart = helpParts[0]; 178 string helpPart = helpParts[0];
179 179
180 if (!dict.ContainsKey(helpPart)) 180 if (!dict.ContainsKey(helpPart))
181 break; 181 break;
182 182
183 //m_log.Debug("Found {0}", helpParts[0]); 183 //m_log.Debug("Found {0}", helpParts[0]);
184 184
185 if (dict[helpPart] is Dictionary<string, Object>) 185 if (dict[helpPart] is Dictionary<string, Object>)
186 dict = (Dictionary<string, object>)dict[helpPart]; 186 dict = (Dictionary<string, object>)dict[helpPart];
187 187
188 helpParts.RemoveAt(0); 188 helpParts.RemoveAt(0);
189 } 189 }
190 190
191 // There was a command for the given help string 191 // There was a command for the given help string
192 if (dict.ContainsKey(String.Empty)) 192 if (dict.ContainsKey(String.Empty))
193 { 193 {
@@ -200,14 +200,14 @@ namespace OpenSim.Framework.Console
200 // If we do have some descriptive help then insert a spacing line before for readability. 200 // If we do have some descriptive help then insert a spacing line before for readability.
201 if (descriptiveHelp != string.Empty) 201 if (descriptiveHelp != string.Empty)
202 help.Add(string.Empty); 202 help.Add(string.Empty);
203 203
204 help.Add(commandInfo.descriptive_help); 204 help.Add(commandInfo.descriptive_help);
205 } 205 }
206 else 206 else
207 { 207 {
208 help.Add(string.Format("No help is available for {0}", originalHelpRequest)); 208 help.Add(string.Format("No help is available for {0}", originalHelpRequest));
209 } 209 }
210 210
211 return help; 211 return help;
212 } 212 }
213 213
@@ -268,7 +268,7 @@ namespace OpenSim.Framework.Console
268// } 268// }
269// return result; 269// return result;
270// } 270// }
271 271
272 /// <summary> 272 /// <summary>
273 /// Add a command to those which can be invoked from the console. 273 /// Add a command to those which can be invoked from the console.
274 /// </summary> 274 /// </summary>
@@ -299,7 +299,7 @@ namespace OpenSim.Framework.Console
299 string[] parts = Parser.Parse(command); 299 string[] parts = Parser.Parse(command);
300 300
301 Dictionary<string, Object> current = tree; 301 Dictionary<string, Object> current = tree;
302 302
303 foreach (string part in parts) 303 foreach (string part in parts)
304 { 304 {
305 if (current.ContainsKey(part)) 305 if (current.ContainsKey(part))
@@ -326,7 +326,7 @@ namespace OpenSim.Framework.Console
326 326
327 return; 327 return;
328 } 328 }
329 329
330 info = new CommandInfo(); 330 info = new CommandInfo();
331 info.module = module; 331 info.module = module;
332 info.shared = shared; 332 info.shared = shared;
@@ -471,7 +471,7 @@ namespace OpenSim.Framework.Console
471 471
472 return null; 472 return null;
473 } 473 }
474 474
475 public bool HasCommand(string command) 475 public bool HasCommand(string command)
476 { 476 {
477 string[] result; 477 string[] result;
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 2d8e723..64cddea 100644..100755
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Framework.Console
67 { 67 {
68 System.Console.WriteLine(text); 68 System.Console.WriteLine(text);
69 } 69 }
70 70
71 public virtual void OutputFormat(string format, params object[] components) 71 public virtual void OutputFormat(string format, params object[] components)
72 { 72 {
73 Output(string.Format(format, components)); 73 Output(string.Format(format, components));
@@ -86,7 +86,7 @@ namespace OpenSim.Framework.Console
86 86
87 return ret; 87 return ret;
88 } 88 }
89 89
90 public string CmdPrompt(string p, List<char> excludedCharacters) 90 public string CmdPrompt(string p, List<char> excludedCharacters)
91 { 91 {
92 bool itisdone = false; 92 bool itisdone = false;
@@ -95,7 +95,7 @@ namespace OpenSim.Framework.Console
95 { 95 {
96 itisdone = true; 96 itisdone = true;
97 ret = CmdPrompt(p); 97 ret = CmdPrompt(p);
98 98
99 foreach (char c in excludedCharacters) 99 foreach (char c in excludedCharacters)
100 { 100 {
101 if (ret.Contains(c.ToString())) 101 if (ret.Contains(c.ToString()))
@@ -117,7 +117,7 @@ namespace OpenSim.Framework.Console
117 { 117 {
118 itisdone = true; 118 itisdone = true;
119 ret = CmdPrompt(p, def); 119 ret = CmdPrompt(p, def);
120 120
121 if (ret == String.Empty) 121 if (ret == String.Empty)
122 { 122 {
123 ret = def; 123 ret = def;
diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs
index f4d3687..f4d3687 100644..100755
--- a/OpenSim/Framework/Console/ConsolePluginCommand.cs
+++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 44f6dc1..bfa05a2 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework.Console
40 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 41
42 public const int LocalIdNotFound = 0; 42 public const int LocalIdNotFound = 0;
43 43
44 /// <summary> 44 /// <summary>
45 /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section 45 /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
46 /// rather than in each help summary. 46 /// rather than in each help summary.
@@ -57,10 +57,10 @@ namespace OpenSim.Framework.Console
57 show object pos ,20,20 to ,40,40 57 show object pos ,20,20 to ,40,40
58 delete object pos ,,30 to ,,~ 58 delete object pos ,,30 to ,,~
59 show object pos ,,-~ to ,,30"; 59 show object pos ,,-~ to ,,30";
60 60
61 public const string MinRawConsoleVectorValue = "-~"; 61 public const string MinRawConsoleVectorValue = "-~";
62 public const string MaxRawConsoleVectorValue = "~"; 62 public const string MaxRawConsoleVectorValue = "~";
63 63
64 public const string VectorSeparator = ","; 64 public const string VectorSeparator = ",";
65 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); 65 public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
66 66
@@ -81,7 +81,7 @@ namespace OpenSim.Framework.Console
81 81
82 return true; 82 return true;
83 } 83 }
84 84
85 /// <summary> 85 /// <summary>
86 /// Try to parse a console UUID from the console. 86 /// Try to parse a console UUID from the console.
87 /// </summary> 87 /// </summary>
@@ -101,7 +101,7 @@ namespace OpenSim.Framework.Console
101 101
102 return false; 102 return false;
103 } 103 }
104 104
105 return true; 105 return true;
106 } 106 }
107 107
@@ -259,7 +259,7 @@ namespace OpenSim.Framework.Console
259 259
260 return false; 260 return false;
261 } 261 }
262 262
263 /// <summary> 263 /// <summary>
264 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 264 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
265 /// </summary> 265 /// </summary>
@@ -270,7 +270,7 @@ namespace OpenSim.Framework.Console
270 { 270 {
271 return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); 271 return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
272 } 272 }
273 273
274 /// <summary> 274 /// <summary>
275 /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 275 /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
276 /// </summary> 276 /// </summary>
@@ -281,7 +281,7 @@ namespace OpenSim.Framework.Console
281 { 281 {
282 return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); 282 return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
283 } 283 }
284 284
285 /// <summary> 285 /// <summary>
286 /// Convert a vector input from the console to an OpenMetaverse.Vector3 286 /// Convert a vector input from the console to an OpenMetaverse.Vector3
287 /// </summary> 287 /// </summary>
@@ -354,10 +354,10 @@ namespace OpenSim.Framework.Console
354 string rawConsoleVector, int dimensions, Func<string, string> blankComponentFunc) 354 string rawConsoleVector, int dimensions, Func<string, string> blankComponentFunc)
355 { 355 {
356 List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); 356 List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
357 357
358 if (components.Count < 1 || components.Count > dimensions) 358 if (components.Count < 1 || components.Count > dimensions)
359 return null; 359 return null;
360 360
361 if (components.Count < dimensions) 361 if (components.Count < dimensions)
362 { 362 {
363 if (blankComponentFunc == null) 363 if (blankComponentFunc == null)
@@ -380,7 +380,7 @@ namespace OpenSim.Framework.Console
380 else 380 else
381 return c; 381 return c;
382 }); 382 });
383 383
384 return string.Join(VectorSeparator, cookedComponents.ToArray()); 384 return string.Join(VectorSeparator, cookedComponents.ToArray());
385 } 385 }
386 } 386 }
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs
index d8f8ecc..73f0323 100644
--- a/OpenSim/Framework/Console/LocalConsole.cs
+++ b/OpenSim/Framework/Console/LocalConsole.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Framework.Console
51 private const string LOGLEVEL_NONE = "(none)"; 51 private const string LOGLEVEL_NONE = "(none)";
52 52
53 // Used to extract categories for colourization. 53 // Used to extract categories for colourization.
54 private Regex m_categoryRegex 54 private Regex m_categoryRegex
55 = new Regex( 55 = new Regex(
56 @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled); 56 @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled);
57 57
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console
97 97
98 string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); 98 string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt");
99 int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); 99 int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100);
100 m_historyPath = Path.GetFullPath(Path.Combine("../caches", m_historyFile)); 100 m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile));
101 m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); 101 m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath);
102 102
103 if (File.Exists(m_historyPath)) 103 if (File.Exists(m_historyPath))
@@ -167,15 +167,15 @@ namespace OpenSim.Framework.Console
167 { 167 {
168 System.Console.CursorLeft = 0; 168 System.Console.CursorLeft = 0;
169 } 169 }
170 else 170 else
171 { 171 {
172 int bufferWidth = System.Console.BufferWidth; 172 int bufferWidth = System.Console.BufferWidth;
173 173
174 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) 174 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
175 if (bufferWidth > 0 && left >= bufferWidth) 175 if (bufferWidth > 0 && left >= bufferWidth)
176 System.Console.CursorLeft = bufferWidth - 1; 176 System.Console.CursorLeft = bufferWidth - 1;
177 } 177 }
178 178
179 if (top < 0) 179 if (top < 0)
180 { 180 {
181 top = 0; 181 top = 0;
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Console
183 else 183 else
184 { 184 {
185 int bufferHeight = System.Console.BufferHeight; 185 int bufferHeight = System.Console.BufferHeight;
186 186
187 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) 187 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
188 if (bufferHeight > 0 && top >= bufferHeight) 188 if (bufferHeight > 0 && top >= bufferHeight)
189 top = bufferHeight - 1; 189 top = bufferHeight - 1;
@@ -216,14 +216,14 @@ namespace OpenSim.Framework.Console
216 { 216 {
217 System.Console.CursorTop = 0; 217 System.Console.CursorTop = 0;
218 } 218 }
219 else 219 else
220 { 220 {
221 int bufferHeight = System.Console.BufferHeight; 221 int bufferHeight = System.Console.BufferHeight;
222 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657) 222 // On Mono 2.4.2.3 (and possibly above), the buffer value is sometimes erroneously zero (Mantis 4657)
223 if (bufferHeight > 0 && top >= bufferHeight) 223 if (bufferHeight > 0 && top >= bufferHeight)
224 System.Console.CursorTop = bufferHeight - 1; 224 System.Console.CursorTop = bufferHeight - 1;
225 } 225 }
226 226
227 if (left < 0) 227 if (left < 0)
228 { 228 {
229 left = 0; 229 left = 0;
@@ -339,7 +339,7 @@ namespace OpenSim.Framework.Console
339 string outText = text; 339 string outText = text;
340 340
341 if (level != LOGLEVEL_NONE) 341 if (level != LOGLEVEL_NONE)
342 { 342 {
343 MatchCollection matches = m_categoryRegex.Matches(text); 343 MatchCollection matches = m_categoryRegex.Matches(text);
344 344
345 if (matches.Count == 1) 345 if (matches.Count == 1)
@@ -364,7 +364,7 @@ namespace OpenSim.Framework.Console
364 WriteColorText(ConsoleColor.Yellow, outText); 364 WriteColorText(ConsoleColor.Yellow, outText);
365 else 365 else
366 System.Console.Write(outText); 366 System.Console.Write(outText);
367 367
368 System.Console.WriteLine(); 368 System.Console.WriteLine();
369 } 369 }
370 370
@@ -551,7 +551,7 @@ namespace OpenSim.Framework.Console
551 } 551 }
552 552
553 string commandLine = m_commandLine.ToString(); 553 string commandLine = m_commandLine.ToString();
554 554
555 if (isCommand) 555 if (isCommand)
556 { 556 {
557 string[] cmd = Commands.Resolve(Parser.Parse(commandLine)); 557 string[] cmd = Commands.Resolve(Parser.Parse(commandLine));
@@ -573,7 +573,7 @@ namespace OpenSim.Framework.Console
573 // If we're not echoing to screen (e.g. a password) then we probably don't want it in history 573 // If we're not echoing to screen (e.g. a password) then we probably don't want it in history
574 if (m_echo && commandLine != "") 574 if (m_echo && commandLine != "")
575 AddToHistory(commandLine); 575 AddToHistory(commandLine);
576 576
577 return commandLine; 577 return commandLine;
578 default: 578 default:
579 break; 579 break;
diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs
index 1a142df..e1ff720 100644
--- a/OpenSim/Framework/Console/MockConsole.cs
+++ b/OpenSim/Framework/Console/MockConsole.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Framework.Console
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// This is a Fake console that's used when setting up the Scene in Unit Tests 37 /// This is a Fake console that's used when setting up the Scene in Unit Tests
38 /// Don't use this except for Unit Testing or you're in for a world of hurt when the 38 /// Don't use this except for Unit Testing or you're in for a world of hurt when the
39 /// sim gets to ReadLine 39 /// sim gets to ReadLine
40 /// </summary> 40 /// </summary>
41 public class MockConsole : ICommandConsole 41 public class MockConsole : ICommandConsole
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Console
56 56
57 public string ReadLine(string p, bool isCommand, bool e) { return ""; } 57 public string ReadLine(string p, bool isCommand, bool e) { return ""; }
58 58
59 public object ConsoleScene { 59 public object ConsoleScene {
60 get { return null; } 60 get { return null; }
61 set {} 61 set {}
62 } 62 }
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index 8ad7b0d..f59c902 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -34,6 +34,7 @@ using System.Reflection;
34using System.Text; 34using System.Text;
35using System.Text.RegularExpressions; 35using System.Text.RegularExpressions;
36using System.Threading; 36using System.Threading;
37using System.Timers;
37using OpenMetaverse; 38using OpenMetaverse;
38using Nini.Config; 39using Nini.Config;
39using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
@@ -41,51 +42,147 @@ using log4net;
41 42
42namespace OpenSim.Framework.Console 43namespace OpenSim.Framework.Console
43{ 44{
44 public class ConsoleConnection
45 {
46 public int last;
47 public long lastLineSeen;
48 public bool newConnection = true;
49 }
50
51 // A console that uses REST interfaces 45 // A console that uses REST interfaces
52 // 46 //
53 public class RemoteConsole : CommandConsole 47 public class RemoteConsole : CommandConsole
54 { 48 {
55 private IHttpServer m_Server = null; 49 // Connection specific data, indexed by a session ID
56 private IConfigSource m_Config = null; 50 // we create when a client connects.
57 51 protected class ConsoleConnection
58 private List<string> m_Scrollback = new List<string>(); 52 {
59 private ManualResetEvent m_DataEvent = new ManualResetEvent(false); 53 // Last activity from the client
60 private List<string> m_InputData = new List<string>(); 54 public int last;
61 private long m_LineNumber = 0; 55
62 private Dictionary<UUID, ConsoleConnection> m_Connections = 56 // Last line of scrollback posted to this client
57 public long lastLineSeen;
58
59 // True if this is a new connection, e.g. has never
60 // displayed a prompt to the user.
61 public bool newConnection = true;
62 }
63
64 // A line in the scrollback buffer.
65 protected class ScrollbackEntry
66 {
67 // The line number of this entry
68 public long lineNumber;
69
70 // The text to send to the client
71 public string text;
72
73 // The level this should be logged as. Omitted for
74 // prompts and input echo.
75 public string level;
76
77 // True if the text above is a prompt, e.g. the
78 // client should turn on the cursor / accept input
79 public bool isPrompt;
80
81 // True if the requested input is a command. A
82 // client may offer help or validate input if
83 // this is set. If false, input should be sent
84 // as typed.
85 public bool isCommand;
86
87 // True if this text represents a line of text that
88 // was input in response to a prompt. A client should
89 // turn off the cursor and refrain from sending commands
90 // until a new prompt is received.
91 public bool isInput;
92 }
93
94 // Data that is relevant to all connections
95
96 // The scrollback buffer
97 protected List<ScrollbackEntry> m_Scrollback = new List<ScrollbackEntry>();
98
99 // Monotonously incrementing line number. This may eventually
100 // wrap. No provision is made for that case because 64 bits
101 // is a long, long time.
102 protected long m_lineNumber = 0;
103
104 // These two variables allow us to send the correct
105 // information about the prompt status to the client,
106 // irrespective of what may have run off the top of the
107 // scrollback buffer;
108 protected bool m_expectingInput = false;
109 protected bool m_expectingCommand = true;
110 protected string m_lastPromptUsed;
111
112 // This is the list of things received from clients.
113 // Note: Race conditions can happen. If a client sends
114 // something while nothing is expected, it will be
115 // intepreted as input to the next prompt. For
116 // commands this is largely correct. For other prompts,
117 // YMMV.
118 // TODO: Find a better way to fix this
119 protected List<string> m_InputData = new List<string>();
120
121 // Event to allow ReadLine to wait synchronously even though
122 // everthing else is asynchronous here.
123 protected ManualResetEvent m_DataEvent = new ManualResetEvent(false);
124
125 // The list of sessions we maintain. Unlike other console types,
126 // multiple users on the same console are explicitly allowed.
127 protected Dictionary<UUID, ConsoleConnection> m_Connections =
63 new Dictionary<UUID, ConsoleConnection>(); 128 new Dictionary<UUID, ConsoleConnection>();
64 private string m_UserName = String.Empty; 129
65 private string m_Password = String.Empty; 130 // Timer to control expiration of sessions that have been
66 private string m_AllowedOrigin = String.Empty; 131 // disconnected.
132 protected System.Timers.Timer m_expireTimer = new System.Timers.Timer(5000);
133
134 // The less interesting stuff that makes the actual server
135 // work.
136 protected IHttpServer m_Server = null;
137 protected IConfigSource m_Config = null;
138
139 protected string m_UserName = String.Empty;
140 protected string m_Password = String.Empty;
141 protected string m_AllowedOrigin = String.Empty;
142
67 143
68 public RemoteConsole(string defaultPrompt) : base(defaultPrompt) 144 public RemoteConsole(string defaultPrompt) : base(defaultPrompt)
69 { 145 {
146 // There is something wrong with this architecture.
147 // A prompt is sent on every single input, so why have this?
148 // TODO: Investigate and fix.
149 m_lastPromptUsed = defaultPrompt;
150
151 // Start expiration of sesssions.
152 m_expireTimer.Elapsed += DoExpire;
153 m_expireTimer.Start();
70 } 154 }
71 155
72 public void ReadConfig(IConfigSource config) 156 public void ReadConfig(IConfigSource config)
73 { 157 {
74 m_Config = config; 158 m_Config = config;
75 159
160 // We're pulling this from the 'Network' section for legacy
161 // compatibility. However, this is so essentially insecure
162 // that TLS and client certs should be used instead of
163 // a username / password.
76 IConfig netConfig = m_Config.Configs["Network"]; 164 IConfig netConfig = m_Config.Configs["Network"];
165
77 if (netConfig == null) 166 if (netConfig == null)
78 return; 167 return;
79 168
169 // Get the username and password.
80 m_UserName = netConfig.GetString("ConsoleUser", String.Empty); 170 m_UserName = netConfig.GetString("ConsoleUser", String.Empty);
81 m_Password = netConfig.GetString("ConsolePass", String.Empty); 171 m_Password = netConfig.GetString("ConsolePass", String.Empty);
172
173 // Woefully underdocumented, this is what makes javascript
174 // console clients work. Set to "*" for anywhere or (better)
175 // to specific addresses.
82 m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty); 176 m_AllowedOrigin = netConfig.GetString("ConsoleAllowedOrigin", String.Empty);
83 } 177 }
84 178
85 public void SetServer(IHttpServer server) 179 public void SetServer(IHttpServer server)
86 { 180 {
181 // This is called by the framework to give us the server
182 // instance (means: port) to work with.
87 m_Server = server; 183 m_Server = server;
88 184
185 // Add our handlers
89 m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession); 186 m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession);
90 m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession); 187 m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession);
91 m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); 188 m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand);
@@ -93,38 +190,84 @@ namespace OpenSim.Framework.Console
93 190
94 public override void Output(string text, string level) 191 public override void Output(string text, string level)
95 { 192 {
193 Output(text, level, false, false, false);
194 }
195
196 protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput)
197 {
198 // Increment the line number. It was 0 and they start at 1
199 // so we need to pre-increment.
200 m_lineNumber++;
201
202 // Create and populate the new entry.
203 ScrollbackEntry newEntry = new ScrollbackEntry();
204
205 newEntry.lineNumber = m_lineNumber;
206 newEntry.text = text;
207 newEntry.level = level;
208 newEntry.isPrompt = isPrompt;
209 newEntry.isCommand = isCommand;
210 newEntry.isInput = isInput;
211
212 // Add a line to the scrollback. In some cases, that may not
213 // actually be a line of text.
96 lock (m_Scrollback) 214 lock (m_Scrollback)
97 { 215 {
216 // Prune the scrollback to the length se send as connect
217 // burst to give the user some context.
98 while (m_Scrollback.Count >= 1000) 218 while (m_Scrollback.Count >= 1000)
99 m_Scrollback.RemoveAt(0); 219 m_Scrollback.RemoveAt(0);
100 m_LineNumber++; 220
101 m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text); 221 m_Scrollback.Add(newEntry);
102 } 222 }
223
224 // Let the rest of the system know we have output something.
103 FireOnOutput(text.Trim()); 225 FireOnOutput(text.Trim());
226
227 // Also display it for debugging.
104 System.Console.WriteLine(text.Trim()); 228 System.Console.WriteLine(text.Trim());
105 } 229 }
106 230
107 public override void Output(string text) 231 public override void Output(string text)
108 { 232 {
109 Output(text, "normal"); 233 // Output plain (non-logging style) text.
234 Output(text, String.Empty, false, false, false);
110 } 235 }
111 236
112 public override string ReadLine(string p, bool isCommand, bool e) 237 public override string ReadLine(string p, bool isCommand, bool e)
113 { 238 {
239 // Output the prompt an prepare to wait. This
240 // is called on a dedicated console thread and
241 // needs to be synchronous. Old architecture but
242 // not worth upgrading.
114 if (isCommand) 243 if (isCommand)
115 Output("+++"+p); 244 {
245 m_expectingInput = true;
246 m_expectingCommand = true;
247 Output(p, String.Empty, true, true, false);
248 m_lastPromptUsed = p;
249 }
116 else 250 else
117 Output("-++"+p); 251 {
252 m_expectingInput = true;
253 Output(p, String.Empty, true, false, false);
254 }
118 255
256
257 // Here is where we wait for the user to input something.
119 m_DataEvent.WaitOne(); 258 m_DataEvent.WaitOne();
120 259
121 string cmdinput; 260 string cmdinput;
122 261
262 // Check for empty input. Read input if not empty.
123 lock (m_InputData) 263 lock (m_InputData)
124 { 264 {
125 if (m_InputData.Count == 0) 265 if (m_InputData.Count == 0)
126 { 266 {
127 m_DataEvent.Reset(); 267 m_DataEvent.Reset();
268 m_expectingInput = false;
269 m_expectingCommand = false;
270
128 return ""; 271 return "";
129 } 272 }
130 273
@@ -135,8 +278,19 @@ namespace OpenSim.Framework.Console
135 278
136 } 279 }
137 280
281 m_expectingInput = false;
282 m_expectingCommand = false;
283
284 // Echo to all the other users what we have done. This
285 // will also go to ourselves.
286 Output (cmdinput, String.Empty, false, false, true);
287
288 // If this is a command, we need to resolve and execute it.
138 if (isCommand) 289 if (isCommand)
139 { 290 {
291 // This call will actually execute the command and create
292 // any output associated with it. The core just gets an
293 // empty string so it will call again immediately.
140 string[] cmd = Commands.Resolve(Parser.Parse(cmdinput)); 294 string[] cmd = Commands.Resolve(Parser.Parse(cmdinput));
141 295
142 if (cmd.Length != 0) 296 if (cmd.Length != 0)
@@ -151,18 +305,23 @@ namespace OpenSim.Framework.Console
151 return String.Empty; 305 return String.Empty;
152 } 306 }
153 } 307 }
308
309 // Return the raw input string if not a command.
154 return cmdinput; 310 return cmdinput;
155 } 311 }
156 312
157 private Hashtable CheckOrigin(Hashtable result) 313 // Very simplistic static access control header.
314 protected Hashtable CheckOrigin(Hashtable result)
158 { 315 {
159 if (!string.IsNullOrEmpty(m_AllowedOrigin)) 316 if (!string.IsNullOrEmpty(m_AllowedOrigin))
160 result["access_control_allow_origin"] = m_AllowedOrigin; 317 result["access_control_allow_origin"] = m_AllowedOrigin;
318
161 return result; 319 return result;
162 } 320 }
321
163 /* TODO: Figure out how PollServiceHTTPHandler can access the request headers 322 /* TODO: Figure out how PollServiceHTTPHandler can access the request headers
164 * in order to use m_AllowedOrigin as a regular expression 323 * in order to use m_AllowedOrigin as a regular expression
165 private Hashtable CheckOrigin(Hashtable headers, Hashtable result) 324 protected Hashtable CheckOrigin(Hashtable headers, Hashtable result)
166 { 325 {
167 if (!string.IsNullOrEmpty(m_AllowedOrigin)) 326 if (!string.IsNullOrEmpty(m_AllowedOrigin))
168 { 327 {
@@ -177,18 +336,23 @@ namespace OpenSim.Framework.Console
177 } 336 }
178 */ 337 */
179 338
180 private void DoExpire() 339 protected void DoExpire(Object sender, ElapsedEventArgs e)
181 { 340 {
341 // Iterate the list of console connections and find those we
342 // haven't heard from for longer then the longpoll interval.
343 // Remove them.
182 List<UUID> expired = new List<UUID>(); 344 List<UUID> expired = new List<UUID>();
183 345
184 lock (m_Connections) 346 lock (m_Connections)
185 { 347 {
348 // Mark the expired ones
186 foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections) 349 foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections)
187 { 350 {
188 if (System.Environment.TickCount - kvp.Value.last > 500000) 351 if (System.Environment.TickCount - kvp.Value.last > 500000)
189 expired.Add(kvp.Key); 352 expired.Add(kvp.Key);
190 } 353 }
191 354
355 // Delete them
192 foreach (UUID id in expired) 356 foreach (UUID id in expired)
193 { 357 {
194 m_Connections.Remove(id); 358 m_Connections.Remove(id);
@@ -197,10 +361,10 @@ namespace OpenSim.Framework.Console
197 } 361 }
198 } 362 }
199 363
200 private Hashtable HandleHttpStartSession(Hashtable request) 364 // Start a new session.
365 protected Hashtable HandleHttpStartSession(Hashtable request)
201 { 366 {
202 DoExpire(); 367 // The login is in the form of a http form post
203
204 Hashtable post = DecodePostString(request["body"].ToString()); 368 Hashtable post = DecodePostString(request["body"].ToString());
205 Hashtable reply = new Hashtable(); 369 Hashtable reply = new Hashtable();
206 370
@@ -208,6 +372,7 @@ namespace OpenSim.Framework.Console
208 reply["int_response_code"] = 401; 372 reply["int_response_code"] = 401;
209 reply["content_type"] = "text/plain"; 373 reply["content_type"] = "text/plain";
210 374
375 // Check user name and password
211 if (m_UserName == String.Empty) 376 if (m_UserName == String.Empty)
212 return reply; 377 return reply;
213 378
@@ -220,22 +385,28 @@ namespace OpenSim.Framework.Console
220 return reply; 385 return reply;
221 } 386 }
222 387
388 // Set up the new console connection record
223 ConsoleConnection c = new ConsoleConnection(); 389 ConsoleConnection c = new ConsoleConnection();
224 c.last = System.Environment.TickCount; 390 c.last = System.Environment.TickCount;
225 c.lastLineSeen = 0; 391 c.lastLineSeen = 0;
226 392
393 // Assign session ID
227 UUID sessionID = UUID.Random(); 394 UUID sessionID = UUID.Random();
228 395
396 // Add connection to list.
229 lock (m_Connections) 397 lock (m_Connections)
230 { 398 {
231 m_Connections[sessionID] = c; 399 m_Connections[sessionID] = c;
232 } 400 }
233 401
402 // This call is a CAP. The URL is the authentication.
234 string uri = "/ReadResponses/" + sessionID.ToString() + "/"; 403 string uri = "/ReadResponses/" + sessionID.ToString() + "/";
235 404
236 m_Server.AddPollServiceHTTPHandler( 405 m_Server.AddPollServiceHTTPHandler(
237 uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout 406 uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout
238 407
408 // Our reply is an XML document.
409 // TODO: Change this to Linq.Xml
239 XmlDocument xmldoc = new XmlDocument(); 410 XmlDocument xmldoc = new XmlDocument();
240 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 411 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
241 "", ""); 412 "", "");
@@ -252,12 +423,13 @@ namespace OpenSim.Framework.Console
252 rootElement.AppendChild(id); 423 rootElement.AppendChild(id);
253 424
254 XmlElement prompt = xmldoc.CreateElement("", "Prompt", ""); 425 XmlElement prompt = xmldoc.CreateElement("", "Prompt", "");
255 prompt.AppendChild(xmldoc.CreateTextNode(DefaultPrompt)); 426 prompt.AppendChild(xmldoc.CreateTextNode(m_lastPromptUsed));
256 427
257 rootElement.AppendChild(prompt); 428 rootElement.AppendChild(prompt);
258 429
259 rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc)); 430 rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc));
260 431
432 // Set up the response and check origin
261 reply["str_response_string"] = xmldoc.InnerXml; 433 reply["str_response_string"] = xmldoc.InnerXml;
262 reply["int_response_code"] = 200; 434 reply["int_response_code"] = 200;
263 reply["content_type"] = "text/xml"; 435 reply["content_type"] = "text/xml";
@@ -266,10 +438,9 @@ namespace OpenSim.Framework.Console
266 return reply; 438 return reply;
267 } 439 }
268 440
269 private Hashtable HandleHttpCloseSession(Hashtable request) 441 // Client closes session. Clean up.
442 protected Hashtable HandleHttpCloseSession(Hashtable request)
270 { 443 {
271 DoExpire();
272
273 Hashtable post = DecodePostString(request["body"].ToString()); 444 Hashtable post = DecodePostString(request["body"].ToString());
274 Hashtable reply = new Hashtable(); 445 Hashtable reply = new Hashtable();
275 446
@@ -316,10 +487,9 @@ namespace OpenSim.Framework.Console
316 return reply; 487 return reply;
317 } 488 }
318 489
319 private Hashtable HandleHttpSessionCommand(Hashtable request) 490 // Command received from the client.
491 protected Hashtable HandleHttpSessionCommand(Hashtable request)
320 { 492 {
321 DoExpire();
322
323 Hashtable post = DecodePostString(request["body"].ToString()); 493 Hashtable post = DecodePostString(request["body"].ToString());
324 Hashtable reply = new Hashtable(); 494 Hashtable reply = new Hashtable();
325 495
@@ -327,6 +497,7 @@ namespace OpenSim.Framework.Console
327 reply["int_response_code"] = 404; 497 reply["int_response_code"] = 404;
328 reply["content_type"] = "text/plain"; 498 reply["content_type"] = "text/plain";
329 499
500 // Check the ID
330 if (post["ID"] == null) 501 if (post["ID"] == null)
331 return reply; 502 return reply;
332 503
@@ -334,21 +505,25 @@ namespace OpenSim.Framework.Console
334 if (!UUID.TryParse(post["ID"].ToString(), out id)) 505 if (!UUID.TryParse(post["ID"].ToString(), out id))
335 return reply; 506 return reply;
336 507
508 // Find the connection for that ID.
337 lock (m_Connections) 509 lock (m_Connections)
338 { 510 {
339 if (!m_Connections.ContainsKey(id)) 511 if (!m_Connections.ContainsKey(id))
340 return reply; 512 return reply;
341 } 513 }
342 514
515 // Empty post. Just error out.
343 if (post["COMMAND"] == null) 516 if (post["COMMAND"] == null)
344 return reply; 517 return reply;
345 518
519 // Place the input data in the buffer.
346 lock (m_InputData) 520 lock (m_InputData)
347 { 521 {
348 m_DataEvent.Set(); 522 m_DataEvent.Set();
349 m_InputData.Add(post["COMMAND"].ToString()); 523 m_InputData.Add(post["COMMAND"].ToString());
350 } 524 }
351 525
526 // Create the XML reply document.
352 XmlDocument xmldoc = new XmlDocument(); 527 XmlDocument xmldoc = new XmlDocument();
353 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 528 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
354 "", ""); 529 "", "");
@@ -372,7 +547,8 @@ namespace OpenSim.Framework.Console
372 return reply; 547 return reply;
373 } 548 }
374 549
375 private Hashtable DecodePostString(string data) 550 // Decode a HTTP form post to a Hashtable
551 protected Hashtable DecodePostString(string data)
376 { 552 {
377 Hashtable result = new Hashtable(); 553 Hashtable result = new Hashtable();
378 554
@@ -389,13 +565,14 @@ namespace OpenSim.Framework.Console
389 565
390 if (elems.Length > 1) 566 if (elems.Length > 1)
391 value = System.Web.HttpUtility.UrlDecode(elems[1]); 567 value = System.Web.HttpUtility.UrlDecode(elems[1]);
392 568
393 result[name] = value; 569 result[name] = value;
394 } 570 }
395 571
396 return result; 572 return result;
397 } 573 }
398 574
575 // Close the CAP receiver for the responses for a given client.
399 public void CloseConnection(UUID id) 576 public void CloseConnection(UUID id)
400 { 577 {
401 try 578 try
@@ -409,7 +586,9 @@ namespace OpenSim.Framework.Console
409 } 586 }
410 } 587 }
411 588
412 private bool HasEvents(UUID RequestID, UUID sessionID) 589 // Check if there is anything to send. Return true if this client has
590 // lines pending.
591 protected bool HasEvents(UUID RequestID, UUID sessionID)
413 { 592 {
414 ConsoleConnection c = null; 593 ConsoleConnection c = null;
415 594
@@ -420,13 +599,15 @@ namespace OpenSim.Framework.Console
420 c = m_Connections[sessionID]; 599 c = m_Connections[sessionID];
421 } 600 }
422 c.last = System.Environment.TickCount; 601 c.last = System.Environment.TickCount;
423 if (c.lastLineSeen < m_LineNumber) 602 if (c.lastLineSeen < m_lineNumber)
424 return true; 603 return true;
425 return false; 604 return false;
426 } 605 }
427 606
428 private Hashtable GetEvents(UUID RequestID, UUID sessionID) 607 // Send all pending output to the client.
608 protected Hashtable GetEvents(UUID RequestID, UUID sessionID)
429 { 609 {
610 // Find the connection that goes with this client.
430 ConsoleConnection c = null; 611 ConsoleConnection c = null;
431 612
432 lock (m_Connections) 613 lock (m_Connections)
@@ -435,12 +616,15 @@ namespace OpenSim.Framework.Console
435 return NoEvents(RequestID, UUID.Zero); 616 return NoEvents(RequestID, UUID.Zero);
436 c = m_Connections[sessionID]; 617 c = m_Connections[sessionID];
437 } 618 }
619
620 // If we have nothing to send, send the no events response.
438 c.last = System.Environment.TickCount; 621 c.last = System.Environment.TickCount;
439 if (c.lastLineSeen >= m_LineNumber) 622 if (c.lastLineSeen >= m_lineNumber)
440 return NoEvents(RequestID, UUID.Zero); 623 return NoEvents(RequestID, UUID.Zero);
441 624
442 Hashtable result = new Hashtable(); 625 Hashtable result = new Hashtable();
443 626
627 // Create the response document.
444 XmlDocument xmldoc = new XmlDocument(); 628 XmlDocument xmldoc = new XmlDocument();
445 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 629 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
446 "", ""); 630 "", "");
@@ -449,30 +633,53 @@ namespace OpenSim.Framework.Console
449 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession", 633 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
450 ""); 634 "");
451 635
452 if (c.newConnection) 636 //if (c.newConnection)
453 { 637 //{
454 c.newConnection = false; 638 // c.newConnection = false;
455 Output("+++" + DefaultPrompt); 639 // Output("+++" + DefaultPrompt);
456 } 640 //}
457 641
458 lock (m_Scrollback) 642 lock (m_Scrollback)
459 { 643 {
460 long startLine = m_LineNumber - m_Scrollback.Count; 644 long startLine = m_lineNumber - m_Scrollback.Count;
461 long sendStart = startLine; 645 long sendStart = startLine;
462 if (sendStart < c.lastLineSeen) 646 if (sendStart < c.lastLineSeen)
463 sendStart = c.lastLineSeen; 647 sendStart = c.lastLineSeen;
464 648
465 for (long i = sendStart ; i < m_LineNumber ; i++) 649 for (long i = sendStart ; i < m_lineNumber ; i++)
466 { 650 {
651 ScrollbackEntry e = m_Scrollback[(int)(i - startLine)];
652
467 XmlElement res = xmldoc.CreateElement("", "Line", ""); 653 XmlElement res = xmldoc.CreateElement("", "Line", "");
468 long line = i + 1; 654 res.SetAttribute("Number", e.lineNumber.ToString());
469 res.SetAttribute("Number", line.ToString()); 655 res.SetAttribute("Level", e.level);
470 res.AppendChild(xmldoc.CreateTextNode(m_Scrollback[(int)(i - startLine)])); 656 // Don't include these for the scrollback, we'll send the
657 // real state later.
658 if (!c.newConnection)
659 {
660 res.SetAttribute("Prompt", e.isPrompt ? "true" : "false");
661 res.SetAttribute("Command", e.isCommand ? "true" : "false");
662 res.SetAttribute("Input", e.isInput ? "true" : "false");
663 }
664 else if (i == m_lineNumber - 1) // Last line for a new connection
665 {
666 res.SetAttribute("Prompt", m_expectingInput ? "true" : "false");
667 res.SetAttribute("Command", m_expectingCommand ? "true" : "false");
668 res.SetAttribute("Input", (!m_expectingInput) ? "true" : "false");
669 }
670 else
671 {
672 res.SetAttribute("Input", e.isInput ? "true" : "false");
673 }
674
675 res.AppendChild(xmldoc.CreateTextNode(e.text));
471 676
472 rootElement.AppendChild(res); 677 rootElement.AppendChild(res);
473 } 678 }
474 } 679 }
475 c.lastLineSeen = m_LineNumber; 680
681 c.lastLineSeen = m_lineNumber;
682 c.newConnection = false;
476 683
477 xmldoc.AppendChild(rootElement); 684 xmldoc.AppendChild(rootElement);
478 685
@@ -486,7 +693,9 @@ namespace OpenSim.Framework.Console
486 return result; 693 return result;
487 } 694 }
488 695
489 private Hashtable NoEvents(UUID RequestID, UUID id) 696 // This is really just a no-op. It generates what is sent
697 // to the client if the poll times out without any events.
698 protected Hashtable NoEvents(UUID RequestID, UUID id)
490 { 699 {
491 Hashtable result = new Hashtable(); 700 Hashtable result = new Hashtable();
492 701
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 48478b4..209c991 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -34,7 +34,7 @@ namespace OpenSim.Framework
34 // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not 34 // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not
35 // be the legacy region size. 35 // be the legacy region size.
36 public const uint RegionSize = 256; 36 public const uint RegionSize = 256;
37 public const uint RegionHeight = 16384; 37 public const uint RegionHeight = 4096;
38 // This could be a parameters but, really, a region of greater than this is pretty unmanageable 38 // This could be a parameters but, really, a region of greater than this is pretty unmanageable
39 public const uint MaximumRegionSize = 8192; 39 public const uint MaximumRegionSize = 8192;
40 40
@@ -46,12 +46,20 @@ namespace OpenSim.Framework
46 46
47 public enum EstateAccessCodex : uint 47 public enum EstateAccessCodex : uint
48 { 48 {
49 AccessOptions = 1, 49 AllowedAccess = 1,
50 AllowedGroups = 2, 50 AllowedGroups = 2,
51 EstateBans = 4, 51 EstateBans = 4,
52 EstateManagers = 8 52 EstateManagers = 8
53 } 53 }
54 54
55 public enum EstateAccessLimits : int
56 {
57 AllowedAccess = 500,
58 AllowedGroups = 63,
59 EstateBans = 500,
60 EstateManagers = 10
61 }
62
55 [Flags]public enum TeleportFlags : uint 63 [Flags]public enum TeleportFlags : uint
56 { 64 {
57 /// <summary>No flags set, or teleport failed</summary> 65 /// <summary>No flags set, or teleport failed</summary>
diff --git a/OpenSim/Framework/Crc32.cs b/OpenSim/Framework/Crc32.cs
new file mode 100644
index 0000000..7ad1566
--- /dev/null
+++ b/OpenSim/Framework/Crc32.cs
@@ -0,0 +1,139 @@
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.Security.Cryptography;
30
31namespace OpenSim.Framework
32{
33 // this is more generic than openmetaverse CRC32
34
35 public class Crc32 : HashAlgorithm
36 {
37 public const UInt32 DefaultPolynomial = 0xedb88320;
38 public const UInt32 DefaultSeed = 0xffffffff;
39
40 private UInt32 hash;
41 private UInt32 seed;
42 private UInt32[] table;
43 private static UInt32[] defaultTable;
44
45 public Crc32()
46 {
47 table = InitializeTable(DefaultPolynomial);
48 seed = DefaultSeed;
49 Initialize();
50 }
51
52 public Crc32(UInt32 polynomial, UInt32 seed)
53 {
54 table = InitializeTable(polynomial);
55 this.seed = seed;
56 Initialize();
57 }
58
59 public override void Initialize()
60 {
61 hash = seed;
62 }
63
64 protected override void HashCore(byte[] buffer, int start, int length)
65 {
66 hash = CalculateHash(table, hash, buffer, start, length);
67 }
68
69 protected override byte[] HashFinal()
70 {
71 byte[] hashBuffer = UInt32ToBigEndianBytes(~hash);
72 this.HashValue = hashBuffer;
73 return hashBuffer;
74 }
75
76 public override int HashSize
77 {
78 get { return 32; }
79 }
80
81 public static UInt32 Compute(byte[] buffer)
82 {
83 return ~CalculateHash(InitializeTable(DefaultPolynomial), DefaultSeed, buffer, 0, buffer.Length);
84 }
85
86 public static UInt32 Compute(UInt32 seed, byte[] buffer)
87 {
88 return ~CalculateHash(InitializeTable(DefaultPolynomial), seed, buffer, 0, buffer.Length);
89 }
90
91 public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer)
92 {
93 return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length);
94 }
95
96 private static UInt32[] InitializeTable(UInt32 polynomial)
97 {
98 if (polynomial == DefaultPolynomial && defaultTable != null)
99 return defaultTable;
100
101 UInt32[] createTable = new UInt32[256];
102 for (int i = 0; i < 256; i++)
103 {
104 UInt32 entry = (UInt32)i;
105 for (int j = 0; j < 8; j++)
106 if ((entry & 1) == 1)
107 entry = (entry >> 1) ^ polynomial;
108 else
109 entry = entry >> 1;
110 createTable[i] = entry;
111 }
112
113 if (polynomial == DefaultPolynomial)
114 defaultTable = createTable;
115
116 return createTable;
117 }
118
119 private static UInt32 CalculateHash(UInt32[] table, UInt32 seed, byte[] buffer, int start, int size)
120 {
121 UInt32 crc = seed;
122 for (int i = start; i < size; i++)
123 unchecked
124 {
125 crc = (crc >> 8) ^ table[buffer[i] ^ crc & 0xff];
126 }
127 return crc;
128 }
129
130 private byte[] UInt32ToBigEndianBytes(UInt32 x)
131 {
132 return new byte[] {
133 (byte)((x >> 24) & 0xff),
134 (byte)((x >> 16) & 0xff),
135 (byte)((x >> 8) & 0xff),
136 (byte)(x & 0xff) };
137 }
138 }
139}
diff --git a/OpenSim/Framework/CustomTypes.cs b/OpenSim/Framework/CustomTypes.cs
new file mode 100644
index 0000000..d109c26
--- /dev/null
+++ b/OpenSim/Framework/CustomTypes.cs
@@ -0,0 +1,43 @@
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;
29
30namespace OpenSim.Framework
31{
32 public enum CustomAssetType : sbyte
33 {
34 CustomTypeBase = 0x60,
35 AnimationSet = 0x60,
36 }
37
38 public enum CustomInventoryType : sbyte
39 {
40 CustomTypeBase = 0x60,
41 AnimationSet = 0x60,
42 }
43}
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs
index 4995a92..1915fa5 100644
--- a/OpenSim/Framework/DAMap.cs
+++ b/OpenSim/Framework/DAMap.cs
@@ -63,9 +63,9 @@ namespace OpenSim.Framework
63 { 63 {
64 get { return m_map; } 64 get { return m_map; }
65 set { m_map = value; } 65 set { m_map = value; }
66 } 66 }
67 67
68 public XmlSchema GetSchema() { return null; } 68 public XmlSchema GetSchema() { return null; }
69 69
70 public static DAMap FromXml(string rawXml) 70 public static DAMap FromXml(string rawXml)
71 { 71 {
@@ -73,19 +73,19 @@ namespace OpenSim.Framework
73 map.ReadXml(rawXml); 73 map.ReadXml(rawXml);
74 return map; 74 return map;
75 } 75 }
76 76
77 public void ReadXml(XmlReader reader) 77 public void ReadXml(XmlReader reader)
78 { 78 {
79 ReadXml(reader.ReadInnerXml()); 79 ReadXml(reader.ReadInnerXml());
80 } 80 }
81 81
82 public void ReadXml(string rawXml) 82 public void ReadXml(string rawXml)
83 { 83 {
84 // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); 84 // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
85 85
86 lock (this) 86 lock (this)
87 { 87 {
88 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); 88 m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
89 SanitiseMap(this); 89 SanitiseMap(this);
90 } 90 }
91 } 91 }
@@ -104,7 +104,7 @@ namespace OpenSim.Framework
104 public void CopyFrom(DAMap other) 104 public void CopyFrom(DAMap other)
105 { 105 {
106 // Deep copy 106 // Deep copy
107 107
108 string data = null; 108 string data = null;
109 lock (other) 109 lock (other)
110 { 110 {
@@ -113,7 +113,7 @@ namespace OpenSim.Framework
113 data = OSDParser.SerializeLLSDXmlString(other.m_map); 113 data = OSDParser.SerializeLLSDXmlString(other.m_map);
114 } 114 }
115 } 115 }
116 116
117 lock (this) 117 lock (this)
118 { 118 {
119 if (data == null) 119 if (data == null)
@@ -185,9 +185,9 @@ namespace OpenSim.Framework
185 /// <summary> 185 /// <summary>
186 /// Get the number of stores. 186 /// Get the number of stores.
187 /// </summary> 187 /// </summary>
188 public int CountStores 188 public int CountStores
189 { 189 {
190 get 190 get
191 { 191 {
192 int count = 0; 192 int count = 0;
193 193
@@ -263,8 +263,8 @@ namespace OpenSim.Framework
263 throw new Exception("Minimum namespace length is " + MIN_NAMESPACE_LENGTH); 263 throw new Exception("Minimum namespace length is " + MIN_NAMESPACE_LENGTH);
264 } 264 }
265 265
266 public bool ContainsStore(string ns, string storeName) 266 public bool ContainsStore(string ns, string storeName)
267 { 267 {
268 OSD namespaceOsd; 268 OSD namespaceOsd;
269 269
270 lock (this) 270 lock (this)
@@ -276,7 +276,7 @@ namespace OpenSim.Framework
276 } 276 }
277 277
278 return false; 278 return false;
279 } 279 }
280 280
281 public bool TryGetStore(string ns, string storeName, out OSDMap store) 281 public bool TryGetStore(string ns, string storeName, out OSDMap store)
282 { 282 {
@@ -297,17 +297,17 @@ namespace OpenSim.Framework
297 297
298 store = null; 298 store = null;
299 return false; 299 return false;
300 } 300 }
301 301
302 public void Clear() 302 public void Clear()
303 { 303 {
304 lock (this) 304 lock (this)
305 m_map.Clear(); 305 m_map.Clear();
306 } 306 }
307 307
308 public bool RemoveStore(string ns, string storeName) 308 public bool RemoveStore(string ns, string storeName)
309 { 309 {
310 OSD namespaceOsd; 310 OSD namespaceOsd;
311 311
312 lock (this) 312 lock (this)
313 { 313 {
@@ -323,6 +323,6 @@ namespace OpenSim.Framework
323 } 323 }
324 324
325 return false; 325 return false;
326 } 326 }
327 } 327 }
328} \ No newline at end of file 328} \ No newline at end of file
diff --git a/OpenSim/Framework/DOMap.cs b/OpenSim/Framework/DOMap.cs
index f5b650b..033cbf9 100644
--- a/OpenSim/Framework/DOMap.cs
+++ b/OpenSim/Framework/DOMap.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Framework
47 public class DOMap 47 public class DOMap
48 { 48 {
49 private IDictionary<string, object> m_map; 49 private IDictionary<string, object> m_map;
50 50
51 public void Add(string ns, string objName, object dynObj) 51 public void Add(string ns, string objName, object dynObj)
52 { 52 {
53 DAMap.ValidateNamespace(ns); 53 DAMap.ValidateNamespace(ns);
diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
index 9056548..816523b 100644
--- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
+++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs
@@ -55,6 +55,11 @@ namespace OpenSim.Framework
55 Dictionary2 = new Dictionary<TKey2, TValue>(capacity); 55 Dictionary2 = new Dictionary<TKey2, TValue>(capacity);
56 } 56 }
57 57
58 ~DoubleDictionaryThreadAbortSafe()
59 {
60 rwLock.Dispose();
61 }
62
58 public void Add(TKey1 key1, TKey2 key2, TValue value) 63 public void Add(TKey1 key1, TKey2 key2, TValue value)
59 { 64 {
60 bool gotLock = false; 65 bool gotLock = false;
@@ -64,31 +69,29 @@ namespace OpenSim.Framework
64 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 69 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
65 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 70 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
66 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 71 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
67 try {} 72 try {}
68 finally 73 finally
69 { 74 {
70 rwLock.EnterWriteLock(); 75 rwLock.EnterWriteLock();
71 gotLock = true; 76 gotLock = true;
77 if (Dictionary1.ContainsKey(key1))
78 {
79 if (!Dictionary2.ContainsKey(key2))
80 throw new ArgumentException("key1 exists in the dictionary but not key2");
81 }
82 else if (Dictionary2.ContainsKey(key2))
83 {
84 if (!Dictionary1.ContainsKey(key1))
85 throw new ArgumentException("key2 exists in the dictionary but not key1");
86 }
87 Dictionary1[key1] = value;
88 Dictionary2[key2] = value;
72 } 89 }
73
74 if (Dictionary1.ContainsKey(key1))
75 {
76 if (!Dictionary2.ContainsKey(key2))
77 throw new ArgumentException("key1 exists in the dictionary but not key2");
78 }
79 else if (Dictionary2.ContainsKey(key2))
80 {
81 if (!Dictionary1.ContainsKey(key1))
82 throw new ArgumentException("key2 exists in the dictionary but not key1");
83 }
84
85 Dictionary1[key1] = value;
86 Dictionary2[key2] = value;
87 } 90 }
88 finally 91 finally
89 { 92 {
90 if (gotLock) 93 if (gotLock)
91 rwLock.ExitWriteLock(); 94 rwLock.ExitWriteLock();
92 } 95 }
93 } 96 }
94 97
@@ -102,20 +105,19 @@ namespace OpenSim.Framework
102 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 105 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
103 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 106 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
104 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 107 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
105 try {} 108 try {}
106 finally 109 finally
107 { 110 {
108 rwLock.EnterWriteLock(); 111 rwLock.EnterWriteLock();
109 gotLock = true; 112 gotLock = true;
113 Dictionary1.Remove(key1);
114 success = Dictionary2.Remove(key2);
110 } 115 }
111
112 Dictionary1.Remove(key1);
113 success = Dictionary2.Remove(key2);
114 } 116 }
115 finally 117 finally
116 { 118 {
117 if (gotLock) 119 if (gotLock)
118 rwLock.ExitWriteLock(); 120 rwLock.ExitWriteLock();
119 } 121 }
120 122
121 return success; 123 return success;
@@ -131,7 +133,7 @@ namespace OpenSim.Framework
131 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 133 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
132 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 134 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
133 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 135 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
134 try {} 136 try {}
135 finally 137 finally
136 { 138 {
137 rwLock.EnterWriteLock(); 139 rwLock.EnterWriteLock();
@@ -146,18 +148,22 @@ namespace OpenSim.Framework
146 { 148 {
147 if (kvp.Value.Equals(value)) 149 if (kvp.Value.Equals(value))
148 { 150 {
149 Dictionary1.Remove(key1); 151 try { }
150 Dictionary2.Remove(kvp.Key); 152 finally
153 {
154 Dictionary1.Remove(key1);
155 Dictionary2.Remove(kvp.Key);
156 }
151 found = true; 157 found = true;
152 break; 158 break;
153 } 159 }
154 } 160 }
155 } 161 }
156 } 162 }
157 finally 163 finally
158 { 164 {
159 if (gotLock) 165 if (gotLock)
160 rwLock.ExitWriteLock(); 166 rwLock.ExitWriteLock();
161 } 167 }
162 168
163 return found; 169 return found;
@@ -173,7 +179,7 @@ namespace OpenSim.Framework
173 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 179 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
174 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 180 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
175 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 181 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
176 try {} 182 try {}
177 finally 183 finally
178 { 184 {
179 rwLock.EnterWriteLock(); 185 rwLock.EnterWriteLock();
@@ -188,18 +194,22 @@ namespace OpenSim.Framework
188 { 194 {
189 if (kvp.Value.Equals(value)) 195 if (kvp.Value.Equals(value))
190 { 196 {
191 Dictionary2.Remove(key2); 197 try { }
192 Dictionary1.Remove(kvp.Key); 198 finally
199 {
200 Dictionary2.Remove(key2);
201 Dictionary1.Remove(kvp.Key);
202 }
193 found = true; 203 found = true;
194 break; 204 break;
195 } 205 }
196 } 206 }
197 } 207 }
198 } 208 }
199 finally 209 finally
200 { 210 {
201 if (gotLock) 211 if (gotLock)
202 rwLock.ExitWriteLock(); 212 rwLock.ExitWriteLock();
203 } 213 }
204 214
205 return found; 215 return found;
@@ -214,20 +224,19 @@ namespace OpenSim.Framework
214 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 224 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
215 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 225 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
216 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 226 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
217 try {} 227 try {}
218 finally 228 finally
219 { 229 {
220 rwLock.EnterWriteLock(); 230 rwLock.EnterWriteLock();
221 gotLock = true; 231 gotLock = true;
232 Dictionary1.Clear();
233 Dictionary2.Clear();
222 } 234 }
223
224 Dictionary1.Clear();
225 Dictionary2.Clear();
226 } 235 }
227 finally 236 finally
228 { 237 {
229 if (gotLock) 238 if (gotLock)
230 rwLock.ExitWriteLock(); 239 rwLock.ExitWriteLock();
231 } 240 }
232 } 241 }
233 242
@@ -251,24 +260,24 @@ namespace OpenSim.Framework
251 bool success; 260 bool success;
252 bool gotLock = false; 261 bool gotLock = false;
253 262
254 try 263 try
255 { 264 {
256 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 265 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
257 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 266 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
258 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 267 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
259 try {} 268 try {}
260 finally 269 finally
261 { 270 {
262 rwLock.EnterReadLock(); 271 rwLock.EnterReadLock();
263 gotLock = true; 272 gotLock = true;
264 } 273 }
265 274
266 success = Dictionary1.TryGetValue(key, out value); 275 success = Dictionary1.TryGetValue(key, out value);
267 } 276 }
268 finally 277 finally
269 { 278 {
270 if (gotLock) 279 if (gotLock)
271 rwLock.ExitReadLock(); 280 rwLock.ExitReadLock();
272 } 281 }
273 282
274 return success; 283 return success;
@@ -279,24 +288,24 @@ namespace OpenSim.Framework
279 bool success; 288 bool success;
280 bool gotLock = false; 289 bool gotLock = false;
281 290
282 try 291 try
283 { 292 {
284 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 293 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
285 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 294 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
286 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 295 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
287 try {} 296 try {}
288 finally 297 finally
289 { 298 {
290 rwLock.EnterReadLock(); 299 rwLock.EnterReadLock();
291 gotLock = true; 300 gotLock = true;
292 } 301 }
293 302
294 success = Dictionary2.TryGetValue(key, out value); 303 success = Dictionary2.TryGetValue(key, out value);
295 } 304 }
296 finally 305 finally
297 { 306 {
298 if (gotLock) 307 if (gotLock)
299 rwLock.ExitReadLock(); 308 rwLock.ExitReadLock();
300 } 309 }
301 310
302 return success; 311 return success;
@@ -311,7 +320,7 @@ namespace OpenSim.Framework
311 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 320 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
312 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 321 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
313 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 322 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
314 try {} 323 try {}
315 finally 324 finally
316 { 325 {
317 rwLock.EnterReadLock(); 326 rwLock.EnterReadLock();
@@ -321,10 +330,10 @@ namespace OpenSim.Framework
321 foreach (TValue value in Dictionary1.Values) 330 foreach (TValue value in Dictionary1.Values)
322 action(value); 331 action(value);
323 } 332 }
324 finally 333 finally
325 { 334 {
326 if (gotLock) 335 if (gotLock)
327 rwLock.ExitReadLock(); 336 rwLock.ExitReadLock();
328 } 337 }
329 } 338 }
330 339
@@ -337,7 +346,7 @@ namespace OpenSim.Framework
337 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 346 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
338 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 347 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
339 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 348 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
340 try {} 349 try {}
341 finally 350 finally
342 { 351 {
343 rwLock.EnterReadLock(); 352 rwLock.EnterReadLock();
@@ -347,10 +356,10 @@ namespace OpenSim.Framework
347 foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1) 356 foreach (KeyValuePair<TKey1, TValue> entry in Dictionary1)
348 action(entry); 357 action(entry);
349 } 358 }
350 finally 359 finally
351 { 360 {
352 if (gotLock) 361 if (gotLock)
353 rwLock.ExitReadLock(); 362 rwLock.ExitReadLock();
354 } 363 }
355 } 364 }
356 365
@@ -363,7 +372,7 @@ namespace OpenSim.Framework
363 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 372 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
364 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 373 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
365 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 374 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
366 try {} 375 try {}
367 finally 376 finally
368 { 377 {
369 rwLock.EnterReadLock(); 378 rwLock.EnterReadLock();
@@ -373,10 +382,10 @@ namespace OpenSim.Framework
373 foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2) 382 foreach (KeyValuePair<TKey2, TValue> entry in Dictionary2)
374 action(entry); 383 action(entry);
375 } 384 }
376 finally 385 finally
377 { 386 {
378 if (gotLock) 387 if (gotLock)
379 rwLock.ExitReadLock(); 388 rwLock.ExitReadLock();
380 } 389 }
381 } 390 }
382 391
@@ -389,7 +398,7 @@ namespace OpenSim.Framework
389 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 398 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
390 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 399 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
391 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 400 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
392 try {} 401 try {}
393 finally 402 finally
394 { 403 {
395 rwLock.EnterReadLock(); 404 rwLock.EnterReadLock();
@@ -402,10 +411,10 @@ namespace OpenSim.Framework
402 return value; 411 return value;
403 } 412 }
404 } 413 }
405 finally 414 finally
406 { 415 {
407 if (gotLock) 416 if (gotLock)
408 rwLock.ExitReadLock(); 417 rwLock.ExitReadLock();
409 } 418 }
410 419
411 return default(TValue); 420 return default(TValue);
@@ -421,7 +430,7 @@ namespace OpenSim.Framework
421 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 430 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
422 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 431 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
423 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 432 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
424 try {} 433 try {}
425 finally 434 finally
426 { 435 {
427 rwLock.EnterReadLock(); 436 rwLock.EnterReadLock();
@@ -434,10 +443,10 @@ namespace OpenSim.Framework
434 list.Add(value); 443 list.Add(value);
435 } 444 }
436 } 445 }
437 finally 446 finally
438 { 447 {
439 if (gotLock) 448 if (gotLock)
440 rwLock.ExitReadLock(); 449 rwLock.ExitReadLock();
441 } 450 }
442 451
443 return list; 452 return list;
@@ -453,7 +462,7 @@ namespace OpenSim.Framework
453 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing 462 // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing
454 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot 463 // the acquision inside the main try. The inner finally block is needed because thread aborts cannot
455 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). 464 // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly).
456 try {} 465 try {}
457 finally 466 finally
458 { 467 {
459 rwLock.EnterUpgradeableReadLock(); 468 rwLock.EnterUpgradeableReadLock();
@@ -477,29 +486,29 @@ namespace OpenSim.Framework
477 486
478 try 487 try
479 { 488 {
480 try {} 489 try {}
481 finally 490 finally
482 { 491 {
483 rwLock.EnterUpgradeableReadLock(); 492 rwLock.EnterWriteLock();
484 gotWriteLock = true; 493 gotWriteLock = true;
485 }
486 494
487 for (int i = 0; i < list.Count; i++) 495 for (int i = 0; i < list.Count; i++)
488 Dictionary1.Remove(list[i]); 496 Dictionary1.Remove(list[i]);
489 497
490 for (int i = 0; i < list2.Count; i++) 498 for (int i = 0; i < list2.Count; i++)
491 Dictionary2.Remove(list2[i]); 499 Dictionary2.Remove(list2[i]);
500 }
492 } 501 }
493 finally 502 finally
494 { 503 {
495 if (gotWriteLock) 504 if (gotWriteLock)
496 rwLock.ExitWriteLock(); 505 rwLock.ExitWriteLock();
497 } 506 }
498 } 507 }
499 finally 508 finally
500 { 509 {
501 if (gotUpgradeableLock) 510 if (gotUpgradeableLock)
502 rwLock.ExitUpgradeableReadLock(); 511 rwLock.ExitUpgradeableReadLock();
503 } 512 }
504 513
505 return list.Count; 514 return list.Count;
diff --git a/OpenSim/Framework/EntityTransferContext.cs b/OpenSim/Framework/EntityTransferContext.cs
new file mode 100644
index 0000000..860414e
--- /dev/null
+++ b/OpenSim/Framework/EntityTransferContext.cs
@@ -0,0 +1,70 @@
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 OpenMetaverse;
31using OpenMetaverse.StructuredData;
32
33namespace OpenSim.Framework
34{
35 public class EntityTransferContext
36 {
37 public EntityTransferContext()
38 {
39 InboundVersion = VersionInfo.SimulationServiceVersionAcceptedMax;
40 OutboundVersion = VersionInfo.SimulationServiceVersionSupportedMax;
41 WearablesCount = -1;
42 }
43
44 public float InboundVersion { get; set; }
45 public float OutboundVersion { get; set; }
46 public int WearablesCount { get; set; }
47
48 public OSD Pack()
49 {
50 OSDMap data = new OSDMap();
51 data["InboundVersion"] = OSD.FromReal(InboundVersion);
52 data["OutboundVersion"] = OSD.FromReal(OutboundVersion);
53 data["WearablesCount"] = OSD.FromInteger(WearablesCount);
54
55 return data;
56 }
57
58 public void Unpack(OSD data)
59 {
60 OSDMap map = (OSDMap)data;
61
62 if (map.ContainsKey("InboundVersion"))
63 InboundVersion = (float)map["InboundVersion"].AsReal();
64 if (map.ContainsKey("OutboundVersion"))
65 OutboundVersion = (float)map["OutboundVersion"].AsReal();
66 if (map.ContainsKey("WearablesCount"))
67 WearablesCount = map["WearablesCount"].AsInteger();
68 }
69 }
70}
diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs
index ebed794..12a92bb 100644
--- a/OpenSim/Framework/EstateBan.cs
+++ b/OpenSim/Framework/EstateBan.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework
43 { 43 {
44 get 44 get
45 { 45 {
46 return m_estateID; 46 return m_estateID;
47 } 47 }
48 set 48 set
49 { 49 {
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index 4df7860..8c8270a 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -305,11 +305,17 @@ namespace OpenSim.Framework
305 OnSave(this); 305 OnSave(this);
306 } 306 }
307 307
308 public int EstateUsersCount()
309 {
310 return l_EstateAccess.Count;
311 }
312
308 public void AddEstateUser(UUID avatarID) 313 public void AddEstateUser(UUID avatarID)
309 { 314 {
310 if (avatarID == UUID.Zero) 315 if (avatarID == UUID.Zero)
311 return; 316 return;
312 if (!l_EstateAccess.Contains(avatarID)) 317 if (!l_EstateAccess.Contains(avatarID) &&
318 (l_EstateAccess.Count < (int)Constants.EstateAccessLimits.AllowedAccess))
313 l_EstateAccess.Add(avatarID); 319 l_EstateAccess.Add(avatarID);
314 } 320 }
315 321
@@ -319,11 +325,17 @@ namespace OpenSim.Framework
319 l_EstateAccess.Remove(avatarID); 325 l_EstateAccess.Remove(avatarID);
320 } 326 }
321 327
328 public int EstateGroupsCount()
329 {
330 return l_EstateGroups.Count;
331 }
332
322 public void AddEstateGroup(UUID avatarID) 333 public void AddEstateGroup(UUID avatarID)
323 { 334 {
324 if (avatarID == UUID.Zero) 335 if (avatarID == UUID.Zero)
325 return; 336 return;
326 if (!l_EstateGroups.Contains(avatarID)) 337 if (!l_EstateGroups.Contains(avatarID) &&
338 (l_EstateGroups.Count < (int)Constants.EstateAccessLimits.AllowedGroups))
327 l_EstateGroups.Add(avatarID); 339 l_EstateGroups.Add(avatarID);
328 } 340 }
329 341
@@ -333,11 +345,17 @@ namespace OpenSim.Framework
333 l_EstateGroups.Remove(avatarID); 345 l_EstateGroups.Remove(avatarID);
334 } 346 }
335 347
348 public int EstateManagersCount()
349 {
350 return l_EstateManagers.Count;
351 }
352
336 public void AddEstateManager(UUID avatarID) 353 public void AddEstateManager(UUID avatarID)
337 { 354 {
338 if (avatarID == UUID.Zero) 355 if (avatarID == UUID.Zero)
339 return; 356 return;
340 if (!l_EstateManagers.Contains(avatarID)) 357 if (!l_EstateManagers.Contains(avatarID) &&
358 (l_EstateManagers.Count < (int)Constants.EstateAccessLimits.EstateManagers))
341 l_EstateManagers.Add(avatarID); 359 l_EstateManagers.Add(avatarID);
342 } 360 }
343 361
@@ -365,17 +383,55 @@ namespace OpenSim.Framework
365 383
366 public bool IsBanned(UUID avatarID) 384 public bool IsBanned(UUID avatarID)
367 { 385 {
368 foreach (EstateBan ban in l_EstateBans) 386 if (!IsEstateManagerOrOwner(avatarID))
387 {
388 foreach (EstateBan ban in l_EstateBans)
389 if (ban.BannedUserID == avatarID)
390 return true;
391 }
392 return false;
393 }
394
395 public bool IsBanned(UUID avatarID, int userFlags)
396 {
397 if (!IsEstateManagerOrOwner(avatarID))
398 {
399 foreach (EstateBan ban in l_EstateBans)
369 if (ban.BannedUserID == avatarID) 400 if (ban.BannedUserID == avatarID)
370 return true; 401 return true;
402
403 if (!HasAccess(avatarID))
404 {
405 if (DenyMinors)
406 {
407 if ((userFlags & 32) == 0)
408 {
409 return true;
410 }
411 }
412 if (DenyAnonymous)
413 {
414 if ((userFlags & 4) == 0)
415 {
416 return true;
417 }
418 }
419 }
420 }
371 return false; 421 return false;
372 } 422 }
373 423
424 public int EstateBansCount()
425 {
426 return l_EstateBans.Count;
427 }
428
374 public void AddBan(EstateBan ban) 429 public void AddBan(EstateBan ban)
375 { 430 {
376 if (ban == null) 431 if (ban == null)
377 return; 432 return;
378 if (!IsBanned(ban.BannedUserID)) 433 if (!IsBanned(ban.BannedUserID, 32) &&
434 (l_EstateBans.Count < (int)Constants.EstateAccessLimits.EstateBans)) //Ignore age-based bans
379 l_EstateBans.Add(ban); 435 l_EstateBans.Add(ban);
380 } 436 }
381 437
@@ -516,14 +572,41 @@ namespace OpenSim.Framework
516 572
517 // EstateBans are special 573 // EstateBans are special
518 if (map.ContainsKey("EstateBans")) 574 if (map.ContainsKey("EstateBans"))
519 { 575 {
520 var banData = ((Dictionary<string, object>)map["EstateBans"]).Values; 576 if(map["EstateBans"] is string)
521 EstateBan[] bans = new EstateBan[banData.Count]; 577 {
522 int b = 0; 578 // JSON encoded bans map
523 foreach (Dictionary<string, object> ban in banData) 579 Dictionary<string, EstateBan> bdata = new Dictionary<string, EstateBan>();
524 bans[b++] = new EstateBan(ban); 580 try
525 PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); 581 {
526 bansProperty.SetValue(this, bans, null); 582 // bypass libovm, we dont need even more useless high level maps
583 // this should only be called once.. but no problem, i hope
584 // (other uses may need more..)
585 LitJson.JsonMapper.RegisterImporter<string, UUID>((input) => new UUID(input));
586 bdata = LitJson.JsonMapper.ToObject<Dictionary<string,EstateBan>>((string)map["EstateBans"]);
587 }
588 // catch(Exception e)
589 catch
590 {
591 return;
592 }
593 EstateBan[] jbans = new EstateBan[bdata.Count];
594 bdata.Values.CopyTo(jbans,0);
595
596 PropertyInfo jbansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
597 jbansProperty.SetValue(this, jbans, null);
598 }
599 else
600 {
601 var banData = ((Dictionary<string, object>)map["EstateBans"]).Values;
602 EstateBan[] bans = new EstateBan[banData.Count];
603
604 int b = 0;
605 foreach (Dictionary<string, object> ban in banData)
606 bans[b++] = new EstateBan(ban);
607 PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance);
608 bansProperty.SetValue(this, bans, null);
609 }
527 } 610 }
528 } 611 }
529 } 612 }
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs
index da3690c..1605005 100644
--- a/OpenSim/Framework/GridInstantMessage.cs
+++ b/OpenSim/Framework/GridInstantMessage.cs
@@ -66,6 +66,7 @@ namespace OpenSim.Framework
66 Position = im.Position; 66 Position = im.Position;
67 binaryBucket = im.binaryBucket; 67 binaryBucket = im.binaryBucket;
68 RegionID = im.RegionID; 68 RegionID = im.RegionID;
69 ParentEstateID = im.ParentEstateID;
69 70
70 if (addTimestamp) 71 if (addTimestamp)
71 timestamp = (uint)Util.UnixTimeSinceEpoch(); 72 timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -84,6 +85,7 @@ namespace OpenSim.Framework
84 fromGroup = _fromGroup; 85 fromGroup = _fromGroup;
85 message = _message; 86 message = _message;
86 imSessionID = _imSessionID.Guid; 87 imSessionID = _imSessionID.Guid;
88
87 if (_offline) 89 if (_offline)
88 offline = 1; 90 offline = 1;
89 else 91 else
diff --git a/OpenSim/Framework/IImprovedAssetCache.cs b/OpenSim/Framework/IAssetCache.cs
index a853e90..2df9199 100644
--- a/OpenSim/Framework/IImprovedAssetCache.cs
+++ b/OpenSim/Framework/IAssetCache.cs
@@ -29,7 +29,7 @@ using OpenSim.Framework;
29 29
30namespace OpenSim.Framework 30namespace OpenSim.Framework
31{ 31{
32 public interface IImprovedAssetCache 32 public interface IAssetCache
33 { 33 {
34 /// <summary> 34 /// <summary>
35 /// Cache the specified asset. 35 /// Cache the specified asset.
@@ -38,11 +38,18 @@ namespace OpenSim.Framework
38 void Cache(AssetBase asset); 38 void Cache(AssetBase asset);
39 39
40 /// <summary> 40 /// <summary>
41 /// Cache that the specified asset wasn't found.
42 /// </summary>
43 /// <param name='id'></param>
44 /// <summary>
45 void CacheNegative(string id);
46
41 /// Get an asset by its id. 47 /// Get an asset by its id.
42 /// </summary> 48 /// </summary>
43 /// <param name='id'></param> 49 /// <param name='id'></param>
44 /// <returns>null if the asset does not exist.</returns> 50 /// <param name='asset'>Will be set to null if no asset was found</param>
45 AssetBase Get(string id); 51 /// <returns>False if the asset has been negative-cached</returns>
52 bool Get(string id, out AssetBase asset);
46 53
47 /// <summary> 54 /// <summary>
48 /// Check whether an asset with the specified id exists in the cache. 55 /// Check whether an asset with the specified id exists in the cache.
@@ -61,4 +68,4 @@ namespace OpenSim.Framework
61 /// </summary> 68 /// </summary>
62 void Clear(); 69 void Clear();
63 } 70 }
64} \ No newline at end of file 71}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index e36edb2..a9044d5 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -47,10 +47,12 @@ namespace OpenSim.Framework
47 47
48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im); 48 public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
49 49
50 public delegate void RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, 50 public delegate void RezObject(IClientAPI remoteClient, UUID itemID, UUID GroupID,
51 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 51 Vector3 RayEnd, Vector3 RayStart,
52 bool RezSelected, bool RemoveItem, UUID fromTaskID); 52 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
53 bool RezSelected, bool RemoveItem, UUID fromTaskID);
53 54
55 public delegate void RezRestoreToWorld(IClientAPI remoteClient, UUID itemId);
54 public delegate ISceneEntity RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); 56 public delegate ISceneEntity RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
55 57
56 public delegate void RezMultipleAttachmentsFromInv(IClientAPI remoteClient, List<KeyValuePair<UUID, uint>> rezlist ); 58 public delegate void RezMultipleAttachmentsFromInv(IClientAPI remoteClient, List<KeyValuePair<UUID, uint>> rezlist );
@@ -58,20 +60,21 @@ namespace OpenSim.Framework
58 public delegate void ObjectAttach( 60 public delegate void ObjectAttach(
59 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); 61 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent);
60 62
61 public delegate void ModifyTerrain(UUID user, 63 public delegate void ModifyTerrain(UUID user,
62 float height, float seconds, byte size, byte action, float north, float west, float south, float east, 64 float height, float seconds, byte size, byte action, float north, float west, float south, float east,
63 UUID agentId); 65 UUID agentId);
64 66
65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 67 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
66 68
67 public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest);
68
69 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems); 69 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems);
70 public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest);
70 71
71 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 72 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
72 73
73 public delegate void StopAnim(IClientAPI remoteClient, UUID animID); 74 public delegate void StopAnim(IClientAPI remoteClient, UUID animID);
74 75
76 public delegate void ChangeAnim(UUID animID, bool addOrRemove, bool sendPack);
77
75 public delegate void LinkObjects(IClientAPI remoteClient, uint parent, List<uint> children); 78 public delegate void LinkObjects(IClientAPI remoteClient, uint parent, List<uint> children);
76 79
77 public delegate void DelinkObjects(List<uint> primIds, IClientAPI client); 80 public delegate void DelinkObjects(List<uint> primIds, IClientAPI client);
@@ -104,7 +107,7 @@ namespace OpenSim.Framework
104 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient); 107 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
105 108
106 public delegate void DeRezObject( 109 public delegate void DeRezObject(
107 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID); 110 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID, bool AddToReturns = true);
108 111
109 public delegate void GenericCall5(IClientAPI remoteClient, bool status); 112 public delegate void GenericCall5(IClientAPI remoteClient, bool status);
110 113
@@ -114,7 +117,7 @@ namespace OpenSim.Framework
114 117
115 public delegate void ObjectExtraParams(UUID agentID, uint localID, ushort type, bool inUse, byte[] data); 118 public delegate void ObjectExtraParams(UUID agentID, uint localID, ushort type, bool inUse, byte[] data);
116 119
117 public delegate void ObjectSelect(uint localID, IClientAPI remoteClient); 120 public delegate void ObjectSelect(List<uint> localID, IClientAPI remoteClient);
118 121
119 public delegate void ObjectRequest(uint localID, IClientAPI remoteClient); 122 public delegate void ObjectRequest(uint localID, IClientAPI remoteClient);
120 123
@@ -132,6 +135,8 @@ namespace OpenSim.Framework
132 135
133 public delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient); 136 public delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient);
134 137
138 public delegate void ClientChangeObject(uint localID, object data ,IClientAPI remoteClient);
139
135 public delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient); 140 public delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient);
136 141
137 public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient); 142 public delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient);
@@ -222,10 +227,10 @@ namespace OpenSim.Framework
222 byte RayEndIsIntersection); 227 byte RayEndIsIntersection);
223 228
224 public delegate void RequestGodlikePowers( 229 public delegate void RequestGodlikePowers(
225 UUID AgentID, UUID SessionID, UUID token, bool GodLike, IClientAPI remote_client); 230 UUID AgentID, UUID SessionID, UUID token, bool GodLike);
226 231
227 public delegate void GodKickUser( 232 public delegate void GodKickUser(
228 UUID GodAgentID, UUID GodSessionID, UUID AgentID, uint kickflags, byte[] reason); 233 UUID GodAgentID, UUID AgentID, uint kickflags, byte[] reason);
229 234
230 public delegate void CreateInventoryFolder( 235 public delegate void CreateInventoryFolder(
231 IClientAPI remoteClient, UUID folderID, ushort folderType, string folderName, UUID parentID); 236 IClientAPI remoteClient, UUID folderID, ushort folderType, string folderName, UUID parentID);
@@ -238,7 +243,7 @@ namespace OpenSim.Framework
238 243
239 public delegate void CreateNewInventoryItem( 244 public delegate void CreateNewInventoryItem(
240 IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, 245 IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name,
241 sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask, int creationDate); 246 sbyte invType, sbyte type, byte wearableType, uint everyoneMask, int creationDate);
242 247
243 public delegate void LinkInventoryItem( 248 public delegate void LinkInventoryItem(
244 IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, 249 IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name,
@@ -268,6 +273,9 @@ namespace OpenSim.Framework
268 public delegate void MoveInventoryItem( 273 public delegate void MoveInventoryItem(
269 IClientAPI remoteClient, List<InventoryItemBase> items); 274 IClientAPI remoteClient, List<InventoryItemBase> items);
270 275
276 public delegate void MoveItemsAndLeaveCopy(
277 IClientAPI remoteClient, List<InventoryItemBase> items, UUID destFolder);
278
271 public delegate void RemoveInventoryItem( 279 public delegate void RemoveInventoryItem(
272 IClientAPI remoteClient, List<UUID> itemIDs); 280 IClientAPI remoteClient, List<UUID> itemIDs);
273 281
@@ -443,6 +451,7 @@ namespace OpenSim.Framework
443 public delegate void ClassifiedInfoRequest(UUID classifiedID, IClientAPI client); 451 public delegate void ClassifiedInfoRequest(UUID classifiedID, IClientAPI client);
444 public delegate void ClassifiedInfoUpdate(UUID classifiedID, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price, IClientAPI client); 452 public delegate void ClassifiedInfoUpdate(UUID classifiedID, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price, IClientAPI client);
445 public delegate void ClassifiedDelete(UUID classifiedID, IClientAPI client); 453 public delegate void ClassifiedDelete(UUID classifiedID, IClientAPI client);
454 public delegate void ClassifiedGodDelete(UUID classifiedID, UUID queryID, IClientAPI client);
446 455
447 public delegate void EventNotificationAddRequest(uint EventID, IClientAPI client); 456 public delegate void EventNotificationAddRequest(uint EventID, IClientAPI client);
448 public delegate void EventNotificationRemoveRequest(uint EventID, IClientAPI client); 457 public delegate void EventNotificationRemoveRequest(uint EventID, IClientAPI client);
@@ -464,47 +473,48 @@ namespace OpenSim.Framework
464 public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client); 473 public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client);
465 474
466 public delegate void AgentFOV(IClientAPI client, float verticalAngle); 475 public delegate void AgentFOV(IClientAPI client, float verticalAngle);
467 476
468 public delegate void MuteListEntryUpdate(IClientAPI client, UUID MuteID, string Name, int Flags,UUID AgentID); 477 public delegate void MuteListEntryUpdate(IClientAPI client, UUID MuteID, string Name, int type, uint flags);
469 478
470 public delegate void MuteListEntryRemove(IClientAPI client, UUID MuteID, string Name, UUID AgentID); 479 public delegate void MuteListEntryRemove(IClientAPI client, UUID MuteID, string Name);
471 480
472 public delegate void AvatarInterestReply(IClientAPI client,UUID target, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages); 481 public delegate void AvatarInterestReply(IClientAPI client,UUID target, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages);
473 482
474 public delegate void FindAgentUpdate(IClientAPI client, UUID hunter, UUID target); 483 public delegate void FindAgentUpdate(IClientAPI client, UUID hunter, UUID target);
475 484
476 public delegate void TrackAgentUpdate(IClientAPI client, UUID hunter, UUID target); 485 public delegate void TrackAgentUpdate(IClientAPI client, UUID hunter, UUID target);
477 486
478 public delegate void FreezeUserUpdate(IClientAPI client, UUID parcelowner,uint flags, UUID target); 487 public delegate void FreezeUserUpdate(IClientAPI client, UUID parcelowner,uint flags, UUID target);
479 488
480 public delegate void EjectUserUpdate(IClientAPI client, UUID parcelowner,uint flags, UUID target); 489 public delegate void EjectUserUpdate(IClientAPI client, UUID parcelowner,uint flags, UUID target);
481 490
482 public delegate void NewUserReport(IClientAPI client, string regionName,UUID abuserID, byte catagory, byte checkflags, string details, UUID objectID, Vector3 postion, byte reportType ,UUID screenshotID, string Summary, UUID reporter); 491 public delegate void NewUserReport(IClientAPI client, string regionName,UUID abuserID, byte catagory, byte checkflags, string details, UUID objectID, Vector3 postion, byte reportType ,UUID screenshotID, string Summary, UUID reporter);
483 492
484 public delegate void GodUpdateRegionInfoUpdate(IClientAPI client, float BillableFactor, ulong EstateID, ulong RegionFlags, byte[] SimName,int RedirectX, int RedirectY); 493 public delegate void GodUpdateRegionInfoUpdate(IClientAPI client, float BillableFactor, ulong EstateID, ulong RegionFlags, byte[] SimName,int RedirectX, int RedirectY);
485 494
486 public delegate void GodlikeMessage(IClientAPI client, UUID requester, byte[] Method, byte[] Parameter); 495 public delegate void GodlikeMessage(IClientAPI client, UUID requester, byte[] Method, byte[] Parameter);
487 496
488 public delegate void SaveStateHandler(IClientAPI client,UUID agentID); 497 public delegate void SaveStateHandler(IClientAPI client,UUID agentID);
489 498
490 public delegate void GroupAccountSummaryRequest(IClientAPI client,UUID agentID, UUID groupID); 499 public delegate void GroupAccountSummaryRequest(IClientAPI client,UUID agentID, UUID groupID);
491 500
492 public delegate void GroupAccountDetailsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID); 501 public delegate void GroupAccountDetailsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID);
493 502
494 public delegate void GroupAccountTransactionsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID); 503 public delegate void GroupAccountTransactionsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID);
495 504
496 public delegate void ParcelBuyPass(IClientAPI client, UUID agentID, int ParcelLocalID); 505 public delegate void ParcelBuyPass(IClientAPI client, UUID agentID, int ParcelLocalID);
497 506
498 public delegate void ParcelGodMark(IClientAPI client, UUID agentID, int ParcelLocalID); 507 public delegate void ParcelGodMark(IClientAPI client, UUID agentID, int ParcelLocalID);
499 508
500 public delegate void GroupActiveProposalsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID); 509 public delegate void GroupActiveProposalsRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID);
501 510
502 public delegate void GroupVoteHistoryRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID); 511 public delegate void GroupVoteHistoryRequest(IClientAPI client,UUID agentID, UUID groupID, UUID transactionID, UUID sessionID);
503 512
504 513
505 public delegate void SimWideDeletesDelegate(IClientAPI client,UUID agentID, int flags, UUID targetID); 514 public delegate void SimWideDeletesDelegate(IClientAPI client,UUID agentID, int flags, UUID targetID);
506 515
507 public delegate void SendPostcard(IClientAPI client); 516 public delegate void SendPostcard(IClientAPI client);
517 public delegate void ChangeInventoryItemFlags(IClientAPI client, UUID itemID, uint flags);
508 518
509 #endregion 519 #endregion
510 520
@@ -575,10 +585,10 @@ namespace OpenSim.Framework
575 public float dwell; 585 public float dwell;
576 } 586 }
577 587
578 public class IEntityUpdate 588 public class EntityUpdate
579 { 589 {
580 private ISceneEntity m_entity; 590 private ISceneEntity m_entity;
581 private uint m_flags; 591 private PrimUpdateFlags m_flags;
582 private int m_updateTime; 592 private int m_updateTime;
583 593
584 public ISceneEntity Entity 594 public ISceneEntity Entity
@@ -586,7 +596,7 @@ namespace OpenSim.Framework
586 get { return m_entity; } 596 get { return m_entity; }
587 } 597 }
588 598
589 public uint Flags 599 public PrimUpdateFlags Flags
590 { 600 {
591 get { return m_flags; } 601 get { return m_flags; }
592 } 602 }
@@ -596,23 +606,30 @@ namespace OpenSim.Framework
596 get { return m_updateTime; } 606 get { return m_updateTime; }
597 } 607 }
598 608
599 public virtual void Update(IEntityUpdate update) 609 public virtual void Update(EntityUpdate oldupdate)
600 { 610 {
601 m_flags |= update.Flags; 611 // we are on the new one
612 PrimUpdateFlags updateFlags = oldupdate.Flags;
613 if(m_flags.HasFlag(PrimUpdateFlags.CancelKill))
614 m_flags = PrimUpdateFlags.FullUpdate;
615 else if(updateFlags.HasFlag(PrimUpdateFlags.Kill))
616 return;
617 else // kill case will just merge in
618 m_flags |= updateFlags;
602 619
603 // Use the older of the updates as the updateTime 620 // Use the older of the updates as the updateTime
604 if (Util.EnvironmentTickCountCompare(UpdateTime, update.UpdateTime) > 0) 621 if (Util.EnvironmentTickCountCompare(UpdateTime, oldupdate.UpdateTime) > 0)
605 m_updateTime = update.UpdateTime; 622 m_updateTime = oldupdate.UpdateTime;
606 } 623 }
607 624
608 public IEntityUpdate(ISceneEntity entity, uint flags) 625 public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags)
609 { 626 {
610 m_entity = entity; 627 m_entity = entity;
611 m_flags = flags; 628 m_flags = flags;
612 m_updateTime = Util.EnvironmentTickCount(); 629 m_updateTime = Util.EnvironmentTickCount();
613 } 630 }
614 631
615 public IEntityUpdate(ISceneEntity entity, uint flags, Int32 updateTime) 632 public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, Int32 updateTime)
616 { 633 {
617 m_entity = entity; 634 m_entity = entity;
618 m_flags = flags; 635 m_flags = flags;
@@ -620,29 +637,6 @@ namespace OpenSim.Framework
620 } 637 }
621 } 638 }
622 639
623 public class EntityUpdate : IEntityUpdate
624 {
625 private float m_timeDilation;
626
627 public float TimeDilation
628 {
629 get { return m_timeDilation; }
630 }
631
632 public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, float timedilation)
633 : base(entity, (uint)flags)
634 {
635 // Flags = flags;
636 m_timeDilation = timedilation;
637 }
638
639 public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, float timedilation, Int32 updateTime)
640 : base(entity,(uint)flags,updateTime)
641 {
642 m_timeDilation = timedilation;
643 }
644 }
645
646 public class PlacesReplyData 640 public class PlacesReplyData
647 { 641 {
648 public UUID OwnerID; 642 public UUID OwnerID;
@@ -691,9 +685,13 @@ namespace OpenSim.Framework
691 ExtraData = 1 << 20, 685 ExtraData = 1 << 20,
692 Sound = 1 << 21, 686 Sound = 1 << 21,
693 Joint = 1 << 22, 687 Joint = 1 << 22,
694 FullUpdate = UInt32.MaxValue 688 FullUpdate = 0x0fffffff,
689 SendInTransit = 0x20000000,
690 CancelKill = 0x4fffffff, // 1 << 30
691 Kill = 0x80000000 // 1 << 31
695 } 692 }
696 693
694/* included in .net 4.0
697 public static class PrimUpdateFlagsExtensions 695 public static class PrimUpdateFlagsExtensions
698 { 696 {
699 public static bool HasFlag(this PrimUpdateFlags updateFlags, PrimUpdateFlags flag) 697 public static bool HasFlag(this PrimUpdateFlags updateFlags, PrimUpdateFlags flag)
@@ -701,7 +699,7 @@ namespace OpenSim.Framework
701 return (updateFlags & flag) == flag; 699 return (updateFlags & flag) == flag;
702 } 700 }
703 } 701 }
704 702*/
705 public interface IClientAPI 703 public interface IClientAPI
706 { 704 {
707 Vector3 StartPos { get; set; } 705 Vector3 StartPos { get; set; }
@@ -718,11 +716,15 @@ namespace OpenSim.Framework
718 716
719 UUID SecureSessionId { get; } 717 UUID SecureSessionId { get; }
720 718
721 UUID ActiveGroupId { get; } 719 UUID ActiveGroupId { get; set; }
720
721 string ActiveGroupName { get; set;}
722 722
723 string ActiveGroupName { get; } 723 ulong ActiveGroupPowers { get; set;}
724 724
725 ulong ActiveGroupPowers { get; } 725 Dictionary<UUID, ulong> GetGroupPowers();
726
727 void SetGroupPowers(Dictionary<UUID, ulong> powers);
726 728
727 ulong GetGroupPowers(UUID groupID); 729 ulong GetGroupPowers(UUID groupID);
728 730
@@ -734,6 +736,8 @@ namespace OpenSim.Framework
734 736
735 IScene Scene { get; } 737 IScene Scene { get; }
736 738
739 List<uint> SelectedObjects { get; }
740
737 // [Obsolete("LLClientView Specific - Replace with ???")] 741 // [Obsolete("LLClientView Specific - Replace with ???")]
738 int NextAnimationSequenceNumber { get; } 742 int NextAnimationSequenceNumber { get; }
739 743
@@ -747,6 +751,8 @@ namespace OpenSim.Framework
747 /// </summary> 751 /// </summary>
748 bool IsActive { get; set; } 752 bool IsActive { get; set; }
749 753
754 int PingTimeMS { get; }
755
750 /// <summary> 756 /// <summary>
751 /// Set if the client is closing due to a logout request 757 /// Set if the client is closing due to a logout request
752 /// </summary> 758 /// </summary>
@@ -758,7 +764,7 @@ namespace OpenSim.Framework
758 /// Only set for root agents. 764 /// Only set for root agents.
759 /// </remarks> 765 /// </remarks>
760 bool IsLoggingOut { get; set; } 766 bool IsLoggingOut { get; set; }
761 767
762 bool SendLogoutPacketWhenClosing { set; } 768 bool SendLogoutPacketWhenClosing { set; }
763 769
764 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] 770 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")]
@@ -794,6 +800,7 @@ namespace OpenSim.Framework
794 event ObjectDrop OnObjectDrop; 800 event ObjectDrop OnObjectDrop;
795 event StartAnim OnStartAnim; 801 event StartAnim OnStartAnim;
796 event StopAnim OnStopAnim; 802 event StopAnim OnStopAnim;
803 event ChangeAnim OnChangeAnim;
797 event LinkObjects OnLinkObjects; 804 event LinkObjects OnLinkObjects;
798 event DelinkObjects OnDelinkObjects; 805 event DelinkObjects OnDelinkObjects;
799 event RequestMapBlocks OnRequestMapBlocks; 806 event RequestMapBlocks OnRequestMapBlocks;
@@ -805,6 +812,7 @@ namespace OpenSim.Framework
805 event TeleportLandmarkRequest OnTeleportLandmarkRequest; 812 event TeleportLandmarkRequest OnTeleportLandmarkRequest;
806 event TeleportCancel OnTeleportCancel; 813 event TeleportCancel OnTeleportCancel;
807 event DeRezObject OnDeRezObject; 814 event DeRezObject OnDeRezObject;
815 event RezRestoreToWorld OnRezRestoreToWorld;
808 event Action<IClientAPI> OnRegionHandShakeReply; 816 event Action<IClientAPI> OnRegionHandShakeReply;
809 event GenericCall1 OnRequestWearables; 817 event GenericCall1 OnRequestWearables;
810 event Action<IClientAPI, bool> OnCompleteMovementToRegion; 818 event Action<IClientAPI, bool> OnCompleteMovementToRegion;
@@ -860,6 +868,7 @@ namespace OpenSim.Framework
860 event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; 868 event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
861 event UpdatePrimFlags OnUpdatePrimFlags; 869 event UpdatePrimFlags OnUpdatePrimFlags;
862 event UpdatePrimTexture OnUpdatePrimTexture; 870 event UpdatePrimTexture OnUpdatePrimTexture;
871 event ClientChangeObject onClientChangeObject;
863 event UpdateVector OnUpdatePrimGroupPosition; 872 event UpdateVector OnUpdatePrimGroupPosition;
864 event UpdateVector OnUpdatePrimSinglePosition; 873 event UpdateVector OnUpdatePrimSinglePosition;
865 event UpdatePrimRotation OnUpdatePrimGroupRotation; 874 event UpdatePrimRotation OnUpdatePrimGroupRotation;
@@ -884,6 +893,7 @@ namespace OpenSim.Framework
884 event RequestTaskInventory OnRequestTaskInventory; 893 event RequestTaskInventory OnRequestTaskInventory;
885 event UpdateInventoryItem OnUpdateInventoryItem; 894 event UpdateInventoryItem OnUpdateInventoryItem;
886 event CopyInventoryItem OnCopyInventoryItem; 895 event CopyInventoryItem OnCopyInventoryItem;
896 event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
887 event MoveInventoryItem OnMoveInventoryItem; 897 event MoveInventoryItem OnMoveInventoryItem;
888 event RemoveInventoryFolder OnRemoveInventoryFolder; 898 event RemoveInventoryFolder OnRemoveInventoryFolder;
889 event RemoveInventoryItem OnRemoveInventoryItem; 899 event RemoveInventoryItem OnRemoveInventoryItem;
@@ -1002,7 +1012,7 @@ namespace OpenSim.Framework
1002 event ClassifiedInfoRequest OnClassifiedInfoRequest; 1012 event ClassifiedInfoRequest OnClassifiedInfoRequest;
1003 event ClassifiedInfoUpdate OnClassifiedInfoUpdate; 1013 event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
1004 event ClassifiedDelete OnClassifiedDelete; 1014 event ClassifiedDelete OnClassifiedDelete;
1005 event ClassifiedDelete OnClassifiedGodDelete; 1015 event ClassifiedGodDelete OnClassifiedGodDelete;
1006 1016
1007 event EventNotificationAddRequest OnEventNotificationAddRequest; 1017 event EventNotificationAddRequest OnEventNotificationAddRequest;
1008 event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; 1018 event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
@@ -1025,7 +1035,7 @@ namespace OpenSim.Framework
1025 event MuteListRequest OnMuteListRequest; 1035 event MuteListRequest OnMuteListRequest;
1026 1036
1027 event PlacesQuery OnPlacesQuery; 1037 event PlacesQuery OnPlacesQuery;
1028 1038
1029 event FindAgentUpdate OnFindAgent; 1039 event FindAgentUpdate OnFindAgent;
1030 event TrackAgentUpdate OnTrackAgent; 1040 event TrackAgentUpdate OnTrackAgent;
1031 event NewUserReport OnUserReport; 1041 event NewUserReport OnUserReport;
@@ -1041,11 +1051,12 @@ namespace OpenSim.Framework
1041 event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; 1051 event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
1042 event SimWideDeletesDelegate OnSimWideDeletes; 1052 event SimWideDeletesDelegate OnSimWideDeletes;
1043 event SendPostcard OnSendPostcard; 1053 event SendPostcard OnSendPostcard;
1054 event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
1044 event MuteListEntryUpdate OnUpdateMuteListEntry; 1055 event MuteListEntryUpdate OnUpdateMuteListEntry;
1045 event MuteListEntryRemove OnRemoveMuteListEntry; 1056 event MuteListEntryRemove OnRemoveMuteListEntry;
1046 event GodlikeMessage onGodlikeMessage; 1057 event GodlikeMessage onGodlikeMessage;
1047 event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; 1058 event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
1048 1059 event GenericCall2 OnUpdateThrottles;
1049 /// <summary> 1060 /// <summary>
1050 /// Set the debug level at which packet output should be printed to console. 1061 /// Set the debug level at which packet output should be printed to console.
1051 /// </summary> 1062 /// </summary>
@@ -1066,15 +1077,15 @@ namespace OpenSim.Framework
1066 /// If true, attempts the close without checking active status. You do not want to try this except as a last 1077 /// If true, attempts the close without checking active status. You do not want to try this except as a last
1067 /// ditch attempt where Active == false but the ScenePresence still exists. 1078 /// ditch attempt where Active == false but the ScenePresence still exists.
1068 /// </param> 1079 /// </param>
1069 void Close(bool force); 1080 void Close(bool sendStop, bool force);
1070 1081
1071 void Kick(string message); 1082 void Kick(string message);
1072 1083
1073 /// <summary> 1084 /// <summary>
1074 /// Start processing for this client. 1085 /// Start processing for this client.
1075 /// </summary> 1086 /// </summary>
1076 void Start(); 1087 void Start();
1077 1088
1078 void Stop(); 1089 void Stop();
1079 1090
1080 // void ActivateGesture(UUID assetId, UUID gestureId); 1091 // void ActivateGesture(UUID assetId, UUID gestureId);
@@ -1102,6 +1113,8 @@ namespace OpenSim.Framework
1102 /// <param name="localID"></param> 1113 /// <param name="localID"></param>
1103 void SendKillObject(List<uint> localID); 1114 void SendKillObject(List<uint> localID);
1104 1115
1116// void SendPartFullUpdate(ISceneEntity ent, uint? parentID);
1117
1105 void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); 1118 void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs);
1106 void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); 1119 void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args);
1107 1120
@@ -1125,11 +1138,13 @@ namespace OpenSim.Framework
1125 void SendGenericMessage(string method, UUID invoice, List<string> message); 1138 void SendGenericMessage(string method, UUID invoice, List<string> message);
1126 void SendGenericMessage(string method, UUID invoice, List<byte[]> message); 1139 void SendGenericMessage(string method, UUID invoice, List<byte[]> message);
1127 1140
1141 bool CanSendLayerData();
1142
1128 void SendLayerData(float[] map); 1143 void SendLayerData(float[] map);
1129 void SendLayerData(int px, int py, float[] map); 1144 void SendLayerData(int px, int py, float[] map);
1130 1145
1131 void SendWindData(Vector2[] windSpeeds); 1146 void SendWindData(int version, Vector2[] windSpeeds);
1132 void SendCloudData(float[] cloudCover); 1147 void SendCloudData(int version, float[] cloudCover);
1133 1148
1134 /// <summary> 1149 /// <summary>
1135 /// Sent when an agent completes its movement into a region. 1150 /// Sent when an agent completes its movement into a region.
@@ -1141,7 +1156,7 @@ namespace OpenSim.Framework
1141 void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); 1156 void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
1142 1157
1143 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); 1158 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
1144 1159
1145 /// <summary> 1160 /// <summary>
1146 /// Return circuit information for this client. 1161 /// Return circuit information for this client.
1147 /// </summary> 1162 /// </summary>
@@ -1168,8 +1183,13 @@ namespace OpenSim.Framework
1168 void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations); 1183 void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations);
1169 1184
1170 void SetChildAgentThrottle(byte[] throttle); 1185 void SetChildAgentThrottle(byte[] throttle);
1186 void SetChildAgentThrottle(byte[] throttle,float factor);
1187
1188 void SetAgentThrottleSilent(int throttle, int setting);
1189 int GetAgentThrottleSilent(int throttle);
1171 1190
1172 void SendAvatarDataImmediate(ISceneEntity avatar); 1191 void SendEntityFullUpdateImmediate(ISceneEntity entity);
1192 void SendEntityTerseUpdateImmediate(ISceneEntity entity);
1173 1193
1174 /// <summary> 1194 /// <summary>
1175 /// Send a positional, velocity, etc. update to the viewer for a given entity. 1195 /// Send a positional, velocity, etc. update to the viewer for a given entity.
@@ -1192,6 +1212,7 @@ namespace OpenSim.Framework
1192 /// </summary> 1212 /// </summary>
1193 /// <param name="Item"></param> 1213 /// <param name="Item"></param>
1194 void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId); 1214 void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId);
1215 void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId);
1195 1216
1196 void SendRemoveInventoryItem(UUID itemID); 1217 void SendRemoveInventoryItem(UUID itemID);
1197 1218
@@ -1204,14 +1225,14 @@ namespace OpenSim.Framework
1204 /// <summary> 1225 /// <summary>
1205 /// Used by the server to inform the client of new inventory items and folders. 1226 /// Used by the server to inform the client of new inventory items and folders.
1206 /// </summary> 1227 /// </summary>
1207 /// 1228 ///
1208 /// If the node is a folder then the contents will be transferred 1229 /// If the node is a folder then the contents will be transferred
1209 /// (including all descendent folders) as well as the folder itself. 1230 /// (including all descendent folders) as well as the folder itself.
1210 /// 1231 ///
1211 /// <param name="node"></param> 1232 /// <param name="node"></param>
1212 void SendBulkUpdateInventory(InventoryNodeBase node); 1233 void SendBulkUpdateInventory(InventoryNodeBase node);
1213 1234
1214 void SendXferPacket(ulong xferID, uint packet, byte[] data); 1235 void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory);
1215 1236
1216 void SendAbortXferPacket(ulong xferID); 1237 void SendAbortXferPacket(ulong xferID);
1217 1238
@@ -1237,9 +1258,11 @@ namespace OpenSim.Framework
1237 void SendAttachedSoundGainChange(UUID objectID, float gain); 1258 void SendAttachedSoundGainChange(UUID objectID, float gain);
1238 1259
1239 void SendNameReply(UUID profileId, string firstname, string lastname); 1260 void SendNameReply(UUID profileId, string firstname, string lastname);
1240 void SendAlertMessage(string message);
1241 1261
1262 void SendAlertMessage(string message);
1263 void SendAlertMessage(string message, string into);
1242 void SendAgentAlertMessage(string message, bool modal); 1264 void SendAgentAlertMessage(string message, bool modal);
1265
1243 void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); 1266 void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url);
1244 1267
1245 /// <summary> 1268 /// <summary>
@@ -1268,11 +1291,11 @@ namespace OpenSim.Framework
1268 /// <param name="OrbitalPosition">The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView</param> 1291 /// <param name="OrbitalPosition">The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView</param>
1269 void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, 1292 void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear,
1270 float OrbitalPosition); 1293 float OrbitalPosition);
1271 1294
1272 void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks); 1295 void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks);
1273 void SendViewerTime(int phase); 1296 void SendViewerTime(int phase);
1274 1297
1275 void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, string flAbout, 1298 void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout,
1276 uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID); 1299 uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID);
1277 1300
1278 void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question); 1301 void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question);
@@ -1336,7 +1359,7 @@ namespace OpenSim.Framework
1336 void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec); 1359 void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec);
1337 1360
1338 /// <summary> 1361 /// <summary>
1339 /// Send the next packet for a series of packets making up a single texture, 1362 /// Send the next packet for a series of packets making up a single texture,
1340 /// as established by SendImageFirstPart() 1363 /// as established by SendImageFirstPart()
1341 /// </summary> 1364 /// </summary>
1342 /// <param name="partNumber"></param> 1365 /// <param name="partNumber"></param>
@@ -1361,12 +1384,16 @@ namespace OpenSim.Framework
1361 1384
1362 void SendObjectPropertiesReply(ISceneEntity Entity); 1385 void SendObjectPropertiesReply(ISceneEntity Entity);
1363 1386
1387 void SendSelectedPartsProprieties(List<ISceneEntity> parts);
1388
1364 void SendPartPhysicsProprieties(ISceneEntity Entity); 1389 void SendPartPhysicsProprieties(ISceneEntity Entity);
1365 1390
1366 void SendAgentOffline(UUID[] agentIDs); 1391 void SendAgentOffline(UUID[] agentIDs);
1367 1392
1368 void SendAgentOnline(UUID[] agentIDs); 1393 void SendAgentOnline(UUID[] agentIDs);
1369 1394
1395 void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY);
1396
1370 void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 1397 void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
1371 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook); 1398 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook);
1372 1399
@@ -1432,6 +1459,7 @@ namespace OpenSim.Framework
1432 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags); 1459 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags);
1433 1460
1434 void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data); 1461 void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data);
1462 void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data);
1435 void SendOfferCallingCard(UUID srcID, UUID transactionID); 1463 void SendOfferCallingCard(UUID srcID, UUID transactionID);
1436 void SendAcceptCallingCard(UUID transactionID); 1464 void SendAcceptCallingCard(UUID transactionID);
1437 void SendDeclineCallingCard(UUID transactionID); 1465 void SendDeclineCallingCard(UUID transactionID);
@@ -1443,6 +1471,9 @@ namespace OpenSim.Framework
1443 1471
1444 void SendAgentDropGroup(UUID groupID); 1472 void SendAgentDropGroup(UUID groupID);
1445 void RefreshGroupMembership(); 1473 void RefreshGroupMembership();
1474 void UpdateGroupMembership(GroupMembershipData[] data);
1475 void GroupMembershipRemove(UUID GroupID);
1476 void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers);
1446 void SendAvatarNotesReply(UUID targetID, string text); 1477 void SendAvatarNotesReply(UUID targetID, string text);
1447 void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks); 1478 void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks);
1448 void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled); 1479 void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled);
@@ -1452,9 +1483,9 @@ namespace OpenSim.Framework
1452 void SendParcelDwellReply(int localID, UUID parcelID, float dwell); 1483 void SendParcelDwellReply(int localID, UUID parcelID, float dwell);
1453 1484
1454 void SendUserInfoReply(bool imViaEmail, bool visible, string email); 1485 void SendUserInfoReply(bool imViaEmail, bool visible, string email);
1455
1456 void SendUseCachedMuteList();
1457 1486
1487 void SendUseCachedMuteList();
1488 void SendEmpytMuteList();
1458 void SendMuteListUpdate(string filename); 1489 void SendMuteListUpdate(string filename);
1459 1490
1460 void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals); 1491 void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals);
@@ -1466,13 +1497,13 @@ namespace OpenSim.Framework
1466 void SendRebakeAvatarTextures(UUID textureID); 1497 void SendRebakeAvatarTextures(UUID textureID);
1467 1498
1468 void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages); 1499 void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages);
1469 1500
1470 void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt); 1501 void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt);
1471 1502
1472 void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier); 1503 void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier);
1473 1504
1474 void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt); 1505 void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt);
1475 1506
1476 void SendChangeUserRights(UUID agentID, UUID friendID, int rights); 1507 void SendChangeUserRights(UUID agentID, UUID friendID, int rights);
1477 void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId); 1508 void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId);
1478 1509
diff --git a/OpenSim/Framework/ICnmCache.cs b/OpenSim/Framework/ICnmCache.cs
index 27b9c56..69b5b42 100644
--- a/OpenSim/Framework/ICnmCache.cs
+++ b/OpenSim/Framework/ICnmCache.cs
@@ -34,10 +34,10 @@ namespace OpenSim.Framework
34 /// Represent generic cache to store key/value pairs (elements) limited by time, size and count of elements. 34 /// Represent generic cache to store key/value pairs (elements) limited by time, size and count of elements.
35 /// </summary> 35 /// </summary>
36 /// <typeparam name="TKey"> 36 /// <typeparam name="TKey">
37 /// The type of keys in the cache. 37 /// The type of keys in the cache.
38 /// </typeparam> 38 /// </typeparam>
39 /// <typeparam name="TValue"> 39 /// <typeparam name="TValue">
40 /// The type of values in the cache. 40 /// The type of values in the cache.
41 /// </typeparam> 41 /// </typeparam>
42 /// <remarks> 42 /// <remarks>
43 /// <para> 43 /// <para>
@@ -51,8 +51,8 @@ namespace OpenSim.Framework
51 /// <item> 51 /// <item>
52 /// <term>Time</term> 52 /// <term>Time</term>
53 /// <description> 53 /// <description>
54 /// Element that is not accessed through <see cref="TryGetValue"/> or <see cref="Set"/> in last <see cref="ExpirationTime"/> are 54 /// Element that is not accessed through <see cref="TryGetValue"/> or <see cref="Set"/> in last <see cref="ExpirationTime"/> are
55 /// removed from the cache automatically. Depending on implementation of the cache some of elements may stay longer in cache. 55 /// removed from the cache automatically. Depending on implementation of the cache some of elements may stay longer in cache.
56 /// <see cref="IsTimeLimited"/> returns <see langword="true"/>, if cache is limited by time. 56 /// <see cref="IsTimeLimited"/> returns <see langword="true"/>, if cache is limited by time.
57 /// </description> 57 /// </description>
58 /// </item> 58 /// </item>
@@ -60,7 +60,7 @@ namespace OpenSim.Framework
60 /// <term>Count</term> 60 /// <term>Count</term>
61 /// <description> 61 /// <description>
62 /// When adding an new element to cache that already have <see cref="MaxCount"/> of elements, cache will remove less recently 62 /// When adding an new element to cache that already have <see cref="MaxCount"/> of elements, cache will remove less recently
63 /// used element(s) from the cache, until element fits to cache. 63 /// used element(s) from the cache, until element fits to cache.
64 /// <see cref="IsCountLimited"/> returns <see langword="true"/>, if cache is limiting element count. 64 /// <see cref="IsCountLimited"/> returns <see langword="true"/>, if cache is limiting element count.
65 /// </description> 65 /// </description>
66 /// </item> 66 /// </item>
@@ -69,8 +69,8 @@ namespace OpenSim.Framework
69 /// <description> 69 /// <description>
70 /// <description> 70 /// <description>
71 /// When adding an new element to cache that already have <see cref="MaxSize"/> of elements, cache will remove less recently 71 /// When adding an new element to cache that already have <see cref="MaxSize"/> of elements, cache will remove less recently
72 /// used element(s) from the cache, until element fits to cache. 72 /// used element(s) from the cache, until element fits to cache.
73 /// <see cref="IsSizeLimited"/> returns <see langword="true"/>, if cache is limiting total size of elements. 73 /// <see cref="IsSizeLimited"/> returns <see langword="true"/>, if cache is limiting total size of elements.
74 /// Normally size is bytes used by element in the cache. But it can be any other suitable unit of measure. 74 /// Normally size is bytes used by element in the cache. But it can be any other suitable unit of measure.
75 /// </description> 75 /// </description>
76 /// </description> 76 /// </description>
@@ -84,8 +84,8 @@ namespace OpenSim.Framework
84 /// </summary> 84 /// </summary>
85 /// <remarks> 85 /// <remarks>
86 /// <para> 86 /// <para>
87 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 87 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
88 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 88 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
89 /// </para> 89 /// </para>
90 /// </remarks> 90 /// </remarks>
91 /// <seealso cref="MaxCount"/> 91 /// <seealso cref="MaxCount"/>
@@ -102,13 +102,13 @@ namespace OpenSim.Framework
102 /// </value> 102 /// </value>
103 /// <remarks> 103 /// <remarks>
104 /// <para> 104 /// <para>
105 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ExpirationTime"/> 105 /// When element has been stored in <see cref="ICnmCache{TKey,TValue}"/> longer than <see cref="ExpirationTime"/>
106 /// and it is not accessed through <see cref="TryGetValue"/> method or element's value is 106 /// and it is not accessed through <see cref="TryGetValue"/> method or element's value is
107 /// not replaced by <see cref="Set"/> method, then it is automatically removed from the 107 /// not replaced by <see cref="Set"/> method, then it is automatically removed from the
108 /// <see cref="ICnmCache{TKey,TValue}"/>. 108 /// <see cref="ICnmCache{TKey,TValue}"/>.
109 /// </para> 109 /// </para>
110 /// <para> 110 /// <para>
111 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time, 111 /// It is possible that <see cref="ICnmCache{TKey,TValue}"/> implementation removes element before it's expiration time,
112 /// because total size or count of elements stored to cache is larger than <see cref="MaxSize"/> or <see cref="MaxCount"/>. 112 /// because total size or count of elements stored to cache is larger than <see cref="MaxSize"/> or <see cref="MaxCount"/>.
113 /// </para> 113 /// </para>
114 /// <para> 114 /// <para>
@@ -135,12 +135,12 @@ namespace OpenSim.Framework
135 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe). 135 /// Gets a value indicating whether or not access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe).
136 /// </summary> 136 /// </summary>
137 /// <value> 137 /// <value>
138 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe); 138 /// <see langword="true"/> if access to the <see cref="ICnmCache{TKey,TValue}"/> is synchronized (thread safe);
139 /// otherwise, <see langword="false"/>. 139 /// otherwise, <see langword="false"/>.
140 /// </value> 140 /// </value>
141 /// <remarks> 141 /// <remarks>
142 /// <para> 142 /// <para>
143 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use 143 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/> object, use
144 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class 144 /// <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> in <see cref="CnmSynchronizedCache{TKey,TValue}"/> class
145 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object. 145 /// to retrieve synchronized wrapper for <see cref="ICnmCache{TKey,TValue}"/> object.
146 /// </para> 146 /// </para>
@@ -153,17 +153,17 @@ namespace OpenSim.Framework
153 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements. 153 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting count of elements.
154 /// </summary> 154 /// </summary>
155 /// <value> 155 /// <value>
156 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited; 156 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> count of elements is limited;
157 /// otherwise, <see langword="false"/>. 157 /// otherwise, <see langword="false"/>.
158 /// </value> 158 /// </value>
159 /// <remarks> 159 /// <remarks>
160 /// <para> 160 /// <para>
161 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 161 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
162 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 162 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
163 /// </para> 163 /// </para>
164 /// </remarks> 164 /// </remarks>
165 /// <seealso cref="Count"/> 165 /// <seealso cref="Count"/>
166 /// <seealso cref="MaxCount"/> 166 /// <seealso cref="MaxCount"/>
167 /// <seealso cref="IsSizeLimited"/> 167 /// <seealso cref="IsSizeLimited"/>
168 /// <seealso cref="IsTimeLimited"/> 168 /// <seealso cref="IsTimeLimited"/>
169 bool IsCountLimited { get; } 169 bool IsCountLimited { get; }
@@ -172,13 +172,13 @@ namespace OpenSim.Framework
172 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements. 172 /// Gets a value indicating whether <see cref="ICnmCache{TKey,TValue}"/> is limiting size of elements.
173 /// </summary> 173 /// </summary>
174 /// <value> 174 /// <value>
175 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited; 175 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> total size of elements is limited;
176 /// otherwise, <see langword="false"/>. 176 /// otherwise, <see langword="false"/>.
177 /// </value> 177 /// </value>
178 /// <remarks> 178 /// <remarks>
179 /// <para> 179 /// <para>
180 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 180 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
181 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 181 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
182 /// </para> 182 /// </para>
183 /// </remarks> 183 /// </remarks>
184 /// <seealso cref="MaxElementSize"/> 184 /// <seealso cref="MaxElementSize"/>
@@ -192,13 +192,13 @@ namespace OpenSim.Framework
192 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time. 192 /// Gets a value indicating whether elements stored to <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time.
193 /// </summary> 193 /// </summary>
194 /// <value> 194 /// <value>
195 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements; 195 /// <see langword="true"/> if the <see cref="ICnmCache{TKey,TValue}"/> has a fixed total size of elements;
196 /// otherwise, <see langword="false"/>. 196 /// otherwise, <see langword="false"/>.
197 /// </value> 197 /// </value>
198 /// <remarks> 198 /// <remarks>
199 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="Set"/> 199 /// If <see cref="ICnmCache{TKey,TValue}"/> have limited inactivity time and element is not accessed through <see cref="Set"/>
200 /// or <see cref="TryGetValue"/> methods in <see cref="ExpirationTime"/> , then element is automatically removed from 200 /// or <see cref="TryGetValue"/> methods in <see cref="ExpirationTime"/> , then element is automatically removed from
201 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may 201 /// the cache. Depending on implementation of the <see cref="ICnmCache{TKey,TValue}"/>, some of the elements may
202 /// stay longer in cache. 202 /// stay longer in cache.
203 /// </remarks> 203 /// </remarks>
204 /// <seealso cref="ExpirationTime"/> 204 /// <seealso cref="ExpirationTime"/>
@@ -206,18 +206,18 @@ namespace OpenSim.Framework
206 /// <seealso cref="IsCountLimited"/> 206 /// <seealso cref="IsCountLimited"/>
207 /// <seealso cref="IsSizeLimited"/> 207 /// <seealso cref="IsSizeLimited"/>
208 bool IsTimeLimited { get; } 208 bool IsTimeLimited { get; }
209 209
210 /// <summary> 210 /// <summary>
211 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>. 211 /// Gets or sets maximal allowed count of elements that can be stored to <see cref="ICnmCache{TKey,TValue}"/>.
212 /// </summary> 212 /// </summary>
213 /// <value> 213 /// <value>
214 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements; 214 /// <see cref="int.MaxValue"/>, if <see cref="ICnmCache{TKey,TValue}"/> is not limited by count of elements;
215 /// otherwise maximal allowed count of elements. 215 /// otherwise maximal allowed count of elements.
216 /// </value> 216 /// </value>
217 /// <remarks> 217 /// <remarks>
218 /// <para> 218 /// <para>
219 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 219 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
220 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 220 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
221 /// </para> 221 /// </para>
222 /// </remarks> 222 /// </remarks>
223 int MaxCount { get; set; } 223 int MaxCount { get; set; }
@@ -230,7 +230,7 @@ namespace OpenSim.Framework
230 /// </value> 230 /// </value>
231 /// <remarks> 231 /// <remarks>
232 /// <para> 232 /// <para>
233 /// If element's size is larger than <see cref="MaxElementSize"/>, then element is 233 /// If element's size is larger than <see cref="MaxElementSize"/>, then element is
234 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>. 234 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>.
235 /// </para> 235 /// </para>
236 /// </remarks> 236 /// </remarks>
@@ -251,8 +251,8 @@ namespace OpenSim.Framework
251 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure. 251 /// Normally size is total bytes used by elements in the cache. But it can be any other suitable unit of measure.
252 /// </para> 252 /// </para>
253 /// <para> 253 /// <para>
254 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 254 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
255 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 255 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
256 /// </para> 256 /// </para>
257 /// </remarks> 257 /// </remarks>
258 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception> 258 /// <exception cref="ArgumentOutOfRangeException">value is less than 0.</exception>
@@ -272,11 +272,11 @@ namespace OpenSim.Framework
272 /// Normally bytes, but can be any suitable unit of measure. 272 /// Normally bytes, but can be any suitable unit of measure.
273 /// </para> 273 /// </para>
274 /// <para> 274 /// <para>
275 /// Element's size is given when element is added or replaced by <see cref="Set"/> method. 275 /// Element's size is given when element is added or replaced by <see cref="Set"/> method.
276 /// </para> 276 /// </para>
277 /// <para> 277 /// <para>
278 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 278 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
279 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element. 279 /// <see cref="ICnmCache{TKey,TValue}"/> will remove less recently used elements until it can fit an new element.
280 /// </para> 280 /// </para>
281 /// </remarks> 281 /// </remarks>
282 /// <seealso cref="MaxElementSize"/> 282 /// <seealso cref="MaxElementSize"/>
@@ -294,8 +294,8 @@ namespace OpenSim.Framework
294 /// </value> 294 /// </value>
295 /// <remarks> 295 /// <remarks>
296 /// <para> 296 /// <para>
297 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/> 297 /// To get synchronized (thread safe) access to <see cref="ICnmCache{TKey,TValue}"/>, use <see cref="CnmSynchronizedCache{TKey,TValue}"/>
298 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to 298 /// method <see cref="CnmSynchronizedCache{TKey,TValue}.Synchronized"/> to retrieve synchronized wrapper interface to
299 /// <see cref="ICnmCache{TKey,TValue}"/>. 299 /// <see cref="ICnmCache{TKey,TValue}"/>.
300 /// </para> 300 /// </para>
301 /// </remarks> 301 /// </remarks>
@@ -367,7 +367,7 @@ namespace OpenSim.Framework
367 void RemoveRange(IEnumerable<TKey> keys); 367 void RemoveRange(IEnumerable<TKey> keys);
368 368
369 /// <summary> 369 /// <summary>
370 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to 370 /// Add or replace an element with the provided <paramref name="key"/>, <paramref name="value"/> and <paramref name="size"/> to
371 /// <see cref="ICnmCache{TKey,TValue}"/>. 371 /// <see cref="ICnmCache{TKey,TValue}"/>.
372 /// </summary> 372 /// </summary>
373 /// <param name="key"> 373 /// <param name="key">
@@ -380,7 +380,7 @@ namespace OpenSim.Framework
380 /// The element's size. Normally bytes, but can be any suitable unit of measure. 380 /// The element's size. Normally bytes, but can be any suitable unit of measure.
381 /// </param> 381 /// </param>
382 /// <returns> 382 /// <returns>
383 /// <see langword="true"/> if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>; 383 /// <see langword="true"/> if element has been added successfully to the <see cref="ICnmCache{TKey,TValue}"/>;
384 /// otherwise <see langword="false"/>. 384 /// otherwise <see langword="false"/>.
385 /// </returns> 385 /// </returns>
386 /// <exception cref="ArgumentNullException"> 386 /// <exception cref="ArgumentNullException">
@@ -391,17 +391,17 @@ namespace OpenSim.Framework
391 /// </exception> 391 /// </exception>
392 /// <remarks> 392 /// <remarks>
393 /// <para> 393 /// <para>
394 /// If element's <paramref name="size"/> is larger than <see cref="MaxElementSize"/>, then element is 394 /// If element's <paramref name="size"/> is larger than <see cref="MaxElementSize"/>, then element is
395 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is 395 /// not added to the <see cref="ICnmCache{TKey,TValue}"/>, however - possible older element is
396 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>. 396 /// removed from the <see cref="ICnmCache{TKey,TValue}"/>.
397 /// </para> 397 /// </para>
398 /// <para> 398 /// <para>
399 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements, 399 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting total size of elements,
400 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 400 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
401 /// </para> 401 /// </para>
402 /// <para> 402 /// <para>
403 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count, 403 /// When adding an new element to <see cref="ICnmCache{TKey,TValue}"/> that is limiting element count,
404 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element. 404 /// <see cref="ICnmCache{TKey,TValue}"/>will remove less recently used elements until it can fit an new element.
405 /// </para> 405 /// </para>
406 /// </remarks> 406 /// </remarks>
407 /// <seealso cref="IsSizeLimited"/> 407 /// <seealso cref="IsSizeLimited"/>
@@ -417,15 +417,15 @@ namespace OpenSim.Framework
417 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>. 417 /// Gets the <paramref name="value"/> associated with the specified <paramref name="key"/>.
418 /// </summary> 418 /// </summary>
419 /// <returns> 419 /// <returns>
420 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with 420 /// <see langword="true"/>if the <see cref="ICnmCache{TKey,TValue}"/> contains an element with
421 /// the specified key; otherwise, <see langword="false"/>. 421 /// the specified key; otherwise, <see langword="false"/>.
422 /// </returns> 422 /// </returns>
423 /// <param name="key"> 423 /// <param name="key">
424 /// The key whose <paramref name="value"/> to get. 424 /// The key whose <paramref name="value"/> to get.
425 /// </param> 425 /// </param>
426 /// <param name="value"> 426 /// <param name="value">
427 /// When this method returns, the value associated with the specified <paramref name="key"/>, 427 /// When this method returns, the value associated with the specified <paramref name="key"/>,
428 /// if the <paramref name="key"/> is found; otherwise, the 428 /// if the <paramref name="key"/> is found; otherwise, the
429 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized. 429 /// default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.
430 /// </param> 430 /// </param>
431 /// <exception cref="ArgumentNullException"> 431 /// <exception cref="ArgumentNullException">
diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs
index c46c03c..8667837 100644
--- a/OpenSim/Framework/ILandChannel.cs
+++ b/OpenSim/Framework/ILandChannel.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.Framework.Interfaces
38 /// </summary> 38 /// </summary>
39 /// <returns></returns> 39 /// <returns></returns>
40 List<ILandObject> AllParcels(); 40 List<ILandObject> AllParcels();
41 41
42 /// <summary> 42 /// <summary>
43 /// Get the parcel at the specified point 43 /// Get the parcel at the specified point
44 /// </summary> 44 /// </summary>
@@ -75,7 +75,9 @@ namespace OpenSim.Region.Framework.Interfaces
75 /// <param name="localID"></param> 75 /// <param name="localID"></param>
76 /// <returns></returns> 76 /// <returns></returns>
77 ILandObject GetLandObject(int localID); 77 ILandObject GetLandObject(int localID);
78 78
79 ILandObject GetLandObject(UUID GlobalID);
80
79 /// <summary> 81 /// <summary>
80 /// Clear the land channel of all parcels. 82 /// Clear the land channel of all parcels.
81 /// </summary> 83 /// </summary>
@@ -83,9 +85,10 @@ namespace OpenSim.Region.Framework.Interfaces
83 /// If true, set up a default parcel covering the whole region owned by the estate owner. 85 /// If true, set up a default parcel covering the whole region owned by the estate owner.
84 /// </param> 86 /// </param>
85 void Clear(bool setupDefaultParcel); 87 void Clear(bool setupDefaultParcel);
86 88
87 bool IsForcefulBansAllowed(); 89 bool IsForcefulBansAllowed();
88 void UpdateLandObject(int localID, LandData data); 90 void UpdateLandObject(int localID, LandData data);
91 void SendParcelsOverlay(IClientAPI client);
89 void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient); 92 void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient);
90 void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel); 93 void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel);
91 void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel); 94 void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel);
@@ -93,5 +96,7 @@ namespace OpenSim.Region.Framework.Interfaces
93 96
94 void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); 97 void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
95 void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); 98 void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id);
99 void sendClientInitialLandInfo(IClientAPI remoteClient);
100
96 } 101 }
97} 102}
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs
index 8465c86..a783256 100644
--- a/OpenSim/Framework/ILandObject.cs
+++ b/OpenSim/Framework/ILandObject.cs
@@ -43,32 +43,39 @@ namespace OpenSim.Framework
43 LandData LandData { get; set; } 43 LandData LandData { get; set; }
44 bool[,] LandBitmap { get; set; } 44 bool[,] LandBitmap { get; set; }
45 UUID RegionUUID { get; } 45 UUID RegionUUID { get; }
46 46
47 /// <summary> 47 /// <summary>
48 /// Prim counts for this land object. 48 /// Prim counts for this land object.
49 /// </summary> 49 /// </summary>
50 IPrimCounts PrimCounts { get; set; } 50 IPrimCounts PrimCounts { get; set; }
51 51
52 /// <summary> 52 /// <summary>
53 /// The start point for the land object. This is the western-most point as one scans land working from 53 /// The start point for the land object. This is the northern-most point as one scans land working from
54 /// north to south. 54 /// west to east.
55 /// </summary> 55 /// </summary>
56 Vector3 StartPoint { get; } 56 Vector2 StartPoint { get; }
57 57
58 /// <summary> 58 /// <summary>
59 /// The end point for the land object. This is the eastern-most point as one scans land working from 59 /// The end point for the land object. This is the southern-most point as one scans land working from
60 /// south to north. 60 /// west to east.
61 /// </summary> 61 /// </summary>
62 Vector3 EndPoint { get; } 62 Vector2 EndPoint { get; }
63 63
64 // a estimation of a parcel center.
65 Vector2 CenterPoint { get; }
66
67 // get positions
68 Vector2? GetNearestPoint(Vector3 pos);
69 Vector2? GetNearestPointAlongDirection(Vector3 pos, Vector3 pdirection);
70
64 bool ContainsPoint(int x, int y); 71 bool ContainsPoint(int x, int y);
65 72
66 ILandObject Copy(); 73 ILandObject Copy();
67 74
68 void SendLandUpdateToAvatarsOverMe(); 75 void SendLandUpdateToAvatarsOverMe();
69 76
70 void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client); 77 void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client);
71 void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client); 78 bool UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client, out bool snap_selection, out bool needOverlay);
72 bool IsEitherBannedOrRestricted(UUID avatar); 79 bool IsEitherBannedOrRestricted(UUID avatar);
73 bool IsBannedFromLand(UUID avatar); 80 bool IsBannedFromLand(UUID avatar);
74 bool CanBeOnThisLand(UUID avatar, float posHeight); 81 bool CanBeOnThisLand(UUID avatar, float posHeight);
@@ -90,27 +97,70 @@ namespace OpenSim.Framework
90 /// </summary> 97 /// </summary>
91 /// <returns>The bitmap created.</returns> 98 /// <returns>The bitmap created.</returns>
92 bool[,] BasicFullRegionLandBitmap(); 99 bool[,] BasicFullRegionLandBitmap();
93 100
94 /// <summary> 101 /// <summary>
95 /// Create a square land bitmap. 102 /// Create a square land bitmap.
96 /// </summary> 103 /// </summary>
97 /// <remarks> 104 /// <remarks>
98 /// Land co-ordinates are zero indexed. The inputs are treated as points. So if you want to create a bitmap 105 /// Land co-ordinates are zero indexed. The inputs are treated as points. So if you want to create a bitmap
99 /// that covers an entire 256 x 256m region apart from a strip of land on the east, then you would need to 106 /// that covers an entire 256 x 256m region apart from a strip of land on the east, then you would need to
100 /// specify start_x = 0, start_y = 0, end_x = 252 (or anything up to 255), end_y = 256. 107 /// specify start_x = 0, start_y = 0, end_x = 252 (or anything up to 255), end_y = 255.
101 /// 108 ///
102 /// At the moment, the smallest parcel of land is 4m x 4m, so if the 109 /// At the moment, the smallest parcel of land is 4m x 4m, so if the
103 /// region is 256 x 256m (the SL size), the bitmap returned will start at (0,0) and end at (63,63). 110 /// region is 256 x 256m (the SL size), the bitmap returned will start at (0,0) and end at (63,63).
111 /// The value of the set_value needs to be true to define an active parcel of the given size.
104 /// </remarks> 112 /// </remarks>
105 /// <param name="start_x"></param> 113 /// <param name="start_x"></param>
106 /// <param name="start_y"></param> 114 /// <param name="start_y"></param>
107 /// <param name="end_x"></param> 115 /// <param name="end_x"></param>
108 /// <param name="end_y"></param> 116 /// <param name="end_y"></param>
117 /// <param name="set_value"></param>
109 /// <returns>The bitmap created.</returns> 118 /// <returns>The bitmap created.</returns>
110 bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y); 119 bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y, bool set_value = true);
111 120
112 bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value); 121 bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value);
122
123 /// <summary>
124 /// Merge two (same size) land bitmaps.
125 /// </summary>
126 /// <param name="bitmap_base"></param>
127 /// <param name="bitmap_add"></param>
128 /// <returns>The modified bitmap.</returns>
113 bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add); 129 bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add);
130
131 /// <summary>
132 /// Remap a land bitmap. Takes the supplied land bitmap and rotates it, crops it and finally offsets it into
133 /// a final land bitmap of the target region size.
134 /// </summary>
135 /// <param name="bitmap_base">The original parcel bitmap</param>
136 /// <param name="rotationDegrees"></param>
137 /// <param name="displacement">&lt;x,y,?&gt;</param>
138 /// <param name="boundingOrigin">&lt;x,y,?&gt;</param>
139 /// <param name="boundingSize">&lt;x,y,?&gt;</param>
140 /// <param name="regionSize">&lt;x,y,?&gt;</param>
141 /// <param name="isEmptyNow">out: This is set if the resultant bitmap is now empty</param>
142 /// <param name="AABBMin">out: parcel.AABBMin &lt;x,y,0&gt</param>
143 /// <param name="AABBMax">out: parcel.AABBMax &lt;x,y,0&gt</param>
144 /// <returns>New parcel bitmap</returns>
145 bool[,] RemapLandBitmap(bool[,] bitmap_base, Vector2 displacement, float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize, Vector2 regionSize, out bool isEmptyNow, out Vector3 AABBMin, out Vector3 AABBMax);
146
147 /// <summary>
148 /// Clears any parcel data in bitmap_base where there exists parcel data in bitmap_new. In other words the parcel data
149 /// in bitmap_new takes over the space of the parcel data in bitmap_base.
150 /// </summary>
151 /// <param name="bitmap_base"></param>
152 /// <param name="bitmap_new"></param>
153 /// <param name="isEmptyNow">out: This is set if the resultant bitmap is now empty</param>
154 /// <param name="AABBMin">out: parcel.AABBMin &lt;x,y,0&gt;</param>
155 /// <param name="AABBMax">out: parcel.AABBMax &lt;x,y,0&gt</param>
156 /// <returns>New parcel bitmap</returns>
157 bool[,] RemoveFromLandBitmap(bool[,] bitmap_base, bool[,] bitmap_new, out bool isEmptyNow, out Vector3 AABBMin, out Vector3 AABBMax);
158
159 byte[] ConvertLandBitmapToBytes();
160 bool[,] ConvertBytesToLandBitmap(bool overrideRegionSize = false);
161 bool IsLandBitmapEmpty(bool[,] landBitmap);
162 void DebugLandBitmap(bool[,] landBitmap);
163
114 void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client); 164 void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client);
115 void SendLandObjectOwners(IClientAPI remote_client); 165 void SendLandObjectOwners(IClientAPI remote_client);
116 void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client); 166 void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client);
@@ -127,7 +177,7 @@ namespace OpenSim.Framework
127 /// </summary> 177 /// </summary>
128 /// <param name="url"></param> 178 /// <param name="url"></param>
129 void SetMediaUrl(string url); 179 void SetMediaUrl(string url);
130 180
131 /// <summary> 181 /// <summary>
132 /// Set the music url for this land parcel 182 /// Set the music url for this land parcel
133 /// </summary> 183 /// </summary>
@@ -139,5 +189,7 @@ namespace OpenSim.Framework
139 /// </summary> 189 /// </summary>
140 /// <returns>The music url.</returns> 190 /// <returns>The music url.</returns>
141 string GetMusicUrl(); 191 string GetMusicUrl();
192
193 void Clear();
142 } 194 }
143} 195}
diff --git a/OpenSim/Framework/IMoneyModule.cs b/OpenSim/Framework/IMoneyModule.cs
index 52f3e83..c72c742 100644
--- a/OpenSim/Framework/IMoneyModule.cs
+++ b/OpenSim/Framework/IMoneyModule.cs
@@ -32,15 +32,16 @@ namespace OpenSim.Framework
32 public delegate void ObjectPaid(UUID objectID, UUID agentID, int amount); 32 public delegate void ObjectPaid(UUID objectID, UUID agentID, int amount);
33 public interface IMoneyModule 33 public interface IMoneyModule
34 { 34 {
35 bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, 35 bool ObjectGiveMoney(UUID objectID, UUID fromID,
36 int amount); 36 UUID toID, int amount, UUID txn, out string reason);
37 37
38 int GetBalance(UUID agentID); 38 int GetBalance(UUID agentID);
39 bool UploadCovered(UUID agentID, int amount); 39 bool UploadCovered(UUID agentID, int amount);
40 bool AmountCovered(UUID agentID, int amount); 40 bool AmountCovered(UUID agentID, int amount);
41 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type); 41 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData = "");
42 void ApplyCharge(UUID agentID, int amount, MoneyTransactionType type, string extraData);
43 void ApplyUploadCharge(UUID agentID, int amount, string text); 42 void ApplyUploadCharge(UUID agentID, int amount, string text);
43 void MoveMoney(UUID fromUser, UUID toUser, int amount, string text);
44 bool MoveMoney(UUID fromUser, UUID toUser, int amount, MoneyTransactionType type, string text);
44 45
45 int UploadCharge { get; } 46 int UploadCharge { get; }
46 int GroupCreationCharge { get; } 47 int GroupCreationCharge { get; }
diff --git a/OpenSim/Framework/IPrimCounts.cs b/OpenSim/Framework/IPrimCounts.cs
index 3e12348..3b62ad3 100644
--- a/OpenSim/Framework/IPrimCounts.cs
+++ b/OpenSim/Framework/IPrimCounts.cs
@@ -35,12 +35,12 @@ namespace OpenSim.Framework
35 /// Parcel owner owned prims 35 /// Parcel owner owned prims
36 /// </summary> 36 /// </summary>
37 int Owner { get; } 37 int Owner { get; }
38 38
39 /// <summary> 39 /// <summary>
40 /// Parcel group owned prims 40 /// Parcel group owned prims
41 /// </summary> 41 /// </summary>
42 int Group { get; } 42 int Group { get; }
43 43
44 /// <summary> 44 /// <summary>
45 /// Prims owned by others (not parcel owner or parcel group). 45 /// Prims owned by others (not parcel owner or parcel group).
46 /// </summary> 46 /// </summary>
@@ -48,19 +48,19 @@ namespace OpenSim.Framework
48 48
49 /// <summary> 49 /// <summary>
50 /// Selected prims 50 /// Selected prims
51 /// </summary> 51 /// </summary>
52 int Selected { get; } 52 int Selected { get; }
53 53
54 /// <summary> 54 /// <summary>
55 /// Total prims on the parcel. 55 /// Total prims on the parcel.
56 /// </summary> 56 /// </summary>
57 int Total { get; } 57 int Total { get; }
58 58
59 /// <summary> 59 /// <summary>
60 /// Prims on the simulator that are owned by the parcel owner, even if they are in other parcels. 60 /// Prims on the simulator that are owned by the parcel owner, even if they are in other parcels.
61 /// </summary> 61 /// </summary>
62 int Simulator { get; } 62 int Simulator { get; }
63 63
64 /// <summary> 64 /// <summary>
65 /// Prims per individual users. 65 /// Prims per individual users.
66 /// </summary> 66 /// </summary>
diff --git a/OpenSim/Framework/IRegistryCore.cs b/OpenSim/Framework/IRegistryCore.cs
index a94b65d..cf3ecc0 100644
--- a/OpenSim/Framework/IRegistryCore.cs
+++ b/OpenSim/Framework/IRegistryCore.cs
@@ -31,7 +31,7 @@ using System.Text;
31 31
32namespace OpenSim.Framework 32namespace OpenSim.Framework
33{ 33{
34 public interface IRegistryCore 34 public interface IRegistryCore
35 { 35 {
36 T Get<T>(); 36 T Get<T>();
37 void RegisterInterface<T>(T iface); 37 void RegisterInterface<T>(T iface);
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index e1b6d1e..37a064f 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework
40 Crashed = 2, 40 Crashed = 2,
41 Starting = 3, 41 Starting = 3,
42 }; 42 };
43 43
44 /// <value> 44 /// <value>
45 /// Indicate what action to take on an object derez request 45 /// Indicate what action to take on an object derez request
46 /// </value> 46 /// </value>
@@ -118,7 +118,7 @@ namespace OpenSim.Framework
118 /// </summary> 118 /// </summary>
119 /// <param name="mod"></param> 119 /// <param name="mod"></param>
120 void RegisterModuleInterface<M>(M mod); 120 void RegisterModuleInterface<M>(M mod);
121 121
122 void StackModuleInterface<M>(M mod); 122 void StackModuleInterface<M>(M mod);
123 123
124 /// <summary> 124 /// <summary>
diff --git a/OpenSim/Framework/ISceneAgent.cs b/OpenSim/Framework/ISceneAgent.cs
index ca1399c..5d70b83 100644
--- a/OpenSim/Framework/ISceneAgent.cs
+++ b/OpenSim/Framework/ISceneAgent.cs
@@ -55,6 +55,10 @@ namespace OpenSim.Framework
55 /// </summary> 55 /// </summary>
56 bool IsChildAgent { get; } 56 bool IsChildAgent { get; }
57 57
58 bool IsInTransit { get; }
59 bool IsNPC { get;}
60
61 bool Invulnerable { get; set; }
58 /// <summary> 62 /// <summary>
59 /// Avatar appearance data. 63 /// Avatar appearance data.
60 /// </summary> 64 /// </summary>
@@ -66,22 +70,17 @@ namespace OpenSim.Framework
66 AvatarAppearance Appearance { get; set; } 70 AvatarAppearance Appearance { get; set; }
67 71
68 /// <summary> 72 /// <summary>
69 /// Set if initial data about the scene (avatars, objects) has been sent to the client.
70 /// </summary>
71 bool SentInitialDataToClient { get; }
72
73 /// <summary>
74 /// Send initial scene data to the client controlling this agent 73 /// Send initial scene data to the client controlling this agent
75 /// </summary> 74 /// </summary>
76 /// <remarks> 75 /// <remarks>
77 /// This includes scene object data and the appearance data of other avatars. 76 /// This includes scene object data and the appearance data of other avatars.
78 /// </remarks> 77 /// </remarks>
79 void SendInitialDataToClient(); 78 void SendInitialDataToMe();
80 79
81 /// <summary> 80 /// <summary>
82 /// Direction in which the scene presence is looking. 81 /// Direction in which the scene presence is looking.
83 /// </summary> 82 /// </summary>
84 /// <remarks>Will be Vector3.Zero for a child agent.</remarks> 83 /// <remarks>Will be Vector3.Zero for a child agent.</remarks>
85 Vector3 Lookat { get; } 84 Vector3 Lookat { get; }
86 } 85 }
87} \ No newline at end of file 86}
diff --git a/OpenSim/Framework/InventoryFolderImpl.cs b/OpenSim/Framework/InventoryFolderImpl.cs
index 139776b..d14f3be 100644
--- a/OpenSim/Framework/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/InventoryFolderImpl.cs
@@ -314,7 +314,7 @@ namespace OpenSim.Framework
314 /// XPath like expression 314 /// XPath like expression
315 /// 315 ///
316 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 316 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
317 /// 317 ///
318 /// <param name="path"> 318 /// <param name="path">
319 /// The path to the required folder. 319 /// The path to the required folder.
320 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. 320 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs
index f9fd752..c359a0c 100644
--- a/OpenSim/Framework/InventoryItemBase.cs
+++ b/OpenSim/Framework/InventoryItemBase.cs
@@ -34,17 +34,17 @@ namespace OpenSim.Framework
34 /// Inventory Item - contains all the properties associated with an individual inventory piece. 34 /// Inventory Item - contains all the properties associated with an individual inventory piece.
35 /// </summary> 35 /// </summary>
36 public class InventoryItemBase : InventoryNodeBase, ICloneable 36 public class InventoryItemBase : InventoryNodeBase, ICloneable
37 { 37 {
38 /// <value> 38 /// <value>
39 /// The inventory type of the item. This is slightly different from the asset type in some situations. 39 /// The inventory type of the item. This is slightly different from the asset type in some situations.
40 /// </value> 40 /// </value>
41 public int InvType 41 public int InvType
42 { 42 {
43 get 43 get
44 { 44 {
45 return m_invType; 45 return m_invType;
46 } 46 }
47 47
48 set 48 set
49 { 49 {
50 m_invType = value; 50 m_invType = value;
@@ -55,13 +55,13 @@ namespace OpenSim.Framework
55 /// <value> 55 /// <value>
56 /// The folder this item is contained in 56 /// The folder this item is contained in
57 /// </value> 57 /// </value>
58 public UUID Folder 58 public UUID Folder
59 { 59 {
60 get 60 get
61 { 61 {
62 return m_folder; 62 return m_folder;
63 } 63 }
64 64
65 set 65 set
66 { 66 {
67 m_folder = value; 67 m_folder = value;
@@ -72,17 +72,17 @@ namespace OpenSim.Framework
72 /// <value> 72 /// <value>
73 /// The creator of this item 73 /// The creator of this item
74 /// </value> 74 /// </value>
75 public string CreatorId 75 public string CreatorId
76 { 76 {
77 get 77 get
78 { 78 {
79 return m_creatorId; 79 return m_creatorId;
80 } 80 }
81 81
82 set 82 set
83 { 83 {
84 m_creatorId = value; 84 m_creatorId = value;
85 85
86 if ((m_creatorId == null) || !UUID.TryParse(m_creatorId, out m_creatorIdAsUuid)) 86 if ((m_creatorId == null) || !UUID.TryParse(m_creatorId, out m_creatorIdAsUuid))
87 m_creatorIdAsUuid = UUID.Zero; 87 m_creatorIdAsUuid = UUID.Zero;
88 } 88 }
@@ -92,7 +92,7 @@ namespace OpenSim.Framework
92 /// <value> 92 /// <value>
93 /// The CreatorId expressed as a UUID. 93 /// The CreatorId expressed as a UUID.
94 /// </value> 94 /// </value>
95 public UUID CreatorIdAsUuid 95 public UUID CreatorIdAsUuid
96 { 96 {
97 get 97 get
98 { 98 {
@@ -161,13 +161,13 @@ namespace OpenSim.Framework
161 /// <value> 161 /// <value>
162 /// The description of the inventory item (must be less than 64 characters) 162 /// The description of the inventory item (must be less than 64 characters)
163 /// </value> 163 /// </value>
164 public string Description 164 public string Description
165 { 165 {
166 get 166 get
167 { 167 {
168 return m_description; 168 return m_description;
169 } 169 }
170 170
171 set 171 set
172 { 172 {
173 m_description = value; 173 m_description = value;
@@ -178,13 +178,13 @@ namespace OpenSim.Framework
178 /// <value> 178 /// <value>
179 /// 179 ///
180 /// </value> 180 /// </value>
181 public uint NextPermissions 181 public uint NextPermissions
182 { 182 {
183 get 183 get
184 { 184 {
185 return m_nextPermissions; 185 return m_nextPermissions;
186 } 186 }
187 187
188 set 188 set
189 { 189 {
190 m_nextPermissions = value; 190 m_nextPermissions = value;
@@ -195,13 +195,13 @@ namespace OpenSim.Framework
195 /// <value> 195 /// <value>
196 /// A mask containing permissions for the current owner (cannot be enforced) 196 /// A mask containing permissions for the current owner (cannot be enforced)
197 /// </value> 197 /// </value>
198 public uint CurrentPermissions 198 public uint CurrentPermissions
199 { 199 {
200 get 200 get
201 { 201 {
202 return m_currentPermissions; 202 return m_currentPermissions;
203 } 203 }
204 204
205 set 205 set
206 { 206 {
207 m_currentPermissions = value; 207 m_currentPermissions = value;
@@ -212,13 +212,13 @@ namespace OpenSim.Framework
212 /// <value> 212 /// <value>
213 /// 213 ///
214 /// </value> 214 /// </value>
215 public uint BasePermissions 215 public uint BasePermissions
216 { 216 {
217 get 217 get
218 { 218 {
219 return m_basePermissions; 219 return m_basePermissions;
220 } 220 }
221 221
222 set 222 set
223 { 223 {
224 m_basePermissions = value; 224 m_basePermissions = value;
@@ -229,13 +229,13 @@ namespace OpenSim.Framework
229 /// <value> 229 /// <value>
230 /// 230 ///
231 /// </value> 231 /// </value>
232 public uint EveryOnePermissions 232 public uint EveryOnePermissions
233 { 233 {
234 get 234 get
235 { 235 {
236 return m_everyonePermissions; 236 return m_everyonePermissions;
237 } 237 }
238 238
239 set 239 set
240 { 240 {
241 m_everyonePermissions = value; 241 m_everyonePermissions = value;
@@ -246,13 +246,13 @@ namespace OpenSim.Framework
246 /// <value> 246 /// <value>
247 /// 247 ///
248 /// </value> 248 /// </value>
249 public uint GroupPermissions 249 public uint GroupPermissions
250 { 250 {
251 get 251 get
252 { 252 {
253 return m_groupPermissions; 253 return m_groupPermissions;
254 } 254 }
255 255
256 set 256 set
257 { 257 {
258 m_groupPermissions = value; 258 m_groupPermissions = value;
@@ -263,13 +263,13 @@ namespace OpenSim.Framework
263 /// <value> 263 /// <value>
264 /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc) 264 /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc)
265 /// </value> 265 /// </value>
266 public int AssetType 266 public int AssetType
267 { 267 {
268 get 268 get
269 { 269 {
270 return m_assetType; 270 return m_assetType;
271 } 271 }
272 272
273 set 273 set
274 { 274 {
275 m_assetType = value; 275 m_assetType = value;
@@ -280,13 +280,13 @@ namespace OpenSim.Framework
280 /// <value> 280 /// <value>
281 /// The UUID of the associated asset on the asset server 281 /// The UUID of the associated asset on the asset server
282 /// </value> 282 /// </value>
283 public UUID AssetID 283 public UUID AssetID
284 { 284 {
285 get 285 get
286 { 286 {
287 return m_assetID; 287 return m_assetID;
288 } 288 }
289 289
290 set 290 set
291 { 291 {
292 m_assetID = value; 292 m_assetID = value;
@@ -297,13 +297,13 @@ namespace OpenSim.Framework
297 /// <value> 297 /// <value>
298 /// 298 ///
299 /// </value> 299 /// </value>
300 public UUID GroupID 300 public UUID GroupID
301 { 301 {
302 get 302 get
303 { 303 {
304 return m_groupID; 304 return m_groupID;
305 } 305 }
306 306
307 set 307 set
308 { 308 {
309 m_groupID = value; 309 m_groupID = value;
@@ -314,13 +314,13 @@ namespace OpenSim.Framework
314 /// <value> 314 /// <value>
315 /// 315 ///
316 /// </value> 316 /// </value>
317 public bool GroupOwned 317 public bool GroupOwned
318 { 318 {
319 get 319 get
320 { 320 {
321 return m_groupOwned; 321 return m_groupOwned;
322 } 322 }
323 323
324 set 324 set
325 { 325 {
326 m_groupOwned = value; 326 m_groupOwned = value;
@@ -331,13 +331,13 @@ namespace OpenSim.Framework
331 /// <value> 331 /// <value>
332 /// 332 ///
333 /// </value> 333 /// </value>
334 public int SalePrice 334 public int SalePrice
335 { 335 {
336 get 336 get
337 { 337 {
338 return m_salePrice; 338 return m_salePrice;
339 } 339 }
340 340
341 set 341 set
342 { 342 {
343 m_salePrice = value; 343 m_salePrice = value;
@@ -348,13 +348,13 @@ namespace OpenSim.Framework
348 /// <value> 348 /// <value>
349 /// 349 ///
350 /// </value> 350 /// </value>
351 public byte SaleType 351 public byte SaleType
352 { 352 {
353 get 353 get
354 { 354 {
355 return m_saleType; 355 return m_saleType;
356 } 356 }
357 357
358 set 358 set
359 { 359 {
360 m_saleType = value; 360 m_saleType = value;
@@ -365,13 +365,13 @@ namespace OpenSim.Framework
365 /// <value> 365 /// <value>
366 /// 366 ///
367 /// </value> 367 /// </value>
368 public uint Flags 368 public uint Flags
369 { 369 {
370 get 370 get
371 { 371 {
372 return m_flags; 372 return m_flags;
373 } 373 }
374 374
375 set 375 set
376 { 376 {
377 m_flags = value; 377 m_flags = value;
@@ -382,13 +382,13 @@ namespace OpenSim.Framework
382 /// <value> 382 /// <value>
383 /// 383 ///
384 /// </value> 384 /// </value>
385 public int CreationDate 385 public int CreationDate
386 { 386 {
387 get 387 get
388 { 388 {
389 return m_creationDate; 389 return m_creationDate;
390 } 390 }
391 391
392 set 392 set
393 { 393 {
394 m_creationDate = value; 394 m_creationDate = value;
diff --git a/OpenSim/Framework/InventoryNodeBase.cs b/OpenSim/Framework/InventoryNodeBase.cs
index 31c3fd1..9ef36b7 100644
--- a/OpenSim/Framework/InventoryNodeBase.cs
+++ b/OpenSim/Framework/InventoryNodeBase.cs
@@ -41,19 +41,19 @@ namespace OpenSim.Framework
41 { 41 {
42 get { return m_name; } 42 get { return m_name; }
43 set { m_name = value; } 43 set { m_name = value; }
44 } 44 }
45 private string m_name = string.Empty; 45 private string m_name = string.Empty;
46 46
47 /// <summary> 47 /// <summary>
48 /// A UUID containing the ID for the inventory node itself 48 /// A UUID containing the ID for the inventory node itself
49 /// </summary> 49 /// </summary>
50 public UUID ID 50 public UUID ID
51 { 51 {
52 get { return m_id; } 52 get { return m_id; }
53 set { m_id = value; } 53 set { m_id = value; }
54 } 54 }
55 private UUID m_id; 55 private UUID m_id;
56 56
57 /// <summary> 57 /// <summary>
58 /// The agent who's inventory this is contained by 58 /// The agent who's inventory this is contained by
59 /// </summary> 59 /// </summary>
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs
index fc02f33..13b58be 100644
--- a/OpenSim/Framework/LandData.cs
+++ b/OpenSim/Framework/LandData.cs
@@ -67,11 +67,11 @@ namespace OpenSim.Framework
67 67
68 private uint _flags = (uint)ParcelFlags.AllowFly | (uint)ParcelFlags.AllowLandmark | 68 private uint _flags = (uint)ParcelFlags.AllowFly | (uint)ParcelFlags.AllowLandmark |
69 (uint)ParcelFlags.AllowAPrimitiveEntry | 69 (uint)ParcelFlags.AllowAPrimitiveEntry |
70 (uint)ParcelFlags.AllowDeedToGroup | (uint)ParcelFlags.AllowTerraform | 70 (uint)ParcelFlags.AllowDeedToGroup |
71 (uint)ParcelFlags.CreateObjects | (uint)ParcelFlags.AllowOtherScripts | 71 (uint)ParcelFlags.CreateObjects | (uint)ParcelFlags.AllowOtherScripts |
72 (uint)ParcelFlags.SoundLocal | (uint)ParcelFlags.AllowVoiceChat; 72 (uint)ParcelFlags.AllowVoiceChat;
73 73
74 private byte _landingType = 0; 74 private byte _landingType = (byte)OpenMetaverse.LandingType.Direct;
75 private string _name = "Your Parcel"; 75 private string _name = "Your Parcel";
76 private ParcelStatus _status = ParcelStatus.Leased; 76 private ParcelStatus _status = ParcelStatus.Leased;
77 private int _localID = 0; 77 private int _localID = 0;
@@ -97,7 +97,13 @@ namespace OpenSim.Framework
97 private bool _mediaLoop = false; 97 private bool _mediaLoop = false;
98 private bool _obscureMusic = false; 98 private bool _obscureMusic = false;
99 private bool _obscureMedia = false; 99 private bool _obscureMedia = false;
100 private float _dwell = 0; 100
101 private float m_dwell = 0;
102 public double LastDwellTimeMS;
103
104 public bool SeeAVs { get; set; }
105 public bool AnyAVSounds { get; set; }
106 public bool GroupAVSounds { get; set; }
101 107
102 /// <summary> 108 /// <summary>
103 /// Traffic count of parcel 109 /// Traffic count of parcel
@@ -107,11 +113,12 @@ namespace OpenSim.Framework
107 { 113 {
108 get 114 get
109 { 115 {
110 return _dwell; 116 return m_dwell;
111 } 117 }
112 set 118 set
113 { 119 {
114 _dwell = value; 120 m_dwell = value;
121 LastDwellTimeMS = Util.GetTimeStampMS();
115 } 122 }
116 } 123 }
117 124
@@ -407,7 +414,7 @@ namespace OpenSim.Framework
407 } 414 }
408 415
409 /// <summary> 416 /// <summary>
410 /// Determines if people are able to teleport where they please on the parcel or if they 417 /// Determines if people are able to teleport where they please on the parcel or if they
411 /// get constrainted to a specific point on teleport within the parcel 418 /// get constrainted to a specific point on teleport within the parcel
412 /// </summary> 419 /// </summary>
413 public byte LandingType 420 public byte LandingType
@@ -616,7 +623,7 @@ namespace OpenSim.Framework
616 } 623 }
617 624
618 /// <summary> 625 /// <summary>
619 /// Number of meters^2 in the Simulator 626 /// Number of meters^2 that the land owner has in the Simulator
620 /// </summary> 627 /// </summary>
621 [XmlIgnore] 628 [XmlIgnore]
622 public int SimwideArea 629 public int SimwideArea
@@ -663,7 +670,7 @@ namespace OpenSim.Framework
663 } 670 }
664 671
665 /// <summary> 672 /// <summary>
666 /// When teleporting is restricted to a certain point, this is the location 673 /// When teleporting is restricted to a certain point, this is the location
667 /// that the user will be redirected to 674 /// that the user will be redirected to
668 /// </summary> 675 /// </summary>
669 public Vector3 UserLocation 676 public Vector3 UserLocation
@@ -679,7 +686,7 @@ namespace OpenSim.Framework
679 } 686 }
680 687
681 /// <summary> 688 /// <summary>
682 /// When teleporting is restricted to a certain point, this is the rotation 689 /// When teleporting is restricted to a certain point, this is the rotation
683 /// that the user will be positioned 690 /// that the user will be positioned
684 /// </summary> 691 /// </summary>
685 public Vector3 UserLookAt 692 public Vector3 UserLookAt
@@ -695,7 +702,7 @@ namespace OpenSim.Framework
695 } 702 }
696 703
697 /// <summary> 704 /// <summary>
698 /// Autoreturn number of minutes to return SceneObjectGroup that are owned by someone who doesn't own 705 /// Autoreturn number of minutes to return SceneObjectGroup that are owned by someone who doesn't own
699 /// the parcel and isn't set to the same 'group' as the parcel. 706 /// the parcel and isn't set to the same 'group' as the parcel.
700 /// </summary> 707 /// </summary>
701 public int OtherCleanTime 708 public int OtherCleanTime
@@ -728,6 +735,10 @@ namespace OpenSim.Framework
728 public LandData() 735 public LandData()
729 { 736 {
730 _globalID = UUID.Random(); 737 _globalID = UUID.Random();
738 SeeAVs = true;
739 AnyAVSounds = true;
740 GroupAVSounds = true;
741 LastDwellTimeMS = Util.GetTimeStampMS();
731 } 742 }
732 743
733 /// <summary> 744 /// <summary>
@@ -777,7 +788,10 @@ namespace OpenSim.Framework
777 landData._obscureMedia = _obscureMedia; 788 landData._obscureMedia = _obscureMedia;
778 landData._simwideArea = _simwideArea; 789 landData._simwideArea = _simwideArea;
779 landData._simwidePrims = _simwidePrims; 790 landData._simwidePrims = _simwidePrims;
780 landData._dwell = _dwell; 791 landData.m_dwell = m_dwell;
792 landData.SeeAVs = SeeAVs;
793 landData.AnyAVSounds = AnyAVSounds;
794 landData.GroupAVSounds = GroupAVSounds;
781 795
782 landData._parcelAccessList.Clear(); 796 landData._parcelAccessList.Clear();
783 foreach (LandAccessEntry entry in _parcelAccessList) 797 foreach (LandAccessEntry entry in _parcelAccessList)
@@ -793,21 +807,21 @@ namespace OpenSim.Framework
793 return landData; 807 return landData;
794 } 808 }
795 809
796 public void ToXml(XmlWriter xmlWriter) 810// public void ToXml(XmlWriter xmlWriter)
797 { 811// {
798 serializer.Serialize(xmlWriter, this); 812// serializer.Serialize(xmlWriter, this);
799 } 813// }
800 814
801 /// <summary> 815 /// <summary>
802 /// Restore a LandData object from the serialized xml representation. 816 /// Restore a LandData object from the serialized xml representation.
803 /// </summary> 817 /// </summary>
804 /// <param name="xmlReader"></param> 818 /// <param name="xmlReader"></param>
805 /// <returns></returns> 819 /// <returns></returns>
806 public static LandData FromXml(XmlReader xmlReader) 820// public static LandData FromXml(XmlReader xmlReader)
807 { 821// {
808 LandData land = (LandData)serializer.Deserialize(xmlReader); 822// LandData land = (LandData)serializer.Deserialize(xmlReader);
809 823//
810 return land; 824// return land;
811 } 825// }
812 } 826 }
813} 827}
diff --git a/OpenSim/Framework/LandUpdateArgs.cs b/OpenSim/Framework/LandUpdateArgs.cs
index 7d6c4f2..a48b8bf 100644
--- a/OpenSim/Framework/LandUpdateArgs.cs
+++ b/OpenSim/Framework/LandUpdateArgs.cs
@@ -56,5 +56,8 @@ namespace OpenSim.Framework
56 public bool MediaLoop; 56 public bool MediaLoop;
57 public bool ObscureMusic; 57 public bool ObscureMusic;
58 public bool ObscureMedia; 58 public bool ObscureMedia;
59 public bool SeeAVs;
60 public bool AnyAVSounds;
61 public bool GroupAVSounds;
59 } 62 }
60} 63}
diff --git a/OpenSim/Framework/Lazy.cs b/OpenSim/Framework/Lazy.cs
index 91de4bd..ea07d0e 100644
--- a/OpenSim/Framework/Lazy.cs
+++ b/OpenSim/Framework/Lazy.cs
@@ -14,10 +14,10 @@
14// distribute, sublicense, and/or sell copies of the Software, and to 14// distribute, sublicense, and/or sell copies of the Software, and to
15// permit persons to whom the Software is furnished to do so, subject to 15// permit persons to whom the Software is furnished to do so, subject to
16// the following conditions: 16// the following conditions:
17// 17//
18// The above copyright notice and this permission notice shall be 18// The above copyright notice and this permission notice shall be
19// included in all copies or substantial portions of the Software. 19// included in all copies or substantial portions of the Software.
20// 20//
21// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
diff --git a/OpenSim/Framework/LocklessQueue.cs b/OpenSim/Framework/LocklessQueue.cs
index 84f887c..21b8178 100644
--- a/OpenSim/Framework/LocklessQueue.cs
+++ b/OpenSim/Framework/LocklessQueue.cs
@@ -29,7 +29,7 @@ using System.Threading;
29 29
30namespace OpenSim.Framework 30namespace OpenSim.Framework
31{ 31{
32 public sealed class LocklessQueue<T> 32 public class LocklessQueue<T>
33 { 33 {
34 private sealed class SingleLinkNode 34 private sealed class SingleLinkNode
35 { 35 {
@@ -41,7 +41,7 @@ namespace OpenSim.Framework
41 SingleLinkNode tail; 41 SingleLinkNode tail;
42 int count; 42 int count;
43 43
44 public int Count { get { return count; } } 44 public virtual int Count { get { return count; } }
45 45
46 public LocklessQueue() 46 public LocklessQueue()
47 { 47 {
@@ -76,7 +76,7 @@ namespace OpenSim.Framework
76 Interlocked.Increment(ref count); 76 Interlocked.Increment(ref count);
77 } 77 }
78 78
79 public bool Dequeue(out T item) 79 public virtual bool Dequeue(out T item)
80 { 80 {
81 item = default(T); 81 item = default(T);
82 SingleLinkNode oldHead = null; 82 SingleLinkNode oldHead = null;
@@ -93,13 +93,16 @@ namespace OpenSim.Framework
93 if (oldHead == oldTail) 93 if (oldHead == oldTail)
94 { 94 {
95 if (oldHeadNext == null) 95 if (oldHeadNext == null)
96 {
97 count = 0;
96 return false; 98 return false;
99 }
97 100
98 CAS(ref tail, oldTail, oldHeadNext); 101 CAS(ref tail, oldTail, oldHeadNext);
99 } 102 }
100 else 103 else
101 { 104 {
102 item = oldHeadNext.Item; 105 item = oldHeadNext.Item;
103 haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext); 106 haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext);
104 if (haveAdvancedHead) 107 if (haveAdvancedHead)
105 { 108 {
@@ -118,8 +121,7 @@ namespace OpenSim.Framework
118 { 121 {
119 // ugly 122 // ugly
120 T item; 123 T item;
121 while(count > 0) 124 while(Dequeue(out item));
122 Dequeue(out item);
123 Init(); 125 Init();
124 } 126 }
125 127
@@ -136,4 +138,4 @@ namespace OpenSim.Framework
136 (object)Interlocked.CompareExchange<SingleLinkNode>(ref location, newValue, comparand); 138 (object)Interlocked.CompareExchange<SingleLinkNode>(ref location, newValue, comparand);
137 } 139 }
138 } 140 }
139} \ No newline at end of file 141}
diff --git a/OpenSim/Framework/LogWriter.cs b/OpenSim/Framework/LogWriter.cs
index 2e0bf4a..2e0bf4a 100644..100755
--- a/OpenSim/Framework/LogWriter.cs
+++ b/OpenSim/Framework/LogWriter.cs
diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs
index c98d3cc..32d6978 100644
--- a/OpenSim/Framework/MapAndArray.cs
+++ b/OpenSim/Framework/MapAndArray.cs
@@ -45,9 +45,9 @@ namespace OpenSim.Framework
45 45
46 /// <summary>Number of values currently stored in the collection</summary> 46 /// <summary>Number of values currently stored in the collection</summary>
47 public int Count { get { return m_array.Length; } } 47 public int Count { get { return m_array.Length; } }
48 /// <summary>NOTE: This collection is thread safe. You do not need to 48 /// <summary>NOTE: This collection is thread safe. You do not need to
49 /// acquire a lock to add, remove, or enumerate entries. This 49 /// acquire a lock to add, remove, or enumerate entries. This
50 /// synchronization object should only be locked for larger 50 /// synchronization object should only be locked for larger
51 /// transactions</summary> 51 /// transactions</summary>
52 public object SyncRoot { get { return m_syncRoot; } } 52 public object SyncRoot { get { return m_syncRoot; } }
53 53
@@ -92,7 +92,7 @@ namespace OpenSim.Framework
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
95 /// Adds a key/value pair to the collection. This will throw an 95 /// Adds a key/value pair to the collection. This will throw an
96 /// exception if the key is already present in the collection 96 /// exception if the key is already present in the collection
97 /// </summary> 97 /// </summary>
98 /// <param name="key">Key to add or update</param> 98 /// <param name="key">Key to add or update</param>
@@ -166,7 +166,7 @@ namespace OpenSim.Framework
166 /// Gets a reference to the immutable array of values stored in this 166 /// Gets a reference to the immutable array of values stored in this
167 /// collection. This array is thread safe for iteration 167 /// collection. This array is thread safe for iteration
168 /// </summary> 168 /// </summary>
169 /// <returns>A thread safe reference ton an array of all of the stored 169 /// <returns>A thread safe reference ton an array of all of the stored
170 /// values</returns> 170 /// values</returns>
171 public TValue[] GetArray() 171 public TValue[] GetArray()
172 { 172 {
@@ -175,7 +175,7 @@ namespace OpenSim.Framework
175 175
176 private void CreateArray() 176 private void CreateArray()
177 { 177 {
178 // Rebuild the array from the dictionary. This method must be 178 // Rebuild the array from the dictionary. This method must be
179 // called from inside a lock 179 // called from inside a lock
180 TValue[] array = new TValue[m_dict.Count]; 180 TValue[] array = new TValue[m_dict.Count];
181 int i = 0; 181 int i = 0;
diff --git a/OpenSim/Framework/MapItemReplyStruct.cs b/OpenSim/Framework/MapItemReplyStruct.cs
index c8693ae..348a240 100644
--- a/OpenSim/Framework/MapItemReplyStruct.cs
+++ b/OpenSim/Framework/MapItemReplyStruct.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Framework
60 map["Extra2"] = OSD.FromInteger(Extra2); 60 map["Extra2"] = OSD.FromInteger(Extra2);
61 return map; 61 return map;
62 } 62 }
63 63
64 public void FromOSD(OSDMap map) 64 public void FromOSD(OSDMap map)
65 { 65 {
66 x = (uint) map["X"].AsInteger(); 66 x = (uint) map["X"].AsInteger();
diff --git a/OpenSim/Framework/MetricsCollector.cs b/OpenSim/Framework/MetricsCollector.cs
index c8f4a33..391f57e 100644
--- a/OpenSim/Framework/MetricsCollector.cs
+++ b/OpenSim/Framework/MetricsCollector.cs
@@ -42,23 +42,23 @@ namespace OpenSim.Framework
42 } 42 }
43 } 43 }
44 44
45 45
46 struct MetricsBucket<T> 46 struct MetricsBucket<T>
47 { 47 {
48 public T value; 48 public T value;
49 public int count; 49 public int count;
50 } 50 }
51 51
52 52
53 /// <summary> 53 /// <summary>
54 /// Collects metrics in a sliding window. 54 /// Collects metrics in a sliding window.
55 /// </summary> 55 /// </summary>
56 /// <remarks> 56 /// <remarks>
57 /// MetricsCollector provides the current Sum of the metrics that it collects. It can easily be extended 57 /// MetricsCollector provides the current Sum of the metrics that it collects. It can easily be extended
58 /// to provide the Average, too. It uses a sliding window to keep these values current. 58 /// to provide the Average, too. It uses a sliding window to keep these values current.
59 /// 59 ///
60 /// This class is not thread-safe. 60 /// This class is not thread-safe.
61 /// 61 ///
62 /// Subclass MetricsCollector to have it use a concrete value type. Override the abstract methods. 62 /// Subclass MetricsCollector to have it use a concrete value type. Override the abstract methods.
63 /// </remarks> 63 /// </remarks>
64 public abstract class MetricsCollector<T> 64 public abstract class MetricsCollector<T>
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
index 20495f6..e513abd 100644
--- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
@@ -43,7 +43,6 @@ namespace OpenSim.Framework.Monitoring
43 StringBuilder sb = new StringBuilder(Environment.NewLine); 43 StringBuilder sb = new StringBuilder(Environment.NewLine);
44 sb.Append("MEMORY STATISTICS"); 44 sb.Append("MEMORY STATISTICS");
45 sb.Append(Environment.NewLine); 45 sb.Append(Environment.NewLine);
46
47 sb.AppendFormat( 46 sb.AppendFormat(
48 "Heap allocated to OpenSim : {0} MB\n", 47 "Heap allocated to OpenSim : {0} MB\n",
49 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); 48 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
@@ -56,13 +55,30 @@ namespace OpenSim.Framework.Monitoring
56 "Average heap allocation rate: {0} MB/s\n", 55 "Average heap allocation rate: {0} MB/s\n",
57 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); 56 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3));
58 57
59 sb.AppendFormat( 58 Process myprocess = Process.GetCurrentProcess();
60 "Process memory : {0} MB\n", 59// if (!myprocess.HasExited)
61 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0)); 60 try
61 {
62 myprocess.Refresh();
63 sb.AppendFormat(
64 "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
65 Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0),
66 Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0),
67 Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0));
68 sb.AppendFormat(
69 "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
70 Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0),
71 Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0),
72 Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0));
73 }
74 catch
75 { }
76// else
77// sb.Append("Process reported as Exited \n");
62 78
63 return sb.ToString(); 79 return sb.ToString();
64 } 80 }
65 81
66 public virtual string XReport(string uptime, string version) 82 public virtual string XReport(string uptime, string version)
67 { 83 {
68 return (string) Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0).ToString() ; 84 return (string) Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0).ToString() ;
diff --git a/OpenSim/Framework/Monitoring/Checks/Check.cs b/OpenSim/Framework/Monitoring/Checks/Check.cs
index 594386a..9a1bd45 100644
--- a/OpenSim/Framework/Monitoring/Checks/Check.cs
+++ b/OpenSim/Framework/Monitoring/Checks/Check.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Framework.Monitoring
79 string category, 79 string category,
80 string container, 80 string container,
81 Func<Check, bool> checkFunc, 81 Func<Check, bool> checkFunc,
82 StatVerbosity verbosity) 82 StatVerbosity verbosity)
83 { 83 {
84 if (ChecksManager.SubCommands.Contains(category)) 84 if (ChecksManager.SubCommands.Contains(category))
85 throw new Exception( 85 throw new Exception(
@@ -108,9 +108,9 @@ namespace OpenSim.Framework.Monitoring
108 public virtual string ToConsoleString() 108 public virtual string ToConsoleString()
109 { 109 {
110 return string.Format( 110 return string.Format(
111 "{0}.{1}.{2} - {3}", 111 "{0}.{1}.{2} - {3}",
112 Category, 112 Category,
113 Container, 113 Container,
114 ShortName, 114 ShortName,
115 Description); 115 Description);
116 } 116 }
diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs
index e4a7f8c..ff3b041 100644
--- a/OpenSim/Framework/Monitoring/ChecksManager.cs
+++ b/OpenSim/Framework/Monitoring/ChecksManager.cs
@@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring
132 /// <returns></returns> 132 /// <returns></returns>
133 public static bool RegisterCheck(Check check) 133 public static bool RegisterCheck(Check check)
134 { 134 {
135 SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; 135 SortedDictionary<string, SortedDictionary<string, Check>> category = null;
136 SortedDictionary<string, Check> container = null, newContainer; 136 SortedDictionary<string, Check> container = null;
137 137
138 lock (RegisteredChecks) 138 lock (RegisteredChecks)
139 { 139 {
@@ -146,19 +146,15 @@ namespace OpenSim.Framework.Monitoring
146 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. 146 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
147 // This means that we don't need to lock or copy them on iteration, which will be a much more 147 // This means that we don't need to lock or copy them on iteration, which will be a much more
148 // common operation after startup. 148 // common operation after startup.
149 if (container != null) 149 if (container == null)
150 newContainer = new SortedDictionary<string, Check>(container); 150 container = new SortedDictionary<string, Check>();
151 else
152 newContainer = new SortedDictionary<string, Check>();
153 151
154 if (category != null) 152 if (category == null)
155 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); 153 category = new SortedDictionary<string, SortedDictionary<string, Check>>();
156 else
157 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>();
158 154
159 newContainer[check.ShortName] = check; 155 container[check.ShortName] = check;
160 newCategory[check.Container] = newContainer; 156 category[check.Container] = container;
161 RegisteredChecks[check.Category] = newCategory; 157 RegisteredChecks[check.Category] = category;
162 } 158 }
163 159
164 return true; 160 return true;
@@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring
171 /// <returns></returns> 167 /// <returns></returns>
172 public static bool DeregisterCheck(Check check) 168 public static bool DeregisterCheck(Check check)
173 { 169 {
174 SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; 170 SortedDictionary<string, SortedDictionary<string, Check>> category = null;
175 SortedDictionary<string, Check> container = null, newContainer; 171 SortedDictionary<string, Check> container = null;
176 172
177 lock (RegisteredChecks) 173 lock (RegisteredChecks)
178 { 174 {
179 if (!TryGetCheckParents(check, out category, out container)) 175 if (!TryGetCheckParents(check, out category, out container))
180 return false; 176 return false;
181 177
182 newContainer = new SortedDictionary<string, Check>(container); 178 if(container != null)
183 newContainer.Remove(check.ShortName); 179 {
184 180 container.Remove(check.ShortName);
185 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); 181 if(category != null && container.Count == 0)
186 newCategory.Remove(check.Container); 182 {
187 183 category.Remove(check.Container);
188 newCategory[check.Container] = newContainer; 184 if(category.Count == 0)
189 RegisteredChecks[check.Category] = newCategory; 185 RegisteredChecks.Remove(check.Category);
190 186 }
187 }
191 return true; 188 return true;
192 } 189 }
193 } 190 }
diff --git a/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs b/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs
index 40df562..e326e8b 100644
--- a/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring
39 /// </summary> 39 /// </summary>
40 /// <returns></returns> 40 /// <returns></returns>
41 string Report(); 41 string Report();
42 42
43 /// <summary> 43 /// <summary>
44 /// Report back collected statistical information in json 44 /// Report back collected statistical information in json
45 /// </summary> 45 /// </summary>
diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs
index 6db9a67..115871e 100644
--- a/OpenSim/Framework/Monitoring/JobEngine.cs
+++ b/OpenSim/Framework/Monitoring/JobEngine.cs
@@ -40,6 +40,8 @@ namespace OpenSim.Framework.Monitoring
40 40
41 public int LogLevel { get; set; } 41 public int LogLevel { get; set; }
42 42
43 private object JobLock = new object();
44
43 public string Name { get; private set; } 45 public string Name { get; private set; }
44 46
45 public string LoggingName { get; private set; } 47 public string LoggingName { get; private set; }
@@ -47,7 +49,7 @@ namespace OpenSim.Framework.Monitoring
47 /// <summary> 49 /// <summary>
48 /// Is this engine running? 50 /// Is this engine running?
49 /// </summary> 51 /// </summary>
50 public bool IsRunning { get; private set; } 52 public bool IsRunning { get; private set; }
51 53
52 /// <summary> 54 /// <summary>
53 /// The current job that the engine is running. 55 /// The current job that the engine is running.
@@ -55,7 +57,8 @@ namespace OpenSim.Framework.Monitoring
55 /// <remarks> 57 /// <remarks>
56 /// Will be null if no job is currently running. 58 /// Will be null if no job is currently running.
57 /// </remarks> 59 /// </remarks>
58 public Job CurrentJob { get; private set; } 60 private Job m_currentJob;
61 public Job CurrentJob { get { return m_currentJob;} }
59 62
60 /// <summary> 63 /// <summary>
61 /// Number of jobs waiting to be processed. 64 /// Number of jobs waiting to be processed.
@@ -71,96 +74,64 @@ namespace OpenSim.Framework.Monitoring
71 /// Controls whether we need to warn in the log about exceeding the max queue size. 74 /// Controls whether we need to warn in the log about exceeding the max queue size.
72 /// </summary> 75 /// </summary>
73 /// <remarks> 76 /// <remarks>
74 /// This is flipped to false once queue max has been exceeded and back to true when it falls below max, in 77 /// This is flipped to false once queue max has been exceeded and back to true when it falls below max, in
75 /// order to avoid spamming the log with lots of warnings. 78 /// order to avoid spamming the log with lots of warnings.
76 /// </remarks> 79 /// </remarks>
77 private bool m_warnOverMaxQueue = true; 80 private bool m_warnOverMaxQueue = true;
78 81
79 private BlockingCollection<Job> m_jobQueue; 82 private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000);
80 83
81 private CancellationTokenSource m_cancelSource; 84 private CancellationTokenSource m_cancelSource;
82 85
83 /// <summary> 86 private int m_timeout = -1;
84 /// Used to signal that we are ready to complete stop.
85 /// </summary>
86 private ManualResetEvent m_finishedProcessingAfterStop = new ManualResetEvent(false);
87 87
88 public JobEngine(string name, string loggingName) 88 private bool m_threadRunnig = false;
89
90 public JobEngine(string name, string loggingName, int timeout = -1)
89 { 91 {
90 Name = name; 92 Name = name;
91 LoggingName = loggingName; 93 LoggingName = loggingName;
92 94 m_timeout = timeout;
93 RequestProcessTimeoutOnStop = 5000; 95 RequestProcessTimeoutOnStop = 5000;
94 } 96 }
95 97
96 public void Start() 98 public void Start()
97 { 99 {
98 lock (this) 100 lock (JobLock)
99 { 101 {
100 if (IsRunning) 102 if (IsRunning)
101 return; 103 return;
102 104
103 IsRunning = true; 105 IsRunning = true;
104 106
105 m_finishedProcessingAfterStop.Reset();
106
107 m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000);
108 m_cancelSource = new CancellationTokenSource(); 107 m_cancelSource = new CancellationTokenSource();
109 108 WorkManager.RunInThreadPool(ProcessRequests, null, Name, false);
110 WorkManager.StartThread( 109 m_threadRunnig = true;
111 ProcessRequests,
112 Name,
113 ThreadPriority.Normal,
114 false,
115 true,
116 null,
117 int.MaxValue);
118 } 110 }
119 } 111 }
120 112
121 public void Stop() 113 public void Stop()
122 { 114 {
123 lock (this) 115 lock (JobLock)
124 { 116 {
125 try 117 try
126 { 118 {
127 if (!IsRunning) 119 if (!IsRunning)
128 return; 120 return;
129 121
130 IsRunning = false; 122 m_log.DebugFormat("[JobEngine] Stopping {0}", Name);
131 123
132 int requestsLeft = m_jobQueue.Count; 124 IsRunning = false;
133 125 if(m_threadRunnig)
134 if (requestsLeft <= 0)
135 { 126 {
136 m_cancelSource.Cancel(); 127 m_cancelSource.Cancel();
137 } 128 m_threadRunnig = false;
138 else
139 {
140 m_log.InfoFormat("[{0}]: Waiting to write {1} events after stop.", LoggingName, requestsLeft);
141
142 while (requestsLeft > 0)
143 {
144 if (!m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop))
145 {
146 // After timeout no events have been written
147 if (requestsLeft == m_jobQueue.Count)
148 {
149 m_log.WarnFormat(
150 "[{0}]: No requests processed after {1} ms wait. Discarding remaining {2} requests",
151 LoggingName, RequestProcessTimeoutOnStop, requestsLeft);
152
153 break;
154 }
155 }
156
157 requestsLeft = m_jobQueue.Count;
158 }
159 } 129 }
160 } 130 }
161 finally 131 finally
162 { 132 {
163 m_cancelSource.Dispose(); 133 if(m_cancelSource != null)
134 m_cancelSource.Dispose();
164 } 135 }
165 } 136 }
166 } 137 }
@@ -169,7 +140,7 @@ namespace OpenSim.Framework.Monitoring
169 /// Make a job. 140 /// Make a job.
170 /// </summary> 141 /// </summary>
171 /// <remarks> 142 /// <remarks>
172 /// We provide this method to replace the constructor so that we can later pool job objects if necessary to 143 /// We provide this method to replace the constructor so that we can later pool job objects if necessary to
173 /// reduce memory churn. Normally one would directly call QueueJob() with parameters anyway. 144 /// reduce memory churn. Normally one would directly call QueueJob() with parameters anyway.
174 /// </remarks> 145 /// </remarks>
175 /// <returns></returns> 146 /// <returns></returns>
@@ -219,6 +190,18 @@ namespace OpenSim.Framework.Monitoring
219 /// </param> 190 /// </param>
220 public bool QueueJob(Job job) 191 public bool QueueJob(Job job)
221 { 192 {
193 lock(JobLock)
194 {
195 if(!IsRunning)
196 return false;
197
198 if(!m_threadRunnig)
199 {
200 WorkManager.RunInThreadPool(ProcessRequests, null, Name, false);
201 m_threadRunnig = true;
202 }
203 }
204
222 if (m_jobQueue.Count < m_jobQueue.BoundedCapacity) 205 if (m_jobQueue.Count < m_jobQueue.BoundedCapacity)
223 { 206 {
224 m_jobQueue.Add(job); 207 m_jobQueue.Add(job);
@@ -238,56 +221,53 @@ namespace OpenSim.Framework.Monitoring
238 221
239 m_warnOverMaxQueue = false; 222 m_warnOverMaxQueue = false;
240 } 223 }
241
242 return false; 224 return false;
243 } 225 }
244 } 226 }
245 227
246 private void ProcessRequests() 228 private void ProcessRequests(Object o)
247 { 229 {
248 try 230 while(IsRunning)
249 { 231 {
250 while (IsRunning || m_jobQueue.Count > 0) 232 try
251 { 233 {
252 try 234 if(!m_jobQueue.TryTake(out m_currentJob, m_timeout, m_cancelSource.Token))
253 { 235 {
254 CurrentJob = m_jobQueue.Take(m_cancelSource.Token); 236 lock(JobLock)
255 } 237 m_threadRunnig = false;
256 catch (ObjectDisposedException e) 238 break;
257 {
258 // If we see this whilst not running then it may be due to a race where this thread checks
259 // IsRunning after the stopping thread sets it to false and disposes of the cancellation source.
260 if (IsRunning)
261 throw e;
262 else
263 break;
264 } 239 }
240 }
241 catch(ObjectDisposedException e)
242 {
243 m_log.DebugFormat("[JobEngine] {0} stopping ignoring {1} jobs in queue",
244 Name,m_jobQueue.Count);
245 break;
246 }
247 catch(OperationCanceledException)
248 {
249 break;
250 }
265 251
266 if (LogLevel >= 1) 252 if(LogLevel >= 1)
267 m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name); 253 m_log.DebugFormat("[{0}]: Processing job {1}",LoggingName,m_currentJob.Name);
268 254
269 try 255 try
270 { 256 {
271 CurrentJob.Action(); 257 m_currentJob.Action();
272 } 258 }
273 catch (Exception e) 259 catch(Exception e)
274 { 260 {
275 m_log.Error( 261 m_log.Error(
276 string.Format( 262 string.Format(
277 "[{0}]: Job {1} failed, continuing. Exception ", LoggingName, CurrentJob.Name), e); 263 "[{0}]: Job {1} failed, continuing. Exception ",LoggingName,m_currentJob.Name),e);
278 } 264 }
279 265
280 if (LogLevel >= 1) 266 if(LogLevel >= 1)
281 m_log.DebugFormat("[{0}]: Processed job {1}", LoggingName, CurrentJob.Name); 267 m_log.DebugFormat("[{0}]: Processed job {1}",LoggingName,m_currentJob.Name);
282 268
283 CurrentJob = null; 269 m_currentJob = null;
284 }
285 }
286 catch (OperationCanceledException)
287 {
288 } 270 }
289
290 m_finishedProcessingAfterStop.Set();
291 } 271 }
292 272
293 public class Job 273 public class Job
@@ -320,7 +300,7 @@ namespace OpenSim.Framework.Monitoring
320 CommonId = commonId; 300 CommonId = commonId;
321 Action = action; 301 Action = action;
322 } 302 }
323 303
324 /// <summary> 304 /// <summary>
325 /// Make a job. It needs to be separately queued. 305 /// Make a job. It needs to be separately queued.
326 /// </summary> 306 /// </summary>
@@ -338,4 +318,4 @@ namespace OpenSim.Framework.Monitoring
338 } 318 }
339 } 319 }
340 } 320 }
341} \ No newline at end of file 321}
diff --git a/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs
index a617b93..2ff2014 100644
--- a/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Framework.Monitoring")] 8[assembly: AssemblyTitle("OpenSim.Framework.Monitoring")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
index 77315bb..a26a6e0 100644
--- a/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/ServerStatsCollector.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Monitoring
88 IConfig cfg = source.Configs["Monitoring"]; 88 IConfig cfg = source.Configs["Monitoring"];
89 89
90 if (cfg != null) 90 if (cfg != null)
91 Enabled = cfg.GetBoolean("ServerStatsEnabled", true); 91 Enabled = cfg.GetBoolean("ServerStatsEnabled", false);
92 92
93 if (Enabled) 93 if (Enabled)
94 { 94 {
@@ -98,12 +98,18 @@ namespace OpenSim.Framework.Monitoring
98 98
99 public void Start() 99 public void Start()
100 { 100 {
101 if(!Enabled)
102 return;
103
101 if (RegisteredStats.Count == 0) 104 if (RegisteredStats.Count == 0)
102 RegisterServerStats(); 105 RegisterServerStats();
103 } 106 }
104 107
105 public void Close() 108 public void Close()
106 { 109 {
110 if(!Enabled)
111 return;
112
107 if (RegisteredStats.Count > 0) 113 if (RegisteredStats.Count > 0)
108 { 114 {
109 foreach (Stat stat in RegisteredStats.Values) 115 foreach (Stat stat in RegisteredStats.Values)
@@ -167,18 +173,18 @@ namespace OpenSim.Framework.Monitoring
167 } 173 }
168 174
169 MakeStat("BuiltinThreadpoolWorkerThreadsAvailable", null, "threads", ContainerThreadpool, 175 MakeStat("BuiltinThreadpoolWorkerThreadsAvailable", null, "threads", ContainerThreadpool,
170 s => 176 s =>
171 { 177 {
172 int workerThreads, iocpThreads; 178 int workerThreads, iocpThreads;
173 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); 179 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
174 s.Value = workerThreads; 180 s.Value = workerThreads;
175 }); 181 });
176 182
177 MakeStat("BuiltinThreadpoolIOCPThreadsAvailable", null, "threads", ContainerThreadpool, 183 MakeStat("BuiltinThreadpoolIOCPThreadsAvailable", null, "threads", ContainerThreadpool,
178 s => 184 s =>
179 { 185 {
180 int workerThreads, iocpThreads; 186 int workerThreads, iocpThreads;
181 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); 187 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
182 s.Value = iocpThreads; 188 s.Value = iocpThreads;
183 }); 189 });
184 190
@@ -193,10 +199,10 @@ namespace OpenSim.Framework.Monitoring
193 } 199 }
194 200
195 MakeStat( 201 MakeStat(
196 "HTTPRequestsMade", 202 "HTTPRequestsMade",
197 "Number of outbound HTTP requests made", 203 "Number of outbound HTTP requests made",
198 "requests", 204 "requests",
199 ContainerNetwork, 205 ContainerNetwork,
200 s => s.Value = WebUtil.RequestNumber, 206 s => s.Value = WebUtil.RequestNumber,
201 MeasuresOfInterest.AverageChangeOverTime); 207 MeasuresOfInterest.AverageChangeOverTime);
202 208
@@ -249,9 +255,52 @@ namespace OpenSim.Framework.Monitoring
249 (s) => { s.Value = Math.Round(MemoryWatchdog.LastHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); 255 (s) => { s.Value = Math.Round(MemoryWatchdog.LastHeapAllocationRate * 1000d / 1024d / 1024d, 3); });
250 MakeStat("AverageHeapAllocationRate", null, "MB/sec", ContainerMemory, 256 MakeStat("AverageHeapAllocationRate", null, "MB/sec", ContainerMemory,
251 (s) => { s.Value = Math.Round(MemoryWatchdog.AverageHeapAllocationRate * 1000d / 1024d / 1024d, 3); }); 257 (s) => { s.Value = Math.Round(MemoryWatchdog.AverageHeapAllocationRate * 1000d / 1024d / 1024d, 3); });
258
259 MakeStat("ProcessResident", null, "MB", ContainerProcess,
260 (s) =>
261 {
262 Process myprocess = Process.GetCurrentProcess();
263 myprocess.Refresh();
264 s.Value = Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0);
265 });
266 MakeStat("ProcessPaged", null, "MB", ContainerProcess,
267 (s) =>
268 {
269 Process myprocess = Process.GetCurrentProcess();
270 myprocess.Refresh();
271 s.Value = Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0);
272 });
273 MakeStat("ProcessVirtual", null, "MB", ContainerProcess,
274 (s) =>
275 {
276 Process myprocess = Process.GetCurrentProcess();
277 myprocess.Refresh();
278 s.Value = Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0);
279 });
280 MakeStat("PeakProcessResident", null, "MB", ContainerProcess,
281 (s) =>
282 {
283 Process myprocess = Process.GetCurrentProcess();
284 myprocess.Refresh();
285 s.Value = Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0);
286 });
287 MakeStat("PeakProcessPaged", null, "MB", ContainerProcess,
288 (s) =>
289 {
290 Process myprocess = Process.GetCurrentProcess();
291 myprocess.Refresh();
292 s.Value = Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0);
293 });
294 MakeStat("PeakProcessVirtual", null, "MB", ContainerProcess,
295 (s) =>
296 {
297 Process myprocess = Process.GetCurrentProcess();
298 myprocess.Refresh();
299 s.Value = Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0);
300 });
252 } 301 }
253 302
254 // Notes on performance counters: 303 // Notes on performance counters:
255 // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx 304 // "How To Read Performance Counters": http://blogs.msdn.com/b/bclteam/archive/2006/06/02/618156.aspx
256 // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c 305 // "How to get the CPU Usage in C#": http://stackoverflow.com/questions/278071/how-to-get-the-cpu-usage-in-c
257 // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters 306 // "Mono Performance Counters": http://www.mono-project.com/Mono_Performance_Counters
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
index e4df7ee..88a0297 100644..100755
--- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs
@@ -34,6 +34,7 @@ using OpenMetaverse;
34using OpenMetaverse.StructuredData; 34using OpenMetaverse.StructuredData;
35using OpenSim.Framework.Monitoring.Interfaces; 35using OpenSim.Framework.Monitoring.Interfaces;
36 36
37
37namespace OpenSim.Framework.Monitoring 38namespace OpenSim.Framework.Monitoring
38{ 39{
39 /// <summary> 40 /// <summary>
@@ -71,6 +72,11 @@ namespace OpenSim.Framework.Monitoring
71 private volatile float pendingDownloads; 72 private volatile float pendingDownloads;
72 private volatile float pendingUploads; 73 private volatile float pendingUploads;
73 private volatile float activeScripts; 74 private volatile float activeScripts;
75 private volatile float spareTime;
76 private volatile float sleepTime;
77 private volatile float physicsStep;
78
79
74 private volatile float scriptLinesPerSecond; 80 private volatile float scriptLinesPerSecond;
75 private volatile float m_frameDilation; 81 private volatile float m_frameDilation;
76 private volatile float m_usersLoggingIn; 82 private volatile float m_usersLoggingIn;
@@ -84,17 +90,17 @@ namespace OpenSim.Framework.Monitoring
84// /// haven't yet been implemented... 90// /// haven't yet been implemented...
85// /// </summary> 91// /// </summary>
86// public long AssetsInCache { get { return assetsInCache; } } 92// public long AssetsInCache { get { return assetsInCache; } }
87// 93//
88// /// <value> 94// /// <value>
89// /// Currently unused 95// /// Currently unused
90// /// </value> 96// /// </value>
91// public long TexturesInCache { get { return texturesInCache; } } 97// public long TexturesInCache { get { return texturesInCache; } }
92// 98//
93// /// <value> 99// /// <value>
94// /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit 100// /// Currently misleading since we can't currently subtract removed asset memory usage without a performance hit
95// /// </value> 101// /// </value>
96// public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } 102// public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
97// 103//
98// /// <value> 104// /// <value>
99// /// Currently unused 105// /// Currently unused
100// /// </value> 106// /// </value>
@@ -121,7 +127,7 @@ namespace OpenSim.Framework.Monitoring
121 public float PendingUploads { get { return pendingUploads; } } 127 public float PendingUploads { get { return pendingUploads; } }
122 public float ActiveScripts { get { return activeScripts; } } 128 public float ActiveScripts { get { return activeScripts; } }
123 public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } } 129 public float ScriptLinesPerSecond { get { return scriptLinesPerSecond; } }
124 130
125// /// <summary> 131// /// <summary>
126// /// This is the time it took for the last asset request made in response to a cache miss. 132// /// This is the time it took for the last asset request made in response to a cache miss.
127// /// </summary> 133// /// </summary>
@@ -171,7 +177,7 @@ namespace OpenSim.Framework.Monitoring
171// assetsInCache++; 177// assetsInCache++;
172// //assetCacheMemoryUsage += asset.Data.Length; 178// //assetCacheMemoryUsage += asset.Data.Length;
173// } 179// }
174// 180//
175// public void RemoveAsset(UUID uuid) 181// public void RemoveAsset(UUID uuid)
176// { 182// {
177// assetsInCache--; 183// assetsInCache--;
@@ -198,7 +204,7 @@ namespace OpenSim.Framework.Monitoring
198// texturesInCache = 0; 204// texturesInCache = 0;
199// textureCacheMemoryUsage = 0; 205// textureCacheMemoryUsage = 0;
200// } 206// }
201// 207//
202// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts) 208// public void AddAssetRequestTimeAfterCacheMiss(TimeSpan ts)
203// { 209// {
204// assetRequestTimeAfterCacheMiss = ts; 210// assetRequestTimeAfterCacheMiss = ts;
@@ -253,7 +259,7 @@ namespace OpenSim.Framework.Monitoring
253 /// <param name="pack"></param> 259 /// <param name="pack"></param>
254 public void ReceiveClassicSimStatsPacket(SimStats stats) 260 public void ReceiveClassicSimStatsPacket(SimStats stats)
255 { 261 {
256 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original 262 // FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
257 // SimStatsPacket that was being used). 263 // SimStatsPacket that was being used).
258 264
259 // For an unknown reason the original designers decided not to 265 // For an unknown reason the original designers decided not to
@@ -270,8 +276,8 @@ namespace OpenSim.Framework.Monitoring
270 totalFrameTime = stats.StatsBlock[8].StatValue; 276 totalFrameTime = stats.StatsBlock[8].StatValue;
271 netFrameTime = stats.StatsBlock[9].StatValue; 277 netFrameTime = stats.StatsBlock[9].StatValue;
272 physicsFrameTime = stats.StatsBlock[10].StatValue; 278 physicsFrameTime = stats.StatsBlock[10].StatValue;
273 otherFrameTime = stats.StatsBlock[11].StatValue; 279 imageFrameTime = stats.StatsBlock[11].StatValue;
274 imageFrameTime = stats.StatsBlock[12].StatValue; 280 otherFrameTime = stats.StatsBlock[12].StatValue;
275 inPacketsPerSecond = stats.StatsBlock[13].StatValue; 281 inPacketsPerSecond = stats.StatsBlock[13].StatValue;
276 outPacketsPerSecond = stats.StatsBlock[14].StatValue; 282 outPacketsPerSecond = stats.StatsBlock[14].StatValue;
277 unackedBytes = stats.StatsBlock[15].StatValue; 283 unackedBytes = stats.StatsBlock[15].StatValue;
@@ -279,12 +285,16 @@ namespace OpenSim.Framework.Monitoring
279 pendingDownloads = stats.StatsBlock[17].StatValue; 285 pendingDownloads = stats.StatsBlock[17].StatValue;
280 pendingUploads = stats.StatsBlock[18].StatValue; 286 pendingUploads = stats.StatsBlock[18].StatValue;
281 activeScripts = stats.StatsBlock[19].StatValue; 287 activeScripts = stats.StatsBlock[19].StatValue;
282 scriptLinesPerSecond = stats.StatsBlock[20].StatValue; 288 sleepTime = stats.StatsBlock[20].StatValue;
283 m_frameDilation = stats.StatsBlock[22].StatValue; 289 spareTime = stats.StatsBlock[21].StatValue;
284 m_usersLoggingIn = stats.StatsBlock[23].StatValue; 290 physicsStep = stats.StatsBlock[22].StatValue;
285 m_totalGeoPrims = stats.StatsBlock[24].StatValue; 291
286 m_totalMeshes = stats.StatsBlock[25].StatValue; 292 scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
287 m_inUseThreads = stats.StatsBlock[26].StatValue; 293 m_frameDilation = stats.ExtraStatsBlock[1].StatValue;
294 m_usersLoggingIn = stats.ExtraStatsBlock[2].StatValue;
295 m_totalGeoPrims = stats.ExtraStatsBlock[3].StatValue;
296 m_totalMeshes = stats.ExtraStatsBlock[4].StatValue;
297 m_inUseThreads = stats.ExtraStatsBlock[5].StatValue;
288 } 298 }
289 299
290 /// <summary> 300 /// <summary>
@@ -296,7 +306,7 @@ namespace OpenSim.Framework.Monitoring
296 StringBuilder sb = new StringBuilder(Environment.NewLine); 306 StringBuilder sb = new StringBuilder(Environment.NewLine);
297// sb.Append("ASSET STATISTICS"); 307// sb.Append("ASSET STATISTICS");
298// sb.Append(Environment.NewLine); 308// sb.Append(Environment.NewLine);
299 309
300 /* 310 /*
301 sb.Append( 311 sb.Append(
302 string.Format( 312 string.Format(
@@ -332,7 +342,7 @@ Asset service request failures: {3}" + Environment.NewLine,
332 List<Stat> stats = StatsManager.GetStatsFromEachContainer("clientstack", "ClientLogoutsDueToNoReceives"); 342 List<Stat> stats = StatsManager.GetStatsFromEachContainer("clientstack", "ClientLogoutsDueToNoReceives");
333 343
334 sb.AppendFormat( 344 sb.AppendFormat(
335 "Client logouts due to no data receive timeout: {0}\n\n", 345 "Client logouts due to no data receive timeout: {0}\n\n",
336 stats != null ? stats.Sum(s => s.Value).ToString() : "unknown"); 346 stats != null ? stats.Sum(s => s.Value).ToString() : "unknown");
337 347
338// sb.Append(Environment.NewLine); 348// sb.Append(Environment.NewLine);
@@ -433,10 +443,10 @@ Asset service request failures: {3}" + Environment.NewLine,
433 foreach (ProcessThread currentThread in 443 foreach (ProcessThread currentThread in
434 Process.GetCurrentProcess().Threads) 444 Process.GetCurrentProcess().Threads)
435 { 445 {
436 // A known issue with the current process .Threads property is 446 // A known issue with the current process .Threads property is
437 // that it can return null threads, thus don't count those as 447 // that it can return null threads, thus don't count those as
438 // running threads and prevent the program function from failing 448 // running threads and prevent the program function from failing
439 if (currentThread != null && 449 if (currentThread != null &&
440 currentThread.ThreadState == ThreadState.Running) 450 currentThread.ThreadState == ThreadState.Running)
441 { 451 {
442 numberThreadsRunning++; 452 numberThreadsRunning++;
@@ -495,7 +505,7 @@ Asset service request failures: {3}" + Environment.NewLine,
495 "{0:0.##}", numberThreadsRunning)); 505 "{0:0.##}", numberThreadsRunning));
496 args["ProcMem"] = OSD.FromString(String.Format("{0:#,###,###.##}", 506 args["ProcMem"] = OSD.FromString(String.Format("{0:#,###,###.##}",
497 memUsage)); 507 memUsage));
498 508
499 return args; 509 return args;
500 } 510 }
501 } 511 }
@@ -521,12 +531,12 @@ Asset service request failures: {3}" + Environment.NewLine,
521 { 531 {
522 return m_statsProvider.GetStats(); 532 return m_statsProvider.GetStats();
523 } 533 }
524 534
525 public string XReport(string uptime, string version) 535 public string XReport(string uptime, string version)
526 { 536 {
527 return ""; 537 return "";
528 } 538 }
529 539
530 public OSDMap OReport(string uptime, string version) 540 public OSDMap OReport(string uptime, string version)
531 { 541 {
532 OSDMap ret = new OSDMap(); 542 OSDMap ret = new OSDMap();
diff --git a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs
index 318cf1c..318cf1c 100644..100755
--- a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs
+++ b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs
diff --git a/OpenSim/Framework/Monitoring/Stats/EventHistogram.cs b/OpenSim/Framework/Monitoring/Stats/EventHistogram.cs
index f51f322..bc56372 100644..100755
--- a/OpenSim/Framework/Monitoring/Stats/EventHistogram.cs
+++ b/OpenSim/Framework/Monitoring/Stats/EventHistogram.cs
@@ -1,173 +1,173 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33using OpenMetaverse.StructuredData; 33using OpenMetaverse.StructuredData;
34 34
35namespace OpenSim.Framework.Monitoring 35namespace OpenSim.Framework.Monitoring
36{ 36{
37// Create a time histogram of events. The histogram is built in a wrap-around 37// Create a time histogram of events. The histogram is built in a wrap-around
38// array of equally distributed buckets. 38// array of equally distributed buckets.
39// For instance, a minute long histogram of second sized buckets would be: 39// For instance, a minute long histogram of second sized buckets would be:
40// new EventHistogram(60, 1000) 40// new EventHistogram(60, 1000)
41public class EventHistogram 41public class EventHistogram
42{ 42{
43 private int m_timeBase; 43 private int m_timeBase;
44 private int m_numBuckets; 44 private int m_numBuckets;
45 private int m_bucketMilliseconds; 45 private int m_bucketMilliseconds;
46 private int m_lastBucket; 46 private int m_lastBucket;
47 private int m_totalHistogramMilliseconds; 47 private int m_totalHistogramMilliseconds;
48 private long[] m_histogram; 48 private long[] m_histogram;
49 private object histoLock = new object(); 49 private object histoLock = new object();
50 50
51 public EventHistogram(int numberOfBuckets, int millisecondsPerBucket) 51 public EventHistogram(int numberOfBuckets, int millisecondsPerBucket)
52 { 52 {
53 m_numBuckets = numberOfBuckets; 53 m_numBuckets = numberOfBuckets;
54 m_bucketMilliseconds = millisecondsPerBucket; 54 m_bucketMilliseconds = millisecondsPerBucket;
55 m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds; 55 m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds;
56 56
57 m_histogram = new long[m_numBuckets]; 57 m_histogram = new long[m_numBuckets];
58 Zero(); 58 Zero();
59 m_lastBucket = 0; 59 m_lastBucket = 0;
60 m_timeBase = Util.EnvironmentTickCount(); 60 m_timeBase = Util.EnvironmentTickCount();
61 } 61 }
62 62
63 public void Event() 63 public void Event()
64 { 64 {
65 this.Event(1); 65 this.Event(1);
66 } 66 }
67 67
68 // Record an event at time 'now' in the histogram. 68 // Record an event at time 'now' in the histogram.
69 public void Event(int cnt) 69 public void Event(int cnt)
70 { 70 {
71 lock (histoLock) 71 lock (histoLock)
72 { 72 {
73 // The time as displaced from the base of the histogram 73 // The time as displaced from the base of the histogram
74 int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase); 74 int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase);
75 75
76 // If more than the total time of the histogram, we just start over 76 // If more than the total time of the histogram, we just start over
77 if (bucketTime > m_totalHistogramMilliseconds) 77 if (bucketTime > m_totalHistogramMilliseconds)
78 { 78 {
79 Zero(); 79 Zero();
80 m_lastBucket = 0; 80 m_lastBucket = 0;
81 m_timeBase = Util.EnvironmentTickCount(); 81 m_timeBase = Util.EnvironmentTickCount();
82 } 82 }
83 else 83 else
84 { 84 {
85 // To which bucket should we add this event? 85 // To which bucket should we add this event?
86 int bucket = bucketTime / m_bucketMilliseconds; 86 int bucket = bucketTime / m_bucketMilliseconds;
87 87
88 // Advance m_lastBucket to the new bucket. Zero any buckets skipped over. 88 // Advance m_lastBucket to the new bucket. Zero any buckets skipped over.
89 while (bucket != m_lastBucket) 89 while (bucket != m_lastBucket)
90 { 90 {
91 // Zero from just after the last bucket to the new bucket or the end 91 // Zero from just after the last bucket to the new bucket or the end
92 for (int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++) 92 for (int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++)
93 { 93 {
94 m_histogram[jj] = 0; 94 m_histogram[jj] = 0;
95 } 95 }
96 m_lastBucket = bucket; 96 m_lastBucket = bucket;
97 // If the new bucket is off the end, wrap around to the beginning 97 // If the new bucket is off the end, wrap around to the beginning
98 if (bucket > m_numBuckets) 98 if (bucket > m_numBuckets)
99 { 99 {
100 bucket -= m_numBuckets; 100 bucket -= m_numBuckets;
101 m_lastBucket = 0; 101 m_lastBucket = 0;
102 m_histogram[m_lastBucket] = 0; 102 m_histogram[m_lastBucket] = 0;
103 m_timeBase += m_totalHistogramMilliseconds; 103 m_timeBase += m_totalHistogramMilliseconds;
104 } 104 }
105 } 105 }
106 } 106 }
107 m_histogram[m_lastBucket] += cnt; 107 m_histogram[m_lastBucket] += cnt;
108 } 108 }
109 } 109 }
110 110
111 // Get a copy of the current histogram 111 // Get a copy of the current histogram
112 public long[] GetHistogram() 112 public long[] GetHistogram()
113 { 113 {
114 long[] ret = new long[m_numBuckets]; 114 long[] ret = new long[m_numBuckets];
115 lock (histoLock) 115 lock (histoLock)
116 { 116 {
117 int indx = m_lastBucket + 1; 117 int indx = m_lastBucket + 1;
118 for (int ii = 0; ii < m_numBuckets; ii++, indx++) 118 for (int ii = 0; ii < m_numBuckets; ii++, indx++)
119 { 119 {
120 if (indx >= m_numBuckets) 120 if (indx >= m_numBuckets)
121 indx = 0; 121 indx = 0;
122 ret[ii] = m_histogram[indx]; 122 ret[ii] = m_histogram[indx];
123 } 123 }
124 } 124 }
125 return ret; 125 return ret;
126 } 126 }
127 127
128 public OSDMap GetHistogramAsOSDMap() 128 public OSDMap GetHistogramAsOSDMap()
129 { 129 {
130 OSDMap ret = new OSDMap(); 130 OSDMap ret = new OSDMap();
131 131
132 ret.Add("Buckets", OSD.FromInteger(m_numBuckets)); 132 ret.Add("Buckets", OSD.FromInteger(m_numBuckets));
133 ret.Add("BucketMilliseconds", OSD.FromInteger(m_bucketMilliseconds)); 133 ret.Add("BucketMilliseconds", OSD.FromInteger(m_bucketMilliseconds));
134 ret.Add("TotalMilliseconds", OSD.FromInteger(m_totalHistogramMilliseconds)); 134 ret.Add("TotalMilliseconds", OSD.FromInteger(m_totalHistogramMilliseconds));
135 135
136 // Compute a number for the first bucket in the histogram. 136 // Compute a number for the first bucket in the histogram.
137 // This will allow readers to know how this histogram relates to any previously read histogram. 137 // This will allow readers to know how this histogram relates to any previously read histogram.
138 int baseBucketNum = (m_timeBase / m_bucketMilliseconds) + m_lastBucket + 1; 138 int baseBucketNum = (m_timeBase / m_bucketMilliseconds) + m_lastBucket + 1;
139 ret.Add("BaseNumber", OSD.FromInteger(baseBucketNum)); 139 ret.Add("BaseNumber", OSD.FromInteger(baseBucketNum));
140 140
141 ret.Add("Values", GetHistogramAsOSDArray()); 141 ret.Add("Values", GetHistogramAsOSDArray());
142 142
143 return ret; 143 return ret;
144 } 144 }
145 // Get a copy of the current histogram 145 // Get a copy of the current histogram
146 public OSDArray GetHistogramAsOSDArray() 146 public OSDArray GetHistogramAsOSDArray()
147 { 147 {
148 OSDArray ret = new OSDArray(m_numBuckets); 148 OSDArray ret = new OSDArray(m_numBuckets);
149 lock (histoLock) 149 lock (histoLock)
150 { 150 {
151 int indx = m_lastBucket + 1; 151 int indx = m_lastBucket + 1;
152 for (int ii = 0; ii < m_numBuckets; ii++, indx++) 152 for (int ii = 0; ii < m_numBuckets; ii++, indx++)
153 { 153 {
154 if (indx >= m_numBuckets) 154 if (indx >= m_numBuckets)
155 indx = 0; 155 indx = 0;
156 ret[ii] = OSD.FromLong(m_histogram[indx]); 156 ret[ii] = OSD.FromLong(m_histogram[indx]);
157 } 157 }
158 } 158 }
159 return ret; 159 return ret;
160 } 160 }
161 161
162 // Zero out the histogram 162 // Zero out the histogram
163 public void Zero() 163 public void Zero()
164 { 164 {
165 lock (histoLock) 165 lock (histoLock)
166 { 166 {
167 for (int ii = 0; ii < m_numBuckets; ii++) 167 for (int ii = 0; ii < m_numBuckets; ii++)
168 m_histogram[ii] = 0; 168 m_histogram[ii] = 0;
169 } 169 }
170 } 170 }
171} 171}
172 172
173} 173}
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs
index a7cb2a6..2402acd 100644
--- a/OpenSim/Framework/Monitoring/Stats/Stat.cs
+++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs
@@ -121,17 +121,17 @@ namespace OpenSim.Framework.Monitoring
121 string container, 121 string container,
122 StatType type, 122 StatType type,
123 Action<Stat> pullAction, 123 Action<Stat> pullAction,
124 StatVerbosity verbosity) 124 StatVerbosity verbosity)
125 : this( 125 : this(
126 shortName, 126 shortName,
127 name, 127 name,
128 description, 128 description,
129 unitName, 129 unitName,
130 category, 130 category,
131 container, 131 container,
132 type, 132 type,
133 MeasuresOfInterest.None, 133 MeasuresOfInterest.None,
134 pullAction, 134 pullAction,
135 verbosity) 135 verbosity)
136 { 136 {
137 } 137 }
@@ -227,11 +227,11 @@ namespace OpenSim.Framework.Monitoring
227 { 227 {
228 StringBuilder sb = new StringBuilder(); 228 StringBuilder sb = new StringBuilder();
229 sb.AppendFormat( 229 sb.AppendFormat(
230 "{0}.{1}.{2} : {3}{4}", 230 "{0}.{1}.{2} : {3}{4}",
231 Category, 231 Category,
232 Container, 232 Container,
233 ShortName, 233 ShortName,
234 Value, 234 Value,
235 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName)); 235 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName));
236 236
237 AppendMeasuresOfInterest(sb); 237 AppendMeasuresOfInterest(sb);
@@ -239,6 +239,17 @@ namespace OpenSim.Framework.Monitoring
239 return sb.ToString(); 239 return sb.ToString();
240 } 240 }
241 241
242 public virtual OSDMap ToBriefOSDMap()
243 {
244 OSDMap ret = new OSDMap();
245
246 ret.Add("Value", OSD.FromReal(Value));
247
248 double lastChangeOverTime, averageChangeOverTime;
249
250 return ret;
251 }
252
242 public virtual OSDMap ToOSDMap() 253 public virtual OSDMap ToOSDMap()
243 { 254 {
244 OSDMap ret = new OSDMap(); 255 OSDMap ret = new OSDMap();
@@ -279,7 +290,7 @@ namespace OpenSim.Framework.Monitoring
279 lock (m_samples) 290 lock (m_samples)
280 { 291 {
281 // m_log.DebugFormat( 292 // m_log.DebugFormat(
282 // "[STAT]: Samples for {0} are {1}", 293 // "[STAT]: Samples for {0} are {1}",
283 // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray())); 294 // Name, string.Join(",", m_samples.Select(s => s.ToString()).ToArray()));
284 295
285 foreach (double s in m_samples) 296 foreach (double s in m_samples)
@@ -315,12 +326,12 @@ namespace OpenSim.Framework.Monitoring
315 if (ComputeMeasuresOfInterest(out lastChangeOverTime, out averageChangeOverTime)) 326 if (ComputeMeasuresOfInterest(out lastChangeOverTime, out averageChangeOverTime))
316 { 327 {
317 sb.AppendFormat( 328 sb.AppendFormat(
318 ", {0:0.##}{1}/s, {2:0.##}{3}/s", 329 ", {0:0.##}{1}/s, {2:0.##}{3}/s",
319 lastChangeOverTime, 330 lastChangeOverTime,
320 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName), 331 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName),
321 averageChangeOverTime, 332 averageChangeOverTime,
322 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName)); 333 string.IsNullOrEmpty(UnitName) ? "" : string.Format(" {0}", UnitName));
323 } 334 }
324 } 335 }
325 } 336 }
326} \ No newline at end of file 337}
diff --git a/OpenSim/Framework/Monitoring/StatsLogger.cs b/OpenSim/Framework/Monitoring/StatsLogger.cs
index 15a37aa..b719af9 100644
--- a/OpenSim/Framework/Monitoring/StatsLogger.cs
+++ b/OpenSim/Framework/Monitoring/StatsLogger.cs
@@ -99,13 +99,13 @@ namespace OpenSim.Framework.Monitoring
99 } 99 }
100 100
101 string path = cmd[2]; 101 string path = cmd[2];
102 102
103 using (StreamWriter sw = new StreamWriter(path, true)) 103 using (StreamWriter sw = new StreamWriter(path, true))
104 { 104 {
105 foreach (string line in GetReport()) 105 foreach (string line in GetReport())
106 sw.WriteLine(line); 106 sw.WriteLine(line);
107 } 107 }
108 108
109 MainConsole.Instance.OutputFormat("Stats saved to file {0}", path); 109 MainConsole.Instance.OutputFormat("Stats saved to file {0}", path);
110 } 110 }
111 111
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs
index 3136ee8..a6b341f 100644
--- a/OpenSim/Framework/Monitoring/StatsManager.cs
+++ b/OpenSim/Framework/Monitoring/StatsManager.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Framework.Monitoring
47 // Subcommand used to list other stats. 47 // Subcommand used to list other stats.
48 public const string ListSubCommand = "list"; 48 public const string ListSubCommand = "list";
49 49
50 public static string StatsPassword { get; set; }
51
50 // All subcommands 52 // All subcommands
51 public static HashSet<string> SubCommands = new HashSet<string> { AllSubCommand, ListSubCommand }; 53 public static HashSet<string> SubCommands = new HashSet<string> { AllSubCommand, ListSubCommand };
52 54
@@ -80,8 +82,7 @@ namespace OpenSim.Framework.Monitoring
80 + "'all' will show all statistics.\n" 82 + "'all' will show all statistics.\n"
81 + "A <category> name will show statistics from that category.\n" 83 + "A <category> name will show statistics from that category.\n"
82 + "A <category>.<container> name will show statistics from that category in that container.\n" 84 + "A <category>.<container> name will show statistics from that category in that container.\n"
83 + "More than one name can be given separated by spaces.\n" 85 + "More than one name can be given separated by spaces.\n",
84 + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS",
85 HandleShowStatsCommand); 86 HandleShowStatsCommand);
86 87
87 console.Commands.AddCommand( 88 console.Commands.AddCommand(
@@ -91,7 +92,6 @@ namespace OpenSim.Framework.Monitoring
91 "show stats [list|all|(<category>[.<container>])+", 92 "show stats [list|all|(<category>[.<container>])+",
92 "Alias for 'stats show' command", 93 "Alias for 'stats show' command",
93 HandleShowStatsCommand); 94 HandleShowStatsCommand);
94
95 StatsLogger.RegisterConsoleCommands(console); 95 StatsLogger.RegisterConsoleCommands(console);
96 } 96 }
97 97
@@ -262,33 +262,36 @@ namespace OpenSim.Framework.Monitoring
262 { 262 {
263 OSDMap map = new OSDMap(); 263 OSDMap map = new OSDMap();
264 264
265 foreach (string catName in RegisteredStats.Keys) 265 lock (RegisteredStats)
266 { 266 {
267 // Do this category if null spec, "all" subcommand or category name matches passed parameter. 267 foreach (string catName in RegisteredStats.Keys)
268 // Skip category if none of the above.
269 if (!(String.IsNullOrEmpty(pCategoryName) || pCategoryName == AllSubCommand || pCategoryName == catName))
270 continue;
271
272 OSDMap contMap = new OSDMap();
273 foreach (string contName in RegisteredStats[catName].Keys)
274 { 268 {
275 if (!(string.IsNullOrEmpty(pContainerName) || pContainerName == AllSubCommand || pContainerName == contName)) 269 // Do this category if null spec, "all" subcommand or category name matches passed parameter.
270 // Skip category if none of the above.
271 if (!(String.IsNullOrEmpty(pCategoryName) || pCategoryName == AllSubCommand || pCategoryName == catName))
276 continue; 272 continue;
277
278 OSDMap statMap = new OSDMap();
279 273
280 SortedDictionary<string, Stat> theStats = RegisteredStats[catName][contName]; 274 OSDMap contMap = new OSDMap();
281 foreach (string statName in theStats.Keys) 275 foreach (string contName in RegisteredStats[catName].Keys)
282 { 276 {
283 if (!(String.IsNullOrEmpty(pStatName) || pStatName == AllSubCommand || pStatName == statName)) 277 if (!(string.IsNullOrEmpty(pContainerName) || pContainerName == AllSubCommand || pContainerName == contName))
284 continue; 278 continue;
285 279
286 statMap.Add(statName, theStats[statName].ToOSDMap()); 280 OSDMap statMap = new OSDMap();
287 } 281
282 SortedDictionary<string, Stat> theStats = RegisteredStats[catName][contName];
283 foreach (string statName in theStats.Keys)
284 {
285 if (!(String.IsNullOrEmpty(pStatName) || pStatName == AllSubCommand || pStatName == statName))
286 continue;
287
288 statMap.Add(statName, theStats[statName].ToBriefOSDMap());
289 }
288 290
289 contMap.Add(contName, statMap); 291 contMap.Add(contName, statMap);
292 }
293 map.Add(catName, contMap);
290 } 294 }
291 map.Add(catName, contMap);
292 } 295 }
293 296
294 return map; 297 return map;
@@ -301,6 +304,17 @@ namespace OpenSim.Framework.Monitoring
301 int response_code = 200; 304 int response_code = 200;
302 string contenttype = "text/json"; 305 string contenttype = "text/json";
303 306
307 if (StatsPassword != String.Empty && (!request.ContainsKey("pass") || request["pass"].ToString() != StatsPassword))
308 {
309 responsedata["int_response_code"] = response_code;
310 responsedata["content_type"] = "text/plain";
311 responsedata["keepalive"] = false;
312 responsedata["str_response_string"] = "Access denied";
313 responsedata["access_control_allow_origin"] = "*";
314
315 return responsedata;
316 }
317
304 string pCategoryName = StatsManager.AllSubCommand; 318 string pCategoryName = StatsManager.AllSubCommand;
305 string pContainerName = StatsManager.AllSubCommand; 319 string pContainerName = StatsManager.AllSubCommand;
306 string pStatName = StatsManager.AllSubCommand; 320 string pStatName = StatsManager.AllSubCommand;
@@ -358,8 +372,8 @@ namespace OpenSim.Framework.Monitoring
358 /// <returns></returns> 372 /// <returns></returns>
359 public static bool RegisterStat(Stat stat) 373 public static bool RegisterStat(Stat stat)
360 { 374 {
361 SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; 375 SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
362 SortedDictionary<string, Stat> container = null, newContainer; 376 SortedDictionary<string, Stat> container = null;
363 377
364 lock (RegisteredStats) 378 lock (RegisteredStats)
365 { 379 {
@@ -369,22 +383,15 @@ namespace OpenSim.Framework.Monitoring
369 if (TryGetStatParents(stat, out category, out container)) 383 if (TryGetStatParents(stat, out category, out container))
370 return false; 384 return false;
371 385
372 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. 386 if (container == null)
373 // This means that we don't need to lock or copy them on iteration, which will be a much more 387 container = new SortedDictionary<string, Stat>();
374 // common operation after startup.
375 if (container != null)
376 newContainer = new SortedDictionary<string, Stat>(container);
377 else
378 newContainer = new SortedDictionary<string, Stat>();
379 388
380 if (category != null) 389 if (category == null)
381 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); 390 category = new SortedDictionary<string, SortedDictionary<string, Stat>>();
382 else
383 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();
384 391
385 newContainer[stat.ShortName] = stat; 392 container[stat.ShortName] = stat;
386 newCategory[stat.Container] = newContainer; 393 category[stat.Container] = container;
387 RegisteredStats[stat.Category] = newCategory; 394 RegisteredStats[stat.Category] = category;
388 } 395 }
389 396
390 return true; 397 return true;
@@ -397,23 +404,24 @@ namespace OpenSim.Framework.Monitoring
397 /// <returns></returns> 404 /// <returns></returns>
398 public static bool DeregisterStat(Stat stat) 405 public static bool DeregisterStat(Stat stat)
399 { 406 {
400 SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory; 407 SortedDictionary<string, SortedDictionary<string, Stat>> category = null;
401 SortedDictionary<string, Stat> container = null, newContainer; 408 SortedDictionary<string, Stat> container = null;
402 409
403 lock (RegisteredStats) 410 lock (RegisteredStats)
404 { 411 {
405 if (!TryGetStatParents(stat, out category, out container)) 412 if (!TryGetStatParents(stat, out category, out container))
406 return false; 413 return false;
407 414
408 newContainer = new SortedDictionary<string, Stat>(container); 415 if(container != null)
409 newContainer.Remove(stat.ShortName); 416 {
410 417 container.Remove(stat.ShortName);
411 newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category); 418 if(category != null && container.Count == 0)
412 newCategory.Remove(stat.Container); 419 {
413 420 category.Remove(stat.Container);
414 newCategory[stat.Container] = newContainer; 421 if(category.Count == 0)
415 RegisteredStats[stat.Category] = newCategory; 422 RegisteredStats.Remove(stat.Category);
416 423 }
424 }
417 return true; 425 return true;
418 } 426 }
419 } 427 }
@@ -554,4 +562,4 @@ namespace OpenSim.Framework.Monitoring
554 Debug, 562 Debug,
555 Info 563 Info
556 } 564 }
557} \ No newline at end of file 565}
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index a644fa5..9cac451 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -96,7 +96,7 @@ namespace OpenSim.Framework.Monitoring
96 FirstTick = Environment.TickCount & Int32.MaxValue; 96 FirstTick = Environment.TickCount & Int32.MaxValue;
97 LastTick = FirstTick; 97 LastTick = FirstTick;
98 98
99 Stat 99 Stat
100 = new Stat( 100 = new Stat(
101 name, 101 name,
102 string.Format("Last update of thread {0}", name), 102 string.Format("Last update of thread {0}", name),
@@ -180,6 +180,30 @@ namespace OpenSim.Framework.Monitoring
180 m_watchdogTimer.Elapsed += WatchdogTimerElapsed; 180 m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
181 } 181 }
182 182
183 public static void Stop()
184 {
185 if(m_threads == null)
186 return;
187
188 lock(m_threads)
189 {
190 m_enabled = false;
191 if(m_watchdogTimer != null)
192 {
193 m_watchdogTimer.Dispose();
194 m_watchdogTimer = null;
195 }
196
197 foreach(ThreadWatchdogInfo twi in m_threads.Values)
198 {
199 Thread t = twi.Thread;
200 if(t.IsAlive)
201 t.Abort();
202 }
203 m_threads.Clear();
204 }
205 }
206
183 /// <summary> 207 /// <summary>
184 /// Add a thread to the watchdog tracker. 208 /// Add a thread to the watchdog tracker.
185 /// </summary> 209 /// </summary>
@@ -230,14 +254,12 @@ namespace OpenSim.Framework.Monitoring
230 254
231 twi.Cleanup(); 255 twi.Cleanup();
232 m_threads.Remove(threadID); 256 m_threads.Remove(threadID);
233
234 return true; 257 return true;
235 } 258 }
236 else 259 else
237 { 260 {
238 m_log.WarnFormat( 261 m_log.WarnFormat(
239 "[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID); 262 "[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID);
240
241 return false; 263 return false;
242 } 264 }
243 } 265 }
@@ -317,6 +339,8 @@ namespace OpenSim.Framework.Monitoring
317 /// <param name="e"></param> 339 /// <param name="e"></param>
318 private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) 340 private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
319 { 341 {
342 if(!m_enabled)
343 return;
320 int now = Environment.TickCount & Int32.MaxValue; 344 int now = Environment.TickCount & Int32.MaxValue;
321 int msElapsed = now - LastWatchdogThreadTick; 345 int msElapsed = now - LastWatchdogThreadTick;
322 346
@@ -332,27 +356,36 @@ namespace OpenSim.Framework.Monitoring
332 if (callback != null) 356 if (callback != null)
333 { 357 {
334 List<ThreadWatchdogInfo> callbackInfos = null; 358 List<ThreadWatchdogInfo> callbackInfos = null;
359 List<ThreadWatchdogInfo> threadsToRemove = null;
360
361 const ThreadState thgone = ThreadState.Stopped;
335 362
336 lock (m_threads) 363 lock (m_threads)
337 { 364 {
338 foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) 365 foreach(ThreadWatchdogInfo threadInfo in m_threads.Values)
339 { 366 {
340 if (threadInfo.Thread.ThreadState == ThreadState.Stopped) 367 if(!m_enabled)
368 return;
369 if((threadInfo.Thread.ThreadState & thgone) != 0)
341 { 370 {
342 RemoveThread(threadInfo.Thread.ManagedThreadId); 371 if(threadsToRemove == null)
372 threadsToRemove = new List<ThreadWatchdogInfo>();
343 373
344 if (callbackInfos == null) 374 threadsToRemove.Add(threadInfo);
375/*
376 if(callbackInfos == null)
345 callbackInfos = new List<ThreadWatchdogInfo>(); 377 callbackInfos = new List<ThreadWatchdogInfo>();
346 378
347 callbackInfos.Add(threadInfo); 379 callbackInfos.Add(threadInfo);
380*/
348 } 381 }
349 else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) 382 else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout)
350 { 383 {
351 threadInfo.IsTimedOut = true; 384 threadInfo.IsTimedOut = true;
352 385
353 if (threadInfo.AlarmIfTimeout) 386 if(threadInfo.AlarmIfTimeout)
354 { 387 {
355 if (callbackInfos == null) 388 if(callbackInfos == null)
356 callbackInfos = new List<ThreadWatchdogInfo>(); 389 callbackInfos = new List<ThreadWatchdogInfo>();
357 390
358 // Send a copy of the watchdog info to prevent race conditions where the watchdog 391 // Send a copy of the watchdog info to prevent race conditions where the watchdog
@@ -361,9 +394,13 @@ namespace OpenSim.Framework.Monitoring
361 } 394 }
362 } 395 }
363 } 396 }
397
398 if(threadsToRemove != null)
399 foreach(ThreadWatchdogInfo twi in threadsToRemove)
400 RemoveThread(twi.Thread.ManagedThreadId);
364 } 401 }
365 402
366 if (callbackInfos != null) 403 if(callbackInfos != null)
367 foreach (ThreadWatchdogInfo callbackInfo in callbackInfos) 404 foreach (ThreadWatchdogInfo callbackInfo in callbackInfos)
368 callback(callbackInfo); 405 callback(callbackInfo);
369 } 406 }
@@ -377,4 +414,4 @@ namespace OpenSim.Framework.Monitoring
377 m_watchdogTimer.Start(); 414 m_watchdogTimer.Start();
378 } 415 }
379 } 416 }
380} \ No newline at end of file 417}
diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs
index d1a74ce..5d9b185 100644
--- a/OpenSim/Framework/Monitoring/WorkManager.cs
+++ b/OpenSim/Framework/Monitoring/WorkManager.cs
@@ -36,16 +36,16 @@ namespace OpenSim.Framework.Monitoring
36 /// Manages various work items in the simulator. 36 /// Manages various work items in the simulator.
37 /// </summary> 37 /// </summary>
38 /// <remarks> 38 /// <remarks>
39 /// Currently, here work can be started 39 /// Currently, here work can be started
40 /// * As a long-running and monitored thread. 40 /// * As a long-running and monitored thread.
41 /// * In a thread that will never timeout but where the job is expected to eventually complete. 41 /// * In a thread that will never timeout but where the job is expected to eventually complete.
42 /// * In a threadpool thread that will timeout if it takes a very long time to complete (> 10 mins). 42 /// * In a threadpool thread that will timeout if it takes a very long time to complete (> 10 mins).
43 /// * As a job which will be run in a single-threaded job engine. Such jobs must not incorporate delays (sleeps, 43 /// * As a job which will be run in a single-threaded job engine. Such jobs must not incorporate delays (sleeps,
44 /// network waits, etc.). 44 /// network waits, etc.).
45 /// 45 ///
46 /// This is an evolving approach to better manage the work that OpenSimulator is asked to do from a very diverse 46 /// This is an evolving approach to better manage the work that OpenSimulator is asked to do from a very diverse
47 /// range of sources (client actions, incoming network, outgoing network calls, etc.). 47 /// range of sources (client actions, incoming network, outgoing network calls, etc.).
48 /// 48 ///
49 /// Util.FireAndForget is still available to insert jobs in the threadpool, though this is equivalent to 49 /// Util.FireAndForget is still available to insert jobs in the threadpool, though this is equivalent to
50 /// WorkManager.RunInThreadPool(). 50 /// WorkManager.RunInThreadPool().
51 /// </remarks> 51 /// </remarks>
@@ -57,7 +57,7 @@ namespace OpenSim.Framework.Monitoring
57 57
58 static WorkManager() 58 static WorkManager()
59 { 59 {
60 JobEngine = new JobEngine("Non-blocking non-critical job engine", "JOB ENGINE"); 60 JobEngine = new JobEngine("Non-blocking non-critical job engine", "JOB ENGINE", 30000);
61 61
62 StatsManager.RegisterStat( 62 StatsManager.RegisterStat(
63 new Stat( 63 new Stat(
@@ -82,6 +82,12 @@ namespace OpenSim.Framework.Monitoring
82 HandleControlCommand); 82 HandleControlCommand);
83 } 83 }
84 84
85 public static void Stop()
86 {
87 JobEngine.Stop();
88 Watchdog.Stop();
89 }
90
85 /// <summary> 91 /// <summary>
86 /// Start a new long-lived thread. 92 /// Start a new long-lived thread.
87 /// </summary> 93 /// </summary>
@@ -121,6 +127,7 @@ namespace OpenSim.Framework.Monitoring
121 Thread thread = new Thread(start); 127 Thread thread = new Thread(start);
122 thread.Priority = priority; 128 thread.Priority = priority;
123 thread.IsBackground = isBackground; 129 thread.IsBackground = isBackground;
130 thread.Name = name;
124 131
125 Watchdog.ThreadWatchdogInfo twi 132 Watchdog.ThreadWatchdogInfo twi
126 = new Watchdog.ThreadWatchdogInfo(thread, timeout, name) 133 = new Watchdog.ThreadWatchdogInfo(thread, timeout, name)
@@ -129,7 +136,6 @@ namespace OpenSim.Framework.Monitoring
129 Watchdog.AddThread(twi, name, log:log); 136 Watchdog.AddThread(twi, name, log:log);
130 137
131 thread.Start(); 138 thread.Start();
132 thread.Name = name;
133 139
134 return thread; 140 return thread;
135 } 141 }
@@ -143,7 +149,7 @@ namespace OpenSim.Framework.Monitoring
143 /// <param name="name">Name of the thread</param> 149 /// <param name="name">Name of the thread</param>
144 public static void RunInThread(WaitCallback callback, object obj, string name, bool log = false) 150 public static void RunInThread(WaitCallback callback, object obj, string name, bool log = false)
145 { 151 {
146 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 152 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
147 { 153 {
148 Culture.SetCurrentCulture(); 154 Culture.SetCurrentCulture();
149 callback(obj); 155 callback(obj);
@@ -168,7 +174,7 @@ namespace OpenSim.Framework.Monitoring
168 } 174 }
169 175
170 /// <summary> 176 /// <summary>
171 /// Run the callback via a threadpool thread. 177 /// Run the callback via a threadpool thread.
172 /// </summary> 178 /// </summary>
173 /// <remarks> 179 /// <remarks>
174 /// Such jobs may run after some delay but must always complete. 180 /// Such jobs may run after some delay but must always complete.
@@ -176,9 +182,9 @@ namespace OpenSim.Framework.Monitoring
176 /// <param name="callback"></param> 182 /// <param name="callback"></param>
177 /// <param name="obj"></param> 183 /// <param name="obj"></param>
178 /// <param name="name">The name of the job. This is used in monitoring and debugging.</param> 184 /// <param name="name">The name of the job. This is used in monitoring and debugging.</param>
179 public static void RunInThreadPool(System.Threading.WaitCallback callback, object obj, string name) 185 public static void RunInThreadPool(System.Threading.WaitCallback callback, object obj, string name, bool timeout = true)
180 { 186 {
181 Util.FireAndForget(callback, obj, name); 187 Util.FireAndForget(callback, obj, name, timeout);
182 } 188 }
183 189
184 /// <summary> 190 /// <summary>
@@ -187,17 +193,17 @@ namespace OpenSim.Framework.Monitoring
187 /// <remarks> 193 /// <remarks>
188 /// This differs from direct scheduling (e.g. Util.FireAndForget) in that a job can be run in the job 194 /// This differs from direct scheduling (e.g. Util.FireAndForget) in that a job can be run in the job
189 /// engine if it is running, where all jobs are currently performed in sequence on a single thread. This is 195 /// engine if it is running, where all jobs are currently performed in sequence on a single thread. This is
190 /// to prevent observed overload and server freeze problems when there are hundreds of connections which all attempt to 196 /// to prevent observed overload and server freeze problems when there are hundreds of connections which all attempt to
191 /// perform work at once (e.g. in conference situations). With lower numbers of connections, the small 197 /// perform work at once (e.g. in conference situations). With lower numbers of connections, the small
192 /// delay in performing jobs in sequence rather than concurrently has not been notiecable in testing, though a future more 198 /// delay in performing jobs in sequence rather than concurrently has not been notiecable in testing, though a future more
193 /// sophisticated implementation could perform jobs concurrently when the server is under low load. 199 /// sophisticated implementation could perform jobs concurrently when the server is under low load.
194 /// 200 ///
195 /// However, be advised that some callers of this function rely on all jobs being performed in sequence if any 201 /// However, be advised that some callers of this function rely on all jobs being performed in sequence if any
196 /// jobs are performed in sequence (i.e. if jobengine is active or not). Therefore, expanding the jobengine 202 /// jobs are performed in sequence (i.e. if jobengine is active or not). Therefore, expanding the jobengine
197 /// beyond a single thread will require considerable thought. 203 /// beyond a single thread will require considerable thought.
198 /// 204 ///
199 /// Also, any jobs submitted must be guaranteed to complete within a reasonable timeframe (e.g. they cannot 205 /// Also, any jobs submitted must be guaranteed to complete within a reasonable timeframe (e.g. they cannot
200 /// incorporate a network delay with a long timeout). At the moment, work that could suffer such issues 206 /// incorporate a network delay with a long timeout). At the moment, work that could suffer such issues
201 /// should still be run directly with RunInThread(), Util.FireAndForget(), etc. This is another area where 207 /// should still be run directly with RunInThread(), Util.FireAndForget(), etc. This is another area where
202 /// the job engine could be improved and so CPU utilization improved by better management of concurrency within 208 /// the job engine could be improved and so CPU utilization improved by better management of concurrency within
203 /// OpenSimulator. 209 /// OpenSimulator.
@@ -211,10 +217,10 @@ namespace OpenSim.Framework.Monitoring
211 /// <param name="log">If set to true then extra logging is performed.</param> 217 /// <param name="log">If set to true then extra logging is performed.</param>
212 public static void RunJob( 218 public static void RunJob(
213 string jobType, WaitCallback callback, object obj, string name, 219 string jobType, WaitCallback callback, object obj, string name,
214 bool canRunInThisThread = false, bool mustNotTimeout = false, 220 bool canRunInThisThread = false, bool mustNotTimeout = false,
215 bool log = false) 221 bool log = false)
216 { 222 {
217 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 223 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
218 { 224 {
219 Culture.SetCurrentCulture(); 225 Culture.SetCurrentCulture();
220 callback(obj); 226 callback(obj);
@@ -225,10 +231,8 @@ namespace OpenSim.Framework.Monitoring
225 JobEngine.QueueJob(name, () => callback(obj)); 231 JobEngine.QueueJob(name, () => callback(obj));
226 else if (canRunInThisThread) 232 else if (canRunInThisThread)
227 callback(obj); 233 callback(obj);
228 else if (mustNotTimeout)
229 RunInThread(callback, obj, name, log);
230 else 234 else
231 Util.FireAndForget(callback, obj, name); 235 Util.FireAndForget(callback, obj, name, !mustNotTimeout);
232 } 236 }
233 237
234 private static void HandleControlCommand(string module, string[] args) 238 private static void HandleControlCommand(string module, string[] args)
@@ -272,16 +276,16 @@ namespace OpenSim.Framework.Monitoring
272 MainConsole.Instance.Output("Usage: debug jobengine log <level>"); 276 MainConsole.Instance.Output("Usage: debug jobengine log <level>");
273 return; 277 return;
274 } 278 }
275 279
276 // int logLevel; 280 // int logLevel;
277 int logLevel = int.Parse(args[3]); 281 int logLevel = int.Parse(args[3]);
278 // if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel)) 282 // if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel))
279 // { 283 // {
280 JobEngine.LogLevel = logLevel; 284 JobEngine.LogLevel = logLevel;
281 MainConsole.Instance.OutputFormat("Set debug log level to {0}", JobEngine.LogLevel); 285 MainConsole.Instance.OutputFormat("Set debug log level to {0}", JobEngine.LogLevel);
282 // } 286 // }
283 } 287 }
284 else 288 else
285 { 289 {
286 MainConsole.Instance.OutputFormat("Unrecognized job engine subcommand {0}", subCommand); 290 MainConsole.Instance.OutputFormat("Unrecognized job engine subcommand {0}", subCommand);
287 } 291 }
diff --git a/OpenSim/Framework/MuteData.cs b/OpenSim/Framework/MuteData.cs
new file mode 100644
index 0000000..7c946d6
--- /dev/null
+++ b/OpenSim/Framework/MuteData.cs
@@ -0,0 +1,41 @@
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 OpenMetaverse;
29
30namespace OpenSim.Framework
31{
32 public class MuteData
33 {
34 public UUID AgentID;
35 public UUID MuteID;
36 public string MuteName;
37 public int MuteType;
38 public int MuteFlags;
39 public int Stamp;
40 }
41}
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs
index 4b7d4c7..dfe9695 100644
--- a/OpenSim/Framework/NetworkServersInfo.cs
+++ b/OpenSim/Framework/NetworkServersInfo.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Framework
41 41
42 // "Out of band" managemnt https 42 // "Out of band" managemnt https
43 public bool ssl_listener = false; 43 public bool ssl_listener = false;
44 public bool ssl_external = false;
44 public uint https_port = 0; 45 public uint https_port = 0;
45 public string cert_path = String.Empty; 46 public string cert_path = String.Empty;
46 public string cert_pass = String.Empty; 47 public string cert_pass = String.Empty;
@@ -64,6 +65,7 @@ namespace OpenSim.Framework
64 65
65 // "Out of band management https" 66 // "Out of band management https"
66 ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); 67 ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false);
68 ssl_external = config.Configs["Network"].GetBoolean("https_external",false);
67 if( ssl_listener) 69 if( ssl_listener)
68 { 70 {
69 cert_path = config.Configs["Network"].GetString("cert_path",String.Empty); 71 cert_path = config.Configs["Network"].GetString("cert_path",String.Empty);
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs
index 2e94b0d..93c9446 100644
--- a/OpenSim/Framework/NetworkUtil.cs
+++ b/OpenSim/Framework/NetworkUtil.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework
40 /// Handles NAT translation in a 'manner of speaking' 40 /// Handles NAT translation in a 'manner of speaking'
41 /// Allows you to return multiple different external 41 /// Allows you to return multiple different external
42 /// hostnames depending on the requestors network 42 /// hostnames depending on the requestors network
43 /// 43 ///
44 /// This enables standard port forwarding techniques 44 /// This enables standard port forwarding techniques
45 /// to work correctly with OpenSim. 45 /// to work correctly with OpenSim.
46 /// </summary> 46 /// </summary>
@@ -145,7 +145,7 @@ namespace OpenSim.Framework
145 byte[] subnetBytes = subnet.Value.GetAddressBytes(); 145 byte[] subnetBytes = subnet.Value.GetAddressBytes();
146 byte[] localBytes = subnet.Key.GetAddressBytes(); 146 byte[] localBytes = subnet.Key.GetAddressBytes();
147 byte[] destBytes = destination.GetAddressBytes(); 147 byte[] destBytes = destination.GetAddressBytes();
148 148
149 if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length) 149 if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length)
150 return null; 150 return null;
151 151
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs
index 455756d..7450be2 100644
--- a/OpenSim/Framework/OSChatMessage.cs
+++ b/OpenSim/Framework/OSChatMessage.cs
@@ -51,12 +51,11 @@ namespace OpenSim.Framework
51 protected object m_senderObject; 51 protected object m_senderObject;
52 protected ChatTypeEnum m_type; 52 protected ChatTypeEnum m_type;
53 protected UUID m_fromID; 53 protected UUID m_fromID;
54 protected UUID m_toID; 54 protected UUID m_destination = UUID.Zero;
55 55
56 public OSChatMessage() 56 public OSChatMessage()
57 { 57 {
58 m_position = new Vector3(); 58 m_position = new Vector3();
59 m_toID = UUID.Zero;
60 } 59 }
61 60
62 /// <summary> 61 /// <summary>
@@ -104,15 +103,6 @@ namespace OpenSim.Framework
104 set { m_from = value; } 103 set { m_from = value; }
105 } 104 }
106 105
107 /// <summary>
108 /// The name of the sender (needed for scripts)
109 /// </summary>
110 public string To
111 {
112 get { return m_from; }
113 set { m_from = value; }
114 }
115
116 #region IEventArgs Members 106 #region IEventArgs Members
117 107
118 /// TODO: Sender and SenderObject should just be Sender and of 108 /// TODO: Sender and SenderObject should just be Sender and of
@@ -142,13 +132,10 @@ namespace OpenSim.Framework
142 set { m_fromID = value; } 132 set { m_fromID = value; }
143 } 133 }
144 134
145 /// <summary> 135 public UUID Destination
146 /// The single recipient or all if not set.
147 /// </summary>
148 public UUID TargetUUID
149 { 136 {
150 get { return m_toID; } 137 get { return m_destination; }
151 set { m_toID = value; } 138 set { m_destination = value; }
152 } 139 }
153 140
154 /// <summary> 141 /// <summary>
diff --git a/OpenSim/Framework/ObjectChangeData.cs b/OpenSim/Framework/ObjectChangeData.cs
new file mode 100644
index 0000000..8d56291
--- /dev/null
+++ b/OpenSim/Framework/ObjectChangeData.cs
@@ -0,0 +1,80 @@
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 OpenMetaverse;
29
30namespace OpenSim.Framework
31{
32 public enum ObjectChangeType : uint
33 {
34 // bits definitions
35 Position = 0x01,
36 Rotation = 0x02,
37 Scale = 0x04,
38 Group = 0x08,
39 UniformScale = 0x10,
40
41 // macros from above
42 // single prim
43 primP = 0x01,
44 primR = 0x02,
45 primPR = 0x03,
46 primS = 0x04,
47 primPS = 0x05,
48 primRS = 0x06,
49 primPSR = 0x07,
50
51 primUS = 0x14,
52 primPUS = 0x15,
53 primRUS = 0x16,
54 primPUSR = 0x17,
55
56 // group
57 groupP = 0x09,
58 groupR = 0x0A,
59 groupPR = 0x0B,
60 groupS = 0x0C,
61 groupPS = 0x0D,
62 groupRS = 0x0E,
63 groupPSR = 0x0F,
64
65 groupUS = 0x1C,
66 groupPUS = 0x1D,
67 groupRUS = 0x1E,
68 groupPUSR = 0x1F,
69
70 PRSmask = 0x07
71 }
72
73 public struct ObjectChangeData
74 {
75 public Quaternion rotation;
76 public Vector3 position;
77 public Vector3 scale;
78 public ObjectChangeType change;
79 }
80}
diff --git a/OpenSim/Framework/OutboundUrlFilter.cs b/OpenSim/Framework/OutboundUrlFilter.cs
index baa3647..63ae361 100644
--- a/OpenSim/Framework/OutboundUrlFilter.cs
+++ b/OpenSim/Framework/OutboundUrlFilter.cs
@@ -49,8 +49,8 @@ namespace OpenSim.Framework
49 private List<IPEndPoint> m_blacklistExceptionEndPoints; 49 private List<IPEndPoint> m_blacklistExceptionEndPoints;
50 50
51 public OutboundUrlFilter( 51 public OutboundUrlFilter(
52 string name, 52 string name,
53 List<IPNetwork> blacklistNetworks, List<IPEndPoint> blacklistEndPoints, 53 List<IPNetwork> blacklistNetworks, List<IPEndPoint> blacklistEndPoints,
54 List<IPNetwork> blacklistExceptionNetworks, List<IPEndPoint> blacklistExceptionEndPoints) 54 List<IPNetwork> blacklistExceptionNetworks, List<IPEndPoint> blacklistExceptionEndPoints)
55 { 55 {
56 Name = name; 56 Name = name;
@@ -79,7 +79,7 @@ namespace OpenSim.Framework
79 if (networkConfig != null) 79 if (networkConfig != null)
80 { 80 {
81 configBlacklist = networkConfig.GetString("OutboundDisallowForUserScripts", configBlacklist); 81 configBlacklist = networkConfig.GetString("OutboundDisallowForUserScripts", configBlacklist);
82 configBlacklistExceptions 82 configBlacklistExceptions
83 = networkConfig.GetString("OutboundDisallowForUserScriptsExcept", configBlacklistExceptions); 83 = networkConfig.GetString("OutboundDisallowForUserScriptsExcept", configBlacklistExceptions);
84 } 84 }
85 85
@@ -98,7 +98,7 @@ namespace OpenSim.Framework
98 string fullConfigEntry, string filterName, out List<IPNetwork> networks, out List<IPEndPoint> endPoints) 98 string fullConfigEntry, string filterName, out List<IPNetwork> networks, out List<IPEndPoint> endPoints)
99 { 99 {
100 // Parse blacklist 100 // Parse blacklist
101 string[] configBlacklistEntries 101 string[] configBlacklistEntries
102 = fullConfigEntry.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); 102 = fullConfigEntry.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
103 103
104 configBlacklistEntries = configBlacklistEntries.Select(e => e.Trim()).ToArray(); 104 configBlacklistEntries = configBlacklistEntries.Select(e => e.Trim()).ToArray();
@@ -129,7 +129,7 @@ namespace OpenSim.Framework
129 if (!Uri.TryCreate("http://" + configEntry, UriKind.Absolute, out configEntryUri)) 129 if (!Uri.TryCreate("http://" + configEntry, UriKind.Absolute, out configEntryUri))
130 { 130 {
131 m_log.ErrorFormat( 131 m_log.ErrorFormat(
132 "[OUTBOUND URL FILTER]: EndPoint entry [{0}] is invalid endpoint for {1}", 132 "[OUTBOUND URL FILTER]: EndPoint entry [{0}] is invalid endpoint for {1}",
133 configEntry, filterName); 133 configEntry, filterName);
134 134
135 continue; 135 continue;
@@ -184,14 +184,14 @@ namespace OpenSim.Framework
184 foreach (IPEndPoint ep in endPoints) 184 foreach (IPEndPoint ep in endPoints)
185 { 185 {
186// m_log.DebugFormat( 186// m_log.DebugFormat(
187// "[OUTBOUND URL FILTER]: Checking [{0}:{1}] against endpoint [{2}]", 187// "[OUTBOUND URL FILTER]: Checking [{0}:{1}] against endpoint [{2}]",
188// addr, port, ep); 188// addr, port, ep);
189 189
190 if (addr.Equals(ep.Address) && port == ep.Port) 190 if (addr.Equals(ep.Address) && port == ep.Port)
191 { 191 {
192// m_log.DebugFormat( 192// m_log.DebugFormat(
193// "[OUTBOUND URL FILTER]: Found [{0}:{1}] in endpoint [{2}]", addr, port, ep); 193// "[OUTBOUND URL FILTER]: Found [{0}:{1}] in endpoint [{2}]", addr, port, ep);
194 194
195 return true; 195 return true;
196 } 196 }
197 } 197 }
@@ -212,7 +212,17 @@ namespace OpenSim.Framework
212 // Check that we are permitted to make calls to this endpoint. 212 // Check that we are permitted to make calls to this endpoint.
213 bool foundIpv4Address = false; 213 bool foundIpv4Address = false;
214 214
215 IPAddress[] addresses = Dns.GetHostAddresses(url.Host); 215 IPAddress[] addresses = null;
216
217 try
218 {
219 addresses = Dns.GetHostAddresses(url.Host);
220 }
221 catch
222 {
223 // If there is a DNS error, we can't stop the script!
224 return true;
225 }
216 226
217 foreach (IPAddress addr in addresses) 227 foreach (IPAddress addr in addresses)
218 { 228 {
@@ -228,7 +238,7 @@ namespace OpenSim.Framework
228// m_log.DebugFormat("[OUTBOUND URL FILTER]: Found [{0}] in blacklist for {1}", url, Name); 238// m_log.DebugFormat("[OUTBOUND URL FILTER]: Found [{0}] in blacklist for {1}", url, Name);
229 239
230 // Check blacklist exceptions 240 // Check blacklist exceptions
231 allowed 241 allowed
232 = OutboundUrlFilter.IsInNetwork( 242 = OutboundUrlFilter.IsInNetwork(
233 addr, url.Port, m_blacklistExceptionNetworks, m_blacklistExceptionEndPoints, Name); 243 addr, url.Port, m_blacklistExceptionNetworks, m_blacklistExceptionEndPoints, Name);
234 244
@@ -253,4 +263,4 @@ namespace OpenSim.Framework
253 return allowed; 263 return allowed;
254 } 264 }
255 } 265 }
256} \ No newline at end of file 266}
diff --git a/OpenSim/Framework/ParcelMediaCommandEnum.cs b/OpenSim/Framework/ParcelMediaCommandEnum.cs
index 93c41ec..e714382 100644
--- a/OpenSim/Framework/ParcelMediaCommandEnum.cs
+++ b/OpenSim/Framework/ParcelMediaCommandEnum.cs
@@ -27,7 +27,7 @@
27 27
28namespace OpenSim.Framework 28namespace OpenSim.Framework
29{ 29{
30 public enum ParcelMediaCommandEnum 30 public enum ParcelMediaCommandEnum : int
31 { 31 {
32 Stop = 0, 32 Stop = 0,
33 Pause = 1, 33 Pause = 1,
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
index d785a78..e50d4df 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -60,28 +60,57 @@ namespace OpenSim.Framework
60 str += "C"; 60 str += "C";
61 if ((perms & (int)PermissionMask.Transfer) != 0) 61 if ((perms & (int)PermissionMask.Transfer) != 0)
62 str += "T"; 62 str += "T";
63 if ((perms & (int)PermissionMask.Export) != 0)
64 str += "X";
63 if (str == "") 65 if (str == "")
64 str = "."; 66 str = ".";
65 return str; 67 return str;
66 } 68 }
67 69
68 /// <summary> 70 public static void ApplyFoldedPermissions(uint foldedSourcePerms, ref uint targetPerms)
69 /// Applies an object's folded permissions to its regular permissions. 71 {
70 /// </summary> 72 uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
71 /// <param name="foldedPerms">The folded permissions. Only the lowest 7 bits are examined.</param> 73 if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do
72 /// <param name="mainPerms">The permissions variable to modify.</param> 74 return;
73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) 75
76 folded <<= (int)PermissionMask.FoldingShift;
77 folded |= ~(uint)PermissionMask.UnfoldedMask;
78
79 uint tmp = targetPerms;
80 tmp &= folded;
81 targetPerms = tmp;
82 }
83
84 // do not touch MOD
85 public static void ApplyNoModFoldedPermissions(uint foldedSourcePerms, ref uint target)
74 { 86 {
75 if ((foldedPerms & 7) == 0) 87 uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask;
76 return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded 88 if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do
89 return;
77 90
78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) 91 folded <<= (int)PermissionMask.FoldingShift;
79 mainPerms &= ~(uint)PermissionMask.Copy; 92 folded |= (~(uint)PermissionMask.UnfoldedMask | (uint)PermissionMask.Modify);
80 if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0) 93
81 mainPerms &= ~(uint)PermissionMask.Transfer; 94 uint tmp = target;
82 if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0) 95 tmp &= folded;
83 mainPerms &= ~(uint)PermissionMask.Modify; 96 target = tmp;
84 } 97 }
85 98
99 public static uint FixAndFoldPermissions(uint perms)
100 {
101 uint tmp = perms;
102
103 // C & T rule
104 if((tmp & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0)
105 tmp |= (uint)PermissionMask.Transfer;
106
107 // unlock
108 tmp |= (uint)PermissionMask.Move;
109
110 tmp &= ~(uint)PermissionMask.FoldedMask;
111 tmp |= ((tmp >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask);
112
113 return tmp;
114 }
86 } 115 }
87} 116}
diff --git a/OpenSim/Framework/PhysicsInertia.cs b/OpenSim/Framework/PhysicsInertia.cs
new file mode 100644
index 0000000..fa83de8
--- /dev/null
+++ b/OpenSim/Framework/PhysicsInertia.cs
@@ -0,0 +1,263 @@
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 OpenMetaverse;
31using System.Text;
32using System.IO;
33using System.Xml;
34
35namespace OpenSim.Framework
36{
37 public class PhysicsInertiaData
38 {
39 public float TotalMass; // the total mass of a linkset
40 public Vector3 CenterOfMass; // the center of mass position relative to root part position
41 public Vector3 Inertia; // (Ixx, Iyy, Izz) moment of inertia relative to center of mass and principal axis in local coords
42 public Vector4 InertiaRotation; // if principal axis don't match local axis, the principal axis rotation
43 // or the upper triangle of the inertia tensor
44 // Ixy (= Iyx), Ixz (= Izx), Iyz (= Izy))
45
46 public PhysicsInertiaData()
47 {
48 }
49
50 public PhysicsInertiaData(PhysicsInertiaData source)
51 {
52 TotalMass = source.TotalMass;
53 CenterOfMass = source.CenterOfMass;
54 Inertia = source.Inertia;
55 InertiaRotation = source.InertiaRotation;
56 }
57
58 private XmlTextWriter writer;
59
60 private void XWint(string name, int i)
61 {
62 writer.WriteElementString(name, i.ToString());
63 }
64
65 private void XWfloat(string name, float f)
66 {
67 writer.WriteElementString(name, f.ToString(Culture.FormatProvider));
68 }
69
70 private void XWVector(string name, Vector3 vec)
71 {
72 writer.WriteStartElement(name);
73 writer.WriteElementString("X", vec.X.ToString(Culture.FormatProvider));
74 writer.WriteElementString("Y", vec.Y.ToString(Culture.FormatProvider));
75 writer.WriteElementString("Z", vec.Z.ToString(Culture.FormatProvider));
76 writer.WriteEndElement();
77 }
78
79 private void XWVector4(string name, Vector4 quat)
80 {
81 writer.WriteStartElement(name);
82 writer.WriteElementString("X", quat.X.ToString(Culture.FormatProvider));
83 writer.WriteElementString("Y", quat.Y.ToString(Culture.FormatProvider));
84 writer.WriteElementString("Z", quat.Z.ToString(Culture.FormatProvider));
85 writer.WriteElementString("W", quat.W.ToString(Culture.FormatProvider));
86 writer.WriteEndElement();
87 }
88
89 public void ToXml2(XmlTextWriter twriter)
90 {
91 writer = twriter;
92 writer.WriteStartElement("PhysicsInertia");
93
94 XWfloat("MASS", TotalMass);
95 XWVector("CM", CenterOfMass);
96 XWVector("INERTIA", Inertia);
97 XWVector4("IROT", InertiaRotation);
98
99 writer.WriteEndElement();
100 writer = null;
101 }
102
103 XmlReader reader;
104
105 private int XRint()
106 {
107 return reader.ReadElementContentAsInt();
108 }
109
110 private float XRfloat()
111 {
112 return reader.ReadElementContentAsFloat();
113 }
114
115 public Vector3 XRvector()
116 {
117 Vector3 vec;
118 reader.ReadStartElement();
119 vec.X = reader.ReadElementContentAsFloat();
120 vec.Y = reader.ReadElementContentAsFloat();
121 vec.Z = reader.ReadElementContentAsFloat();
122 reader.ReadEndElement();
123 return vec;
124 }
125
126 public Vector4 XRVector4()
127 {
128 Vector4 q;
129 reader.ReadStartElement();
130 q.X = reader.ReadElementContentAsFloat();
131 q.Y = reader.ReadElementContentAsFloat();
132 q.Z = reader.ReadElementContentAsFloat();
133 q.W = reader.ReadElementContentAsFloat();
134 reader.ReadEndElement();
135 return q;
136 }
137
138 public static bool EReadProcessors(
139 Dictionary<string, Action> processors,
140 XmlReader xtr)
141 {
142 bool errors = false;
143
144 string nodeName = string.Empty;
145 while (xtr.NodeType != XmlNodeType.EndElement)
146 {
147 nodeName = xtr.Name;
148
149 Action p = null;
150 if (processors.TryGetValue(xtr.Name, out p))
151 {
152 try
153 {
154 p();
155 }
156 catch
157 {
158 errors = true;
159 if (xtr.NodeType == XmlNodeType.EndElement)
160 xtr.Read();
161 }
162 }
163 else
164 {
165 xtr.ReadOuterXml(); // ignore
166 }
167 }
168
169 return errors;
170 }
171
172 public string ToXml2()
173 {
174 using (StringWriter sw = new StringWriter())
175 {
176 using (XmlTextWriter xwriter = new XmlTextWriter(sw))
177 {
178 ToXml2(xwriter);
179 }
180
181 return sw.ToString();
182 }
183 }
184
185 public static PhysicsInertiaData FromXml2(string text)
186 {
187 if (text == String.Empty)
188 return null;
189
190 bool error;
191 PhysicsInertiaData v;
192 UTF8Encoding enc = new UTF8Encoding();
193 using(MemoryStream ms = new MemoryStream(enc.GetBytes(text)))
194 using(XmlTextReader xreader = new XmlTextReader(ms))
195 {
196 xreader.ProhibitDtd = true;
197
198 v = new PhysicsInertiaData();
199 v.FromXml2(xreader, out error);
200 }
201
202 if (error)
203 return null;
204
205 return v;
206 }
207
208 public static PhysicsInertiaData FromXml2(XmlReader reader)
209 {
210 PhysicsInertiaData data = new PhysicsInertiaData();
211
212 bool errors = false;
213
214 data.FromXml2(reader, out errors);
215 if (errors)
216 return null;
217
218 return data;
219 }
220
221 private void FromXml2(XmlReader _reader, out bool errors)
222 {
223 errors = false;
224 reader = _reader;
225
226 Dictionary<string, Action> m_XmlProcessors = new Dictionary<string, Action>();
227
228 m_XmlProcessors.Add("MASS", ProcessXR_Mass);
229 m_XmlProcessors.Add("CM", ProcessXR_CM);
230 m_XmlProcessors.Add("INERTIA", ProcessXR_Inertia);
231 m_XmlProcessors.Add("IROT", ProcessXR_InertiaRotation);
232
233 reader.ReadStartElement("PhysicsInertia", String.Empty);
234
235 errors = EReadProcessors(
236 m_XmlProcessors,
237 reader);
238
239 reader.ReadEndElement();
240 reader = null;
241 }
242
243 private void ProcessXR_Mass()
244 {
245 TotalMass = XRfloat();
246 }
247
248 private void ProcessXR_CM()
249 {
250 CenterOfMass = XRvector();
251 }
252
253 private void ProcessXR_Inertia()
254 {
255 Inertia = XRvector();
256 }
257
258 private void ProcessXR_InertiaRotation()
259 {
260 InertiaRotation = XRVector4();
261 }
262 }
263}
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index d12aa61..1e5e8bf 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -245,13 +245,22 @@ namespace OpenSim.Framework
245 // occasionally seems to corrupt its addin cache 245 // occasionally seems to corrupt its addin cache
246 // Hence, as a temporary solution we'll remove it before each startup 246 // Hence, as a temporary solution we'll remove it before each startup
247 247
248 string customDir = Environment.GetEnvironmentVariable ("MONO_ADDINS_REGISTRY");
249 string v0 = "addin-db-000";
250 string v1 = "addin-db-001";
251 if (customDir != null && customDir != String.Empty)
252 {
253 v0 = Path.Combine(customDir, v0);
254 v1 = Path.Combine(customDir, v1);
255 }
248 try 256 try
249 { 257 {
250 if (Directory.Exists(dir + "/addin-db-000")) 258 if (Directory.Exists(v0))
251 Directory.Delete(dir + "/addin-db-000", true); 259 Directory.Delete(v0, true);
260
261 if (Directory.Exists(v1))
262 Directory.Delete(v1, true);
252 263
253 if (Directory.Exists(dir + "/addin-db-001"))
254 Directory.Delete(dir + "/addin-db-001", true);
255 } 264 }
256 catch (IOException) 265 catch (IOException)
257 { 266 {
diff --git a/OpenSim/Framework/PluginManager.cs b/OpenSim/Framework/PluginManager.cs
index 0117096..0c94fcb 100644
--- a/OpenSim/Framework/PluginManager.cs
+++ b/OpenSim/Framework/PluginManager.cs
@@ -44,17 +44,17 @@ namespace OpenSim.Framework
44 /// <summary> 44 /// <summary>
45 /// Manager for registries and plugins 45 /// Manager for registries and plugins
46 /// </summary> 46 /// </summary>
47 public class PluginManager : SetupService 47 public class PluginManager : SetupService
48 { 48 {
49 public AddinRegistry PluginRegistry; 49 public AddinRegistry PluginRegistry;
50 50
51 public PluginManager(AddinRegistry registry): base (registry) 51 public PluginManager(AddinRegistry registry): base (registry)
52 { 52 {
53 PluginRegistry = registry; 53 PluginRegistry = registry;
54 54
55 } 55 }
56 56
57 /// <summary> 57 /// <summary>
58 /// Installs the plugin. 58 /// Installs the plugin.
59 /// </summary> 59 /// </summary>
60 /// <returns> 60 /// <returns>
@@ -97,14 +97,14 @@ namespace OpenSim.Framework
97 Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id); 97 Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id);
98 PluginRegistry.DisableAddin(addin.Id); 98 PluginRegistry.DisableAddin(addin.Id);
99 addin.Enabled = false; 99 addin.Enabled = false;
100 100
101 MainConsole.Instance.Output("Installation Success"); 101 MainConsole.Instance.Output("Installation Success");
102 ListInstalledAddins(out res); 102 ListInstalledAddins(out res);
103 result = res; 103 result = res;
104 return true; 104 return true;
105 } 105 }
106 else 106 else
107 { 107 {
108 MainConsole.Instance.Output("Installation Failed"); 108 MainConsole.Instance.Output("Installation Failed");
109 result = res; 109 result = res;
110 return false; 110 return false;
@@ -159,11 +159,11 @@ namespace OpenSim.Framework
159 { 159 {
160 Dictionary<string, object> res = new Dictionary<string, object>(); 160 Dictionary<string, object> res = new Dictionary<string, object>();
161 161
162 Addin[] addins = GetSortedAddinList("RobustPlugin"); 162 Addin[] addins = GetSortedAddinList("RobustPlugin");
163 if(addins.Count() < 1) 163 if(addins.Count() < 1)
164 { 164 {
165 MainConsole.Instance.Output("Error!"); 165 MainConsole.Instance.Output("Error!");
166 } 166 }
167 int count = 0; 167 int count = 0;
168 foreach (Addin addin in addins) 168 foreach (Addin addin in addins)
169 { 169 {
@@ -377,7 +377,7 @@ namespace OpenSim.Framework
377 r["enabled"] = rep.Enabled == true ? true : false; 377 r["enabled"] = rep.Enabled == true ? true : false;
378 r["name"] = rep.Name; 378 r["name"] = rep.Name;
379 r["url"] = rep.Url; 379 r["url"] = rep.Url;
380 380
381 res.Add(count.ToString(), r); 381 res.Add(count.ToString(), r);
382 count++; 382 count++;
383 } 383 }
@@ -493,7 +493,7 @@ namespace OpenSim.Framework
493 } 493 }
494 494
495 495
496 496
497 #region Util 497 #region Util
498 private void Testing() 498 private void Testing()
499 { 499 {
@@ -537,15 +537,15 @@ namespace OpenSim.Framework
537 537
538 ArrayList xlist = new ArrayList(); 538 ArrayList xlist = new ArrayList();
539 ArrayList list = new ArrayList(); 539 ArrayList list = new ArrayList();
540 try 540 try
541 { 541 {
542 list.AddRange(PluginRegistry.GetAddins()); 542 list.AddRange(PluginRegistry.GetAddins());
543 } 543 }
544 catch (Exception) 544 catch (Exception)
545 { 545 {
546 Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[]; 546 Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
547 return x; 547 return x;
548 } 548 }
549 549
550 foreach (Addin addin in list) 550 foreach (Addin addin in list)
551 { 551 {
@@ -559,5 +559,5 @@ namespace OpenSim.Framework
559 return addins; 559 return addins;
560 } 560 }
561 #endregion Util 561 #endregion Util
562 } 562 }
563} 563}
diff --git a/OpenSim/Framework/PrimeNumberHelper.cs b/OpenSim/Framework/PrimeNumberHelper.cs
index 477c274..5a1b3b2 100644
--- a/OpenSim/Framework/PrimeNumberHelper.cs
+++ b/OpenSim/Framework/PrimeNumberHelper.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Framework
35 public static class PrimeNumberHelper 35 public static class PrimeNumberHelper
36 { 36 {
37 /// <summary> 37 /// <summary>
38 /// Precalculated prime numbers. 38 /// Precalculated prime numbers.
39 /// </summary> 39 /// </summary>
40 private static readonly int[] Primes = new int[] 40 private static readonly int[] Primes = new int[]
41 { 41 {
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index c8a5376..6e7a038 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -238,8 +238,8 @@ namespace OpenSim.Framework
238 SculptTexture = prim.Sculpt.SculptTexture; 238 SculptTexture = prim.Sculpt.SculptTexture;
239 SculptType = (byte)prim.Sculpt.Type; 239 SculptType = (byte)prim.Sculpt.Type;
240 } 240 }
241 else 241 else
242 { 242 {
243 SculptType = (byte)OpenMetaverse.SculptType.None; 243 SculptType = (byte)OpenMetaverse.SculptType.None;
244 } 244 }
245 } 245 }
@@ -328,6 +328,72 @@ namespace OpenSim.Framework
328 return shape; 328 return shape;
329 } 329 }
330 330
331 public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID)
332 {
333 PrimitiveBaseShape shape = new PrimitiveBaseShape();
334
335 shape._pathScaleX = 100;
336 shape._pathScaleY = 100;
337
338 if(numberOfFaces <= 0) // oops ?
339 numberOfFaces = 1;
340
341 switch(numberOfFaces)
342 {
343 case 1: // torus
344 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
345 shape.PathCurve = (byte)Extrusion.Curve1;
346 shape._pathScaleY = 150;
347 break;
348
349 case 2: // torus with hollow (a sl viewer whould see 4 faces on a hollow sphere)
350 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
351 shape.PathCurve = (byte)Extrusion.Curve1;
352 shape.ProfileHollow = 27500;
353 shape._pathScaleY = 150;
354 break;
355
356 case 3: // cylinder
357 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
358 shape.PathCurve = (byte)Extrusion.Straight;
359 break;
360
361 case 4: // cylinder with hollow
362 shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle;
363 shape.PathCurve = (byte)Extrusion.Straight;
364 shape.ProfileHollow = 27500;
365 break;
366
367 case 5: // prism
368 shape.ProfileCurve = (byte)ProfileShape.EquilateralTriangle | (byte)HollowShape.Triangle;
369 shape.PathCurve = (byte)Extrusion.Straight;
370 break;
371
372 case 6: // box
373 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
374 shape.PathCurve = (byte)Extrusion.Straight;
375 break;
376
377 case 7: // box with hollow
378 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
379 shape.PathCurve = (byte)Extrusion.Straight;
380 shape.ProfileHollow = 27500;
381 break;
382
383 default: // 8 faces box with cut
384 shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle;
385 shape.PathCurve = (byte)Extrusion.Straight;
386 shape.ProfileBegin = 9375;
387 break;
388 }
389
390 shape.SculptEntry = true;
391 shape.SculptType = (byte)OpenMetaverse.SculptType.Mesh;
392 shape.SculptTexture = meshAssetID;
393
394 return shape;
395 }
396
331 public void SetScale(float side) 397 public void SetScale(float side)
332 { 398 {
333 _scale = new Vector3(side, side, side); 399 _scale = new Vector3(side, side, side);
@@ -728,7 +794,12 @@ namespace OpenSim.Framework
728 return _lightColorR; 794 return _lightColorR;
729 } 795 }
730 set { 796 set {
731 _lightColorR = value; 797 if (value < 0)
798 _lightColorR = 0;
799 else if (value > 1.0f)
800 _lightColorR = 1.0f;
801 else
802 _lightColorR = value;
732 } 803 }
733 } 804 }
734 805
@@ -737,7 +808,12 @@ namespace OpenSim.Framework
737 return _lightColorG; 808 return _lightColorG;
738 } 809 }
739 set { 810 set {
740 _lightColorG = value; 811 if (value < 0)
812 _lightColorG = 0;
813 else if (value > 1.0f)
814 _lightColorG = 1.0f;
815 else
816 _lightColorG = value;
741 } 817 }
742 } 818 }
743 819
@@ -746,7 +822,12 @@ namespace OpenSim.Framework
746 return _lightColorB; 822 return _lightColorB;
747 } 823 }
748 set { 824 set {
749 _lightColorB = value; 825 if (value < 0)
826 _lightColorB = 0;
827 else if (value > 1.0f)
828 _lightColorB = 1.0f;
829 else
830 _lightColorB = value;
750 } 831 }
751 } 832 }
752 833
@@ -755,7 +836,12 @@ namespace OpenSim.Framework
755 return _lightColorA; 836 return _lightColorA;
756 } 837 }
757 set { 838 set {
758 _lightColorA = value; 839 if (value < 0)
840 _lightColorA = 0;
841 else if (value > 1.0f)
842 _lightColorA = 1.0f;
843 else
844 _lightColorA = value;
759 } 845 }
760 } 846 }
761 847
@@ -869,6 +955,11 @@ namespace OpenSim.Framework
869 955
870 public ulong GetMeshKey(Vector3 size, float lod) 956 public ulong GetMeshKey(Vector3 size, float lod)
871 { 957 {
958 return GetMeshKey(size, lod, false);
959 }
960
961 public ulong GetMeshKey(Vector3 size, float lod, bool convex)
962 {
872 ulong hash = 5381; 963 ulong hash = 5381;
873 964
874 hash = djb2(hash, this.PathCurve); 965 hash = djb2(hash, this.PathCurve);
@@ -914,6 +1005,9 @@ namespace OpenSim.Framework
914 hash = djb2(hash, scaleBytes[i]); 1005 hash = djb2(hash, scaleBytes[i]);
915 } 1006 }
916 1007
1008 if(convex)
1009 hash = djb2(hash, 0xa5);
1010
917 return hash; 1011 return hash;
918 } 1012 }
919 1013
@@ -1417,7 +1511,7 @@ namespace OpenSim.Framework
1417 prim.Textures = this.Textures; 1511 prim.Textures = this.Textures;
1418 1512
1419 prim.Properties = new Primitive.ObjectProperties(); 1513 prim.Properties = new Primitive.ObjectProperties();
1420 prim.Properties.Name = "Primitive"; 1514 prim.Properties.Name = "Object";
1421 prim.Properties.Description = ""; 1515 prim.Properties.Description = "";
1422 prim.Properties.CreatorID = UUID.Zero; 1516 prim.Properties.CreatorID = UUID.Zero;
1423 prim.Properties.GroupID = UUID.Zero; 1517 prim.Properties.GroupID = UUID.Zero;
@@ -1488,35 +1582,50 @@ namespace OpenSim.Framework
1488 { 1582 {
1489 MediaList ml = new MediaList(); 1583 MediaList ml = new MediaList();
1490 ml.ReadXml(rawXml); 1584 ml.ReadXml(rawXml);
1585 if(ml.Count == 0)
1586 return null;
1491 return ml; 1587 return ml;
1492 } 1588 }
1493 1589
1494 public void ReadXml(string rawXml) 1590 public void ReadXml(string rawXml)
1495 { 1591 {
1496 using (StringReader sr = new StringReader(rawXml)) 1592 try
1497 { 1593 {
1498 using (XmlTextReader xtr = new XmlTextReader(sr)) 1594 using (StringReader sr = new StringReader(rawXml))
1499 { 1595 {
1500 xtr.MoveToContent(); 1596 using (XmlTextReader xtr = new XmlTextReader(sr))
1597 {
1598 xtr.ProhibitDtd = true;
1501 1599
1502 string type = xtr.GetAttribute("type"); 1600 xtr.MoveToContent();
1503 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1504 1601
1505 if (type != MEDIA_TEXTURE_TYPE) 1602 string type = xtr.GetAttribute("type");
1506 return; 1603 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1507 1604
1508 xtr.ReadStartElement("OSMedia"); 1605 if (type != MEDIA_TEXTURE_TYPE)
1606 return;
1509 1607
1510 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); 1608 xtr.ReadStartElement("OSMedia");
1511 foreach (OSD osdMe in osdMeArray) 1609 OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1512 { 1610 if(osdp == null || !(osdp is OSDArray))
1513 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); 1611 return;
1514 Add(me);
1515 }
1516 1612
1517 xtr.ReadEndElement(); 1613 OSDArray osdMeArray = osdp as OSDArray;
1614 if(osdMeArray.Count == 0)
1615 return;
1616
1617 foreach (OSD osdMe in osdMeArray)
1618 {
1619 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
1620 Add(me);
1621 }
1622 }
1518 } 1623 }
1519 } 1624 }
1625 catch
1626 {
1627 m_log.Debug("PrimitiveBaseShape] error decoding MOAP xml" );
1628 }
1520 } 1629 }
1521 1630
1522 public void ReadXml(XmlReader reader) 1631 public void ReadXml(XmlReader reader)
diff --git a/OpenSim/Framework/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs
index e7a7f7f..22ffcdc 100644
--- a/OpenSim/Framework/PriorityQueue.cs
+++ b/OpenSim/Framework/PriorityQueue.cs
@@ -45,7 +45,8 @@ namespace OpenSim.Framework
45 /// <summary> 45 /// <summary>
46 /// Total number of queues (priorities) available 46 /// Total number of queues (priorities) available
47 /// </summary> 47 /// </summary>
48 public const uint NumberOfQueues = 12; 48
49 public const uint NumberOfQueues = 12; // includes immediate queues, m_queueCounts need to be set acording
49 50
50 /// <summary> 51 /// <summary>
51 /// Number of queuest (priorities) that are processed immediately 52 /// Number of queuest (priorities) that are processed immediately
@@ -56,11 +57,14 @@ namespace OpenSim.Framework
56 private Dictionary<uint, LookupItem> m_lookupTable; 57 private Dictionary<uint, LookupItem> m_lookupTable;
57 58
58 // internal state used to ensure the deqeues are spread across the priority 59 // internal state used to ensure the deqeues are spread across the priority
59 // queues "fairly". queuecounts is the amount to pull from each queue in 60 // queues "fairly". queuecounts is the amount to pull from each queue in
60 // each pass. weighted towards the higher priority queues 61 // each pass. weighted towards the higher priority queues
61 private uint m_nextQueue = 0; 62 private uint m_nextQueue = 0;
62 private uint m_countFromQueue = 0; 63 private uint m_countFromQueue = 0;
63 private uint[] m_queueCounts = { 8, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; 64 // first queues are imediate, so no counts
65// private uint[] m_queueCounts = { 0, 0, 8, 4, 4, 2, 2, 2, 2, 1, 1, 1 };
66 private uint[] m_queueCounts = {0, 0, 8, 8, 5, 4, 3, 2, 1, 1, 1, 1};
67 // this is ava, ava, attach, <10m, 20,40,80,160m,320,640,1280, +
64 68
65 // next request is a counter of the number of updates queued, it provides 69 // next request is a counter of the number of updates queued, it provides
66 // a total ordering on the updates coming through the queue and is more 70 // a total ordering on the updates coming through the queue and is more
@@ -101,7 +105,7 @@ namespace OpenSim.Framework
101 int count = 0; 105 int count = 0;
102 for (int i = 0; i < m_heaps.Length; ++i) 106 for (int i = 0; i < m_heaps.Length; ++i)
103 count += m_heaps[i].Count; 107 count += m_heaps[i].Count;
104 108
105 return count; 109 return count;
106 } 110 }
107 } 111 }
@@ -109,7 +113,7 @@ namespace OpenSim.Framework
109 /// <summary> 113 /// <summary>
110 /// Enqueue an item into the specified priority queue 114 /// Enqueue an item into the specified priority queue
111 /// </summary> 115 /// </summary>
112 public bool Enqueue(uint pqueue, IEntityUpdate value) 116 public bool Enqueue(uint pqueue, EntityUpdate value)
113 { 117 {
114 LookupItem lookup; 118 LookupItem lookup;
115 119
@@ -130,14 +134,29 @@ namespace OpenSim.Framework
130 return true; 134 return true;
131 } 135 }
132 136
137
138 public void Remove(List<uint> ids)
139 {
140 LookupItem lookup;
141
142 foreach (uint localid in ids)
143 {
144 if (m_lookupTable.TryGetValue(localid, out lookup))
145 {
146 lookup.Heap.Remove(lookup.Handle);
147 m_lookupTable.Remove(localid);
148 }
149 }
150 }
151
133 /// <summary> 152 /// <summary>
134 /// Remove an item from one of the queues. Specifically, it removes the 153 /// Remove an item from one of the queues. Specifically, it removes the
135 /// oldest item from the next queue in order to provide fair access to 154 /// oldest item from the next queue in order to provide fair access to
136 /// all of the queues 155 /// all of the queues
137 /// </summary> 156 /// </summary>
138 public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) 157 public bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue)
139 { 158 {
140 // If there is anything in priority queue 0, return it first no 159 // If there is anything in imediate queues, return it first no
141 // matter what else. Breaks fairness. But very useful. 160 // matter what else. Breaks fairness. But very useful.
142 for (int iq = 0; iq < NumberOfImmediateQueues; iq++) 161 for (int iq = 0; iq < NumberOfImmediateQueues; iq++)
143 { 162 {
@@ -151,36 +170,35 @@ namespace OpenSim.Framework
151 return true; 170 return true;
152 } 171 }
153 } 172 }
154 173
155 // To get the fair queing, we cycle through each of the 174 // To get the fair queing, we cycle through each of the
156 // queues when finding an element to dequeue. 175 // queues when finding an element to dequeue.
157 // We pull (NumberOfQueues - QueueIndex) items from each queue in order 176 // We pull (NumberOfQueues - QueueIndex) items from each queue in order
158 // to give lower numbered queues a higher priority and higher percentage 177 // to give lower numbered queues a higher priority and higher percentage
159 // of the bandwidth. 178 // of the bandwidth.
160 179
161 // Check for more items to be pulled from the current queue 180 // Check for more items to be pulled from the current queue
162 if (m_heaps[m_nextQueue].Count > 0 && m_countFromQueue > 0) 181 if (m_heaps[m_nextQueue].Count > 0 && m_countFromQueue > 0)
163 { 182 {
164 m_countFromQueue--; 183 m_countFromQueue--;
165 184
166 MinHeapItem item = m_heaps[m_nextQueue].RemoveMin(); 185 MinHeapItem item = m_heaps[m_nextQueue].RemoveMin();
167 m_lookupTable.Remove(item.Value.Entity.LocalId); 186 m_lookupTable.Remove(item.Value.Entity.LocalId);
168 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); 187 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
169 value = item.Value; 188 value = item.Value;
170 189
171 return true; 190 return true;
172 } 191 }
173 192
174 // Find the next non-immediate queue with updates in it 193 // Find the next non-immediate queue with updates in it
175 for (int i = 0; i < NumberOfQueues; ++i) 194 for (uint i = NumberOfImmediateQueues; i < NumberOfQueues; ++i)
176 { 195 {
177 m_nextQueue = (uint)((m_nextQueue + 1) % NumberOfQueues); 196 m_nextQueue++;
197 if(m_nextQueue >= NumberOfQueues)
198 m_nextQueue = NumberOfImmediateQueues;
199
178 m_countFromQueue = m_queueCounts[m_nextQueue]; 200 m_countFromQueue = m_queueCounts[m_nextQueue];
179 201
180 // if this is one of the immediate queues, just skip it
181 if (m_nextQueue < NumberOfImmediateQueues)
182 continue;
183
184 if (m_heaps[m_nextQueue].Count > 0) 202 if (m_heaps[m_nextQueue].Count > 0)
185 { 203 {
186 m_countFromQueue--; 204 m_countFromQueue--;
@@ -189,19 +207,39 @@ namespace OpenSim.Framework
189 m_lookupTable.Remove(item.Value.Entity.LocalId); 207 m_lookupTable.Remove(item.Value.Entity.LocalId);
190 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); 208 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
191 value = item.Value; 209 value = item.Value;
210 return true;
211 }
212 }
192 213
214 timeinqueue = 0;
215 value = default(EntityUpdate);
216 return false;
217 }
218
219 public bool TryOrderedDequeue(out EntityUpdate value, out Int32 timeinqueue)
220 {
221 // If there is anything in imediate queues, return it first no
222 // matter what else. Breaks fairness. But very useful.
223 for (int iq = 0; iq < NumberOfQueues; iq++)
224 {
225 if (m_heaps[iq].Count > 0)
226 {
227 MinHeapItem item = m_heaps[iq].RemoveMin();
228 m_lookupTable.Remove(item.Value.Entity.LocalId);
229 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
230 value = item.Value;
193 return true; 231 return true;
194 } 232 }
195 } 233 }
196 234
197 timeinqueue = 0; 235 timeinqueue = 0;
198 value = default(IEntityUpdate); 236 value = default(EntityUpdate);
199 return false; 237 return false;
200 } 238 }
201 239
202 /// <summary> 240 /// <summary>
203 /// Reapply the prioritization function to each of the updates currently 241 /// Reapply the prioritization function to each of the updates currently
204 /// stored in the priority queues. 242 /// stored in the priority queues.
205 /// </summary 243 /// </summary
206 public void Reprioritize(UpdatePriorityHandler handler) 244 public void Reprioritize(UpdatePriorityHandler handler)
207 { 245 {
@@ -253,8 +291,8 @@ namespace OpenSim.Framework
253#region MinHeapItem 291#region MinHeapItem
254 private struct MinHeapItem : IComparable<MinHeapItem> 292 private struct MinHeapItem : IComparable<MinHeapItem>
255 { 293 {
256 private IEntityUpdate value; 294 private EntityUpdate value;
257 internal IEntityUpdate Value { 295 internal EntityUpdate Value {
258 get { 296 get {
259 return this.value; 297 return this.value;
260 } 298 }
@@ -290,7 +328,7 @@ namespace OpenSim.Framework
290 this.pqueue = pqueue; 328 this.pqueue = pqueue;
291 } 329 }
292 330
293 internal MinHeapItem(uint pqueue, UInt64 entryorder, IEntityUpdate value) 331 internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value)
294 { 332 {
295 this.entrytime = Util.EnvironmentTickCount(); 333 this.entrytime = Util.EnvironmentTickCount();
296 this.entryorder = entryorder; 334 this.entryorder = entryorder;
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 79fbd96..75ed999 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -40,6 +40,7 @@ using OpenMetaverse.StructuredData;
40 40
41namespace OpenSim.Framework 41namespace OpenSim.Framework
42{ 42{
43 [Serializable]
43 public class RegionLightShareData : ICloneable 44 public class RegionLightShareData : ICloneable
44 { 45 {
45 public bool valid = false; 46 public bool valid = false;
@@ -101,6 +102,11 @@ namespace OpenSim.Framework
101 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 102 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
102 private static readonly string LogHeader = "[REGION INFO]"; 103 private static readonly string LogHeader = "[REGION INFO]";
103 104
105
106 public bool commFailTF = false;
107 public ConfigurationMember configMember;
108 public string DataStore = String.Empty;
109
104 public string RegionFile = String.Empty; 110 public string RegionFile = String.Empty;
105 public bool isSandbox = false; 111 public bool isSandbox = false;
106 public bool Persistent = true; 112 public bool Persistent = true;
@@ -124,7 +130,7 @@ namespace OpenSim.Framework
124 private float m_physPrimMin = 0; 130 private float m_physPrimMin = 0;
125 private int m_physPrimMax = 0; 131 private int m_physPrimMax = 0;
126 private bool m_clampPrimSize = false; 132 private bool m_clampPrimSize = false;
127 private int m_objectCapacity = 0; 133 private int m_objectCapacity = 15000;
128 private int m_maxPrimsPerUser = -1; 134 private int m_maxPrimsPerUser = -1;
129 private int m_linksetCapacity = 0; 135 private int m_linksetCapacity = 0;
130 private string m_regionType = String.Empty; 136 private string m_regionType = String.Empty;
@@ -132,8 +138,6 @@ namespace OpenSim.Framework
132 protected uint m_httpPort; 138 protected uint m_httpPort;
133 protected string m_serverURI; 139 protected string m_serverURI;
134 protected string m_regionName = String.Empty; 140 protected string m_regionName = String.Empty;
135 protected bool Allow_Alternate_Ports;
136 public bool m_allow_alternate_ports;
137 protected string m_externalHostName; 141 protected string m_externalHostName;
138 protected IPEndPoint m_internalEndPoint; 142 protected IPEndPoint m_internalEndPoint;
139 protected uint m_remotingPort; 143 protected uint m_remotingPort;
@@ -141,6 +145,7 @@ namespace OpenSim.Framework
141 public string RemotingAddress; 145 public string RemotingAddress;
142 public UUID ScopeID = UUID.Zero; 146 public UUID ScopeID = UUID.Zero;
143 private UUID m_maptileStaticUUID = UUID.Zero; 147 private UUID m_maptileStaticUUID = UUID.Zero;
148 private bool m_resolveAddress = false;
144 149
145 public uint WorldLocX = 0; 150 public uint WorldLocX = 0;
146 public uint WorldLocY = 0; 151 public uint WorldLocY = 0;
@@ -170,6 +175,9 @@ namespace OpenSim.Framework
170 /// </remarks> 175 /// </remarks>
171 public uint RegionSizeZ = Constants.RegionHeight; 176 public uint RegionSizeZ = Constants.RegionHeight;
172 177
178 // If entering avatar has no specific coords, this is where they land
179 public Vector3 DefaultLandingPoint = new Vector3(128, 128, 30);
180
173 private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>(); 181 private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>();
174 182
175 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. 183 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
@@ -368,7 +376,7 @@ namespace OpenSim.Framework
368 } 376 }
369 377
370 public string MaptileStaticFile { get; private set; } 378 public string MaptileStaticFile { get; private set; }
371 379
372 /// <summary> 380 /// <summary>
373 /// The port by which http communication occurs with the region (most noticeably, CAPS communication) 381 /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
374 /// </summary> 382 /// </summary>
@@ -381,17 +389,17 @@ namespace OpenSim.Framework
381 /// <summary> 389 /// <summary>
382 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) 390 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
383 /// </summary> 391 /// </summary>
384 392
385 public string ServerURI 393 public string ServerURI
386 { 394 {
387 get { 395 get {
388 if ( m_serverURI != string.Empty ) { 396 if ( m_serverURI != string.Empty ) {
389 return m_serverURI; 397 return m_serverURI;
390 } else { 398 } else {
391 return "http://" + m_externalHostName + ":" + m_httpPort + "/"; 399 return "http://" + m_externalHostName + ":" + m_httpPort + "/";
392 } 400 }
393 } 401 }
394 set { 402 set {
395 if ( value.EndsWith("/") ) { 403 if ( value.EndsWith("/") ) {
396 m_serverURI = value; 404 m_serverURI = value;
397 } else { 405 } else {
@@ -412,6 +420,7 @@ namespace OpenSim.Framework
412 set { m_remotingPort = value; } 420 set { m_remotingPort = value; }
413 } 421 }
414 422
423
415 /// <value> 424 /// <value>
416 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. 425 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
417 /// 426 ///
@@ -419,42 +428,7 @@ namespace OpenSim.Framework
419 /// </value> 428 /// </value>
420 public IPEndPoint ExternalEndPoint 429 public IPEndPoint ExternalEndPoint
421 { 430 {
422 get 431 get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); }
423 {
424 // Old one defaults to IPv6
425 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
426
427 IPAddress ia = null;
428 // If it is already an IP, don't resolve it - just return directly
429 if (IPAddress.TryParse(m_externalHostName, out ia))
430 return new IPEndPoint(ia, m_internalEndPoint.Port);
431
432 // Reset for next check
433 ia = null;
434 try
435 {
436 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
437 {
438 if (ia == null)
439 ia = Adr;
440
441 if (Adr.AddressFamily == AddressFamily.InterNetwork)
442 {
443 ia = Adr;
444 break;
445 }
446 }
447 }
448 catch (SocketException e)
449 {
450 throw new Exception(
451 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
452 e + "' attached to this exception", e);
453 }
454
455 return new IPEndPoint(ia, m_internalEndPoint.Port);
456 }
457
458 set { m_externalHostName = value.ToString(); } 432 set { m_externalHostName = value.ToString(); }
459 } 433 }
460 434
@@ -527,7 +501,7 @@ namespace OpenSim.Framework
527 return null; 501 return null;
528 } 502 }
529 503
530 private void SetExtraSetting(string key, string value) 504 public void SetExtraSetting(string key, string value)
531 { 505 {
532 string keylower = key.ToLower(); 506 string keylower = key.ToLower();
533 m_extraSettings[keylower] = value; 507 m_extraSettings[keylower] = value;
@@ -535,7 +509,7 @@ namespace OpenSim.Framework
535 509
536 private void ReadNiniConfig(IConfigSource source, string name) 510 private void ReadNiniConfig(IConfigSource source, string name)
537 { 511 {
538// bool creatingNew = false; 512 bool creatingNew = false;
539 513
540 if (source.Configs.Count == 0) 514 if (source.Configs.Count == 0)
541 { 515 {
@@ -559,7 +533,7 @@ namespace OpenSim.Framework
559 533
560 source.AddConfig(name); 534 source.AddConfig(name);
561 535
562// creatingNew = true; 536 creatingNew = true;
563 } 537 }
564 538
565 if (name == String.Empty) 539 if (name == String.Empty)
@@ -663,18 +637,19 @@ namespace OpenSim.Framework
663 } 637 }
664 m_internalEndPoint = new IPEndPoint(address, port); 638 m_internalEndPoint = new IPEndPoint(address, port);
665 639
666 // AllowAlternatePorts 640 // ResolveAddress
667 // 641 //
668 allKeys.Remove("AllowAlternatePorts"); 642 allKeys.Remove("ResolveAddress");
669 if (config.Contains("AllowAlternatePorts")) 643 if (config.Contains("ResolveAddress"))
670 { 644 {
671 m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true); 645 m_resolveAddress = config.GetBoolean("ResolveAddress", false);
672 } 646 }
673 else 647 else
674 { 648 {
675 m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False")); 649 if (creatingNew)
650 m_resolveAddress = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Resolve hostname to IP on start (for running inside Docker)", "False"));
676 651
677 config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString()); 652 config.Set("ResolveAddress", m_resolveAddress.ToString());
678 } 653 }
679 654
680 // ExternalHostName 655 // ExternalHostName
@@ -697,15 +672,36 @@ namespace OpenSim.Framework
697 "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}", 672 "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}",
698 m_externalHostName, name); 673 m_externalHostName, name);
699 } 674 }
700 else 675 else if (!m_resolveAddress)
701 { 676 {
702 m_externalHostName = externalName; 677 m_externalHostName = externalName;
703 } 678 }
679 else
680 {
681 IPAddress[] addrs = Dns.GetHostAddresses(externalName);
682 if (addrs.Length != 1) // If it is ambiguous or not resolveable, use it literally
683 m_externalHostName = externalName;
684 else
685 m_externalHostName = addrs[0].ToString();
686 }
704 687
705 // RegionType 688 // RegionType
706 m_regionType = config.GetString("RegionType", String.Empty); 689 m_regionType = config.GetString("RegionType", String.Empty);
707 allKeys.Remove("RegionType"); 690 allKeys.Remove("RegionType");
708 691
692 // Get Default Landing Location (Defaults to 128,128)
693 string temp_location = config.GetString("DefaultLanding", "<128, 128, 30>");
694 Vector3 temp_vector;
695
696 if (Vector3.TryParse(temp_location, out temp_vector))
697 DefaultLandingPoint = temp_vector;
698 else
699 m_log.ErrorFormat("[RegionInfo]: Unable to parse DefaultLanding for '{0}'. The value given was '{1}'", RegionName, temp_location);
700
701 allKeys.Remove("DefaultLanding");
702
703 DoDefaultLandingSanityChecks();
704
709 #region Prim and map stuff 705 #region Prim and map stuff
710 706
711 m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0); 707 m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0);
@@ -719,11 +715,11 @@ namespace OpenSim.Framework
719 715
720 m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); 716 m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
721 allKeys.Remove("PhysicalPrimMax"); 717 allKeys.Remove("PhysicalPrimMax");
722 718
723 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); 719 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
724 allKeys.Remove("ClampPrimSize"); 720 allKeys.Remove("ClampPrimSize");
725 721
726 m_objectCapacity = config.GetInt("MaxPrims", 15000); 722 m_objectCapacity = config.GetInt("MaxPrims", m_objectCapacity);
727 allKeys.Remove("MaxPrims"); 723 allKeys.Remove("MaxPrims");
728 724
729 m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1); 725 m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1);
@@ -736,12 +732,12 @@ namespace OpenSim.Framework
736 string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString()); 732 string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString());
737 if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID)) 733 if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID))
738 { 734 {
739 config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); 735 config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString());
740 } 736 }
741 737
742 MaptileStaticFile = config.GetString("MaptileStaticFile", String.Empty); 738 MaptileStaticFile = config.GetString("MaptileStaticFile", String.Empty);
743 allKeys.Remove("MaptileStaticFile"); 739 allKeys.Remove("MaptileStaticFile");
744 740
745 #endregion 741 #endregion
746 742
747 AgentCapacity = config.GetInt("MaxAgents", 100); 743 AgentCapacity = config.GetInt("MaxAgents", 100);
@@ -758,6 +754,48 @@ namespace OpenSim.Framework
758 } 754 }
759 } 755 }
760 756
757 // Make sure DefaultLanding is within region borders with a buffer zone 5 meters from borders
758 private void DoDefaultLandingSanityChecks()
759 {
760 // Sanity Check Default Landing
761 float buffer_zone = 5f;
762
763 bool ValuesCapped = false;
764
765 // Minimum Positions
766 if (DefaultLandingPoint.X < buffer_zone)
767 {
768 DefaultLandingPoint.X = buffer_zone;
769 ValuesCapped = true;
770 }
771
772 if (DefaultLandingPoint.Y < buffer_zone)
773 {
774 DefaultLandingPoint.Y = buffer_zone;
775 ValuesCapped = true;
776 }
777
778 // Maximum Positions
779 if (DefaultLandingPoint.X > RegionSizeX - buffer_zone)
780 {
781 DefaultLandingPoint.X = RegionSizeX - buffer_zone;
782 ValuesCapped = true;
783 }
784
785 if (DefaultLandingPoint.Y > RegionSizeY - buffer_zone)
786 {
787 DefaultLandingPoint.Y = RegionSizeY - buffer_zone;
788 ValuesCapped = true;
789 }
790
791 // Height
792 if (DefaultLandingPoint.Z < 0f)
793 DefaultLandingPoint.Z = 0f;
794
795 if (ValuesCapped == true)
796 m_log.WarnFormat("[RegionInfo]: The default landing location for {0} has been capped to {1}", RegionName, DefaultLandingPoint);
797 }
798
761 // Make sure user specified region sizes are sane. 799 // Make sure user specified region sizes are sane.
762 // Must be multiples of legacy region size (256). 800 // Must be multiples of legacy region size (256).
763 private void DoRegionSizeSanityChecks() 801 private void DoRegionSizeSanityChecks()
@@ -823,20 +861,20 @@ namespace OpenSim.Framework
823 string location = String.Format("{0},{1}", RegionLocX, RegionLocY); 861 string location = String.Format("{0},{1}", RegionLocX, RegionLocY);
824 config.Set("Location", location); 862 config.Set("Location", location);
825 863
826 if (RegionSizeX > 0) 864 if (DataStore != String.Empty)
827 config.Set("SizeX", RegionSizeX); 865 config.Set("Datastore", DataStore);
828 866
829 if (RegionSizeY > 0) 867 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
868 {
869 config.Set("SizeX", RegionSizeX);
830 config.Set("SizeY", RegionSizeY); 870 config.Set("SizeY", RegionSizeY);
831 871 // if (RegionSizeZ > 0)
832// if (RegionSizeZ > 0) 872 // config.Set("SizeZ", RegionSizeZ);
833// config.Set("SizeZ", RegionSizeZ); 873 }
834 874
835 config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); 875 config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
836 config.Set("InternalPort", m_internalEndPoint.Port); 876 config.Set("InternalPort", m_internalEndPoint.Port);
837 877
838 config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString());
839
840 config.Set("ExternalHostName", m_externalHostName); 878 config.Set("ExternalHostName", m_externalHostName);
841 879
842 if (m_nonphysPrimMin > 0) 880 if (m_nonphysPrimMin > 0)
@@ -847,10 +885,10 @@ namespace OpenSim.Framework
847 885
848 if (m_physPrimMin > 0) 886 if (m_physPrimMin > 0)
849 config.Set("PhysicalPrimMax", m_physPrimMin); 887 config.Set("PhysicalPrimMax", m_physPrimMin);
850 888
851 if (m_physPrimMax > 0) 889 if (m_physPrimMax > 0)
852 config.Set("PhysicalPrimMax", m_physPrimMax); 890 config.Set("PhysicalPrimMax", m_physPrimMax);
853 891
854 config.Set("ClampPrimSize", m_clampPrimSize.ToString()); 892 config.Set("ClampPrimSize", m_clampPrimSize.ToString());
855 893
856 if (m_objectCapacity > 0) 894 if (m_objectCapacity > 0)
@@ -901,6 +939,222 @@ namespace OpenSim.Framework
901 throw new Exception("Invalid file type for region persistence."); 939 throw new Exception("Invalid file type for region persistence.");
902 } 940 }
903 941
942 public void loadConfigurationOptionsFromMe()
943 {
944 configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE,
945 "UUID of Region (Default is recommended, random UUID)",
946 RegionID.ToString(), true);
947 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
948 "Region Name", RegionName, true);
949
950 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
951 "Grid Location (X Axis)", RegionLocX.ToString(), true);
952 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
953 "Grid Location (Y Axis)", RegionLocY.ToString(), true);
954 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
955 "Size of region in X dimension", RegionSizeX.ToString(), true);
956 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
957 "Size of region in Y dimension", RegionSizeY.ToString(), true);
958 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
959 "Size of region in Z dimension", RegionSizeZ.ToString(), true);
960
961 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
962 configMember.addConfigurationOption("internal_ip_address",
963 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
964 "Internal IP Address for incoming UDP client connections",
965 m_internalEndPoint.Address.ToString(),
966 true);
967 configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
968 "Internal IP Port for incoming UDP client connections",
969 m_internalEndPoint.Port.ToString(), true);
970 configMember.addConfigurationOption("external_host_name",
971 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
972 "External Host Name", m_externalHostName, true);
973 configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
974 "Last Map UUID", lastMapUUID.ToString(), true);
975 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
976 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
977
978 configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
979 "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true);
980
981 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
982 "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
983
984 configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
985 "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true);
986
987 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
988 "Maximum size for physical prims", m_physPrimMax.ToString(), true);
989
990 configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
991 "Clamp prims to max size", m_clampPrimSize.ToString(), true);
992
993 configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
994 "Max objects this sim will hold", m_objectCapacity.ToString(), true);
995
996 configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
997 "Max prims an object will hold", m_linksetCapacity.ToString(), true);
998
999 configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1000 "Max avatars this sim will hold",AgentCapacity.ToString(), true);
1001
1002 configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1003 "Scope ID for this region", ScopeID.ToString(), true);
1004
1005 configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
1006 "Free form string describing the type of region", String.Empty, true);
1007
1008 configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1009 "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true);
1010 }
1011
1012 public void loadConfigurationOptions()
1013 {
1014 configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1015 "UUID of Region (Default is recommended, random UUID)",
1016 UUID.Random().ToString(), true);
1017 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
1018 "Region Name", "OpenSim Test", false);
1019
1020 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1021 "Grid Location (X Axis)", "1000", false);
1022 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1023 "Grid Location (Y Axis)", "1000", false);
1024 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1025 "Size of region in X dimension", Constants.RegionSize.ToString(), false);
1026 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1027 "Size of region in Y dimension", Constants.RegionSize.ToString(), false);
1028 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
1029 "Size of region in Z dimension", Constants.RegionHeight.ToString(), false);
1030
1031 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
1032 configMember.addConfigurationOption("internal_ip_address",
1033 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
1034 "Internal IP Address for incoming UDP client connections", "0.0.0.0",
1035 false);
1036 configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1037 "Internal IP Port for incoming UDP client connections",
1038 ConfigSettings.DefaultRegionHttpPort.ToString(), false);
1039 configMember.addConfigurationOption("external_host_name",
1040 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
1041 "External Host Name", "127.0.0.1", false);
1042 configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1043 "Last Map UUID", lastMapUUID.ToString(), true);
1044
1045 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
1046 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
1047
1048 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1049 "Maximum size for nonphysical prims", "0", true);
1050
1051 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1052 "Maximum size for physical prims", "0", true);
1053
1054 configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN,
1055 "Clamp prims to max size", "false", true);
1056
1057 configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1058 "Max objects this sim will hold", "15000", true);
1059
1060 configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
1061 "Max avatars this sim will hold", "100", true);
1062
1063 configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1064 "Scope ID for this region", UUID.Zero.ToString(), true);
1065
1066 configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
1067 "Region Type", String.Empty, true);
1068
1069 configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
1070 "UUID of a texture to use as the map for this region", String.Empty, true);
1071 }
1072
1073 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
1074 {
1075 switch (configuration_key)
1076 {
1077 case "sim_UUID":
1078 RegionID = (UUID) configuration_result;
1079 originRegionID = (UUID) configuration_result;
1080 break;
1081 case "sim_name":
1082 RegionName = (string) configuration_result;
1083 break;
1084 case "sim_location_x":
1085 RegionLocX = (uint) configuration_result;
1086 break;
1087 case "sim_location_y":
1088 RegionLocY = (uint) configuration_result;
1089 break;
1090 case "sim_size_x":
1091 RegionSizeX = (uint) configuration_result;
1092 break;
1093 case "sim_size_y":
1094 RegionSizeY = (uint) configuration_result;
1095 break;
1096 case "sim_size_z":
1097 RegionSizeZ = (uint) configuration_result;
1098 break;
1099 case "datastore":
1100 DataStore = (string) configuration_result;
1101 break;
1102 case "internal_ip_address":
1103 IPAddress address = (IPAddress) configuration_result;
1104 m_internalEndPoint = new IPEndPoint(address, 0);
1105 break;
1106 case "internal_ip_port":
1107 m_internalEndPoint.Port = (int) configuration_result;
1108 break;
1109 case "external_host_name":
1110 if ((string) configuration_result != "SYSTEMIP")
1111 {
1112 m_externalHostName = (string) configuration_result;
1113 }
1114 else
1115 {
1116 m_externalHostName = Util.GetLocalHost().ToString();
1117 }
1118 break;
1119 case "lastmap_uuid":
1120 lastMapUUID = (UUID)configuration_result;
1121 break;
1122 case "lastmap_refresh":
1123 lastMapRefresh = (string)configuration_result;
1124 break;
1125 case "nonphysical_prim_max":
1126 m_nonphysPrimMax = (int)configuration_result;
1127 break;
1128 case "physical_prim_max":
1129 m_physPrimMax = (int)configuration_result;
1130 break;
1131 case "clamp_prim_size":
1132 m_clampPrimSize = (bool)configuration_result;
1133 break;
1134 case "object_capacity":
1135 m_objectCapacity = (int)configuration_result;
1136 break;
1137 case "linkset_capacity":
1138 m_linksetCapacity = (int)configuration_result;
1139 break;
1140 case "agent_capacity":
1141 AgentCapacity = (int)configuration_result;
1142 break;
1143 case "scope_id":
1144 ScopeID = (UUID)configuration_result;
1145 break;
1146 case "region_type":
1147 m_regionType = (string)configuration_result;
1148 break;
1149 case "region_static_maptile":
1150 m_maptileStaticUUID = (UUID)configuration_result;
1151 break;
1152 }
1153
1154 return true;
1155 }
1156
1157
904 public void SaveLastMapUUID(UUID mapUUID) 1158 public void SaveLastMapUUID(UUID mapUUID)
905 { 1159 {
906 lastMapUUID = mapUUID; 1160 lastMapUUID = mapUUID;
@@ -928,7 +1182,6 @@ namespace OpenSim.Framework
928 if ((RemotingAddress != null) && !RemotingAddress.Equals("")) 1182 if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
929 args["remoting_address"] = OSD.FromString(RemotingAddress); 1183 args["remoting_address"] = OSD.FromString(RemotingAddress);
930 args["remoting_port"] = OSD.FromString(RemotingPort.ToString()); 1184 args["remoting_port"] = OSD.FromString(RemotingPort.ToString());
931 args["allow_alt_ports"] = OSD.FromBoolean(m_allow_alternate_ports);
932 if ((proxyUrl != null) && !proxyUrl.Equals("")) 1185 if ((proxyUrl != null) && !proxyUrl.Equals(""))
933 args["proxy_url"] = OSD.FromString(proxyUrl); 1186 args["proxy_url"] = OSD.FromString(proxyUrl);
934 if (RegionType != String.Empty) 1187 if (RegionType != String.Empty)
@@ -983,8 +1236,6 @@ namespace OpenSim.Framework
983 RemotingAddress = args["remoting_address"].AsString(); 1236 RemotingAddress = args["remoting_address"].AsString();
984 if (args["remoting_port"] != null) 1237 if (args["remoting_port"] != null)
985 UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort); 1238 UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort);
986 if (args["allow_alt_ports"] != null)
987 m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean();
988 if (args["proxy_url"] != null) 1239 if (args["proxy_url"] != null)
989 proxyUrl = args["proxy_url"].AsString(); 1240 proxyUrl = args["proxy_url"].AsString();
990 if (args["region_type"] != null) 1241 if (args["region_type"] != null)
@@ -1004,5 +1255,29 @@ namespace OpenSim.Framework
1004 regionInfo.ServerURI = serverURI; 1255 regionInfo.ServerURI = serverURI;
1005 return regionInfo; 1256 return regionInfo;
1006 } 1257 }
1258
1259 public int getInternalEndPointPort()
1260 {
1261 return m_internalEndPoint.Port;
1262 }
1263
1264 public Dictionary<string, object> ToKeyValuePairs()
1265 {
1266 Dictionary<string, object> kvp = new Dictionary<string, object>();
1267 kvp["uuid"] = RegionID.ToString();
1268 kvp["locX"] = RegionLocX.ToString();
1269 kvp["locY"] = RegionLocY.ToString();
1270 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
1271 kvp["external_port"] = ExternalEndPoint.Port.ToString();
1272 kvp["external_host_name"] = ExternalHostName;
1273 kvp["http_port"] = HttpPort.ToString();
1274 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
1275 kvp["internal_port"] = InternalEndPoint.Port.ToString();
1276 // TODO: Remove in next major version
1277 kvp["alternate_ports"] = "False";
1278 kvp["server_uri"] = ServerURI;
1279
1280 return kvp;
1281 }
1007 } 1282 }
1008} 1283}
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
index a895c40..c2947a2 100644
--- a/OpenSim/Framework/RegionSettings.cs
+++ b/OpenSim/Framework/RegionSettings.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Framework
91 string[] parts = str.Split(','); 91 string[] parts = str.Split(',');
92 if (parts.Length != 3) 92 if (parts.Length != 3)
93 throw new ArgumentException("Invalid string: " + str); 93 throw new ArgumentException("Invalid string: " + str);
94 94
95 SpawnPoint sp = new SpawnPoint(); 95 SpawnPoint sp = new SpawnPoint();
96 sp.Yaw = float.Parse(parts[0]); 96 sp.Yaw = float.Parse(parts[0]);
97 sp.Pitch = float.Parse(parts[1]); 97 sp.Pitch = float.Parse(parts[1]);
@@ -105,7 +105,7 @@ namespace OpenSim.Framework
105 public delegate void SaveDelegate(RegionSettings rs); 105 public delegate void SaveDelegate(RegionSettings rs);
106 106
107 public event SaveDelegate OnSave; 107 public event SaveDelegate OnSave;
108 108
109 /// <value> 109 /// <value>
110 /// These appear to be terrain textures that are shipped with the client. 110 /// These appear to be terrain textures that are shipped with the client.
111 /// </value> 111 /// </value>
@@ -454,24 +454,24 @@ namespace OpenSim.Framework
454 get { return m_LoadedCreationDateTime; } 454 get { return m_LoadedCreationDateTime; }
455 set { m_LoadedCreationDateTime = value; } 455 set { m_LoadedCreationDateTime = value; }
456 } 456 }
457 457
458 public String LoadedCreationDate 458 public String LoadedCreationDate
459 { 459 {
460 get 460 get
461 { 461 {
462 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); 462 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
463 DateTime stamp = new DateTime(1970, 1, 1) + ts; 463 DateTime stamp = new DateTime(1970, 1, 1) + ts;
464 return stamp.ToLongDateString(); 464 return stamp.ToLongDateString();
465 } 465 }
466 } 466 }
467 467
468 public String LoadedCreationTime 468 public String LoadedCreationTime
469 { 469 {
470 get 470 get
471 { 471 {
472 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime); 472 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
473 DateTime stamp = new DateTime(1970, 1, 1) + ts; 473 DateTime stamp = new DateTime(1970, 1, 1) + ts;
474 return stamp.ToLongTimeString(); 474 return stamp.ToLongTimeString();
475 } 475 }
476 } 476 }
477 477
@@ -482,6 +482,28 @@ namespace OpenSim.Framework
482 set { m_LoadedCreationID = value; } 482 set { m_LoadedCreationID = value; }
483 } 483 }
484 484
485 private bool m_GodBlockSearch = false;
486 public bool GodBlockSearch
487 {
488 get { return m_GodBlockSearch; }
489 set { m_GodBlockSearch = value; }
490 }
491
492 private bool m_Casino = false;
493 public bool Casino
494 {
495 get { return m_Casino; }
496 set { m_Casino = value; }
497 }
498
499 // Telehub support
500 private bool m_TelehubEnabled = false;
501 public bool HasTelehub
502 {
503 get { return m_TelehubEnabled; }
504 set { m_TelehubEnabled = value; }
505 }
506
485 /// <summary> 507 /// <summary>
486 /// Connected Telehub object 508 /// Connected Telehub object
487 /// </summary> 509 /// </summary>
@@ -520,4 +542,4 @@ namespace OpenSim.Framework
520 l_SpawnPoints.Clear(); 542 l_SpawnPoints.Clear();
521 } 543 }
522 } 544 }
523} \ No newline at end of file 545}
diff --git a/OpenSim/Framework/RestClient.cs b/OpenSim/Framework/RestClient.cs
index 7080ca5..4939cf7 100644
--- a/OpenSim/Framework/RestClient.cs
+++ b/OpenSim/Framework/RestClient.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Framework
156 public void Dispose() 156 public void Dispose()
157 { 157 {
158 Dispose(true); 158 Dispose(true);
159 GC.SuppressFinalize(this); 159 GC.SuppressFinalize(this);
160 } 160 }
161 161
162 protected virtual void Dispose(bool disposing) 162 protected virtual void Dispose(bool disposing)
@@ -388,10 +388,10 @@ namespace OpenSim.Framework
388 m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); 388 m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e);
389 } 389 }
390 } 390 }
391
392 return null; 391 return null;
393 } 392 }
394 393
394
395 if (_asyncException != null) 395 if (_asyncException != null)
396 throw _asyncException; 396 throw _asyncException;
397 397
@@ -413,7 +413,7 @@ namespace OpenSim.Framework
413 _request = (HttpWebRequest) WebRequest.Create(buildUri()); 413 _request = (HttpWebRequest) WebRequest.Create(buildUri());
414 _request.KeepAlive = false; 414 _request.KeepAlive = false;
415 _request.ContentType = "application/xml"; 415 _request.ContentType = "application/xml";
416 _request.Timeout = 900000; 416 _request.Timeout = 90000;
417 _request.Method = RequestMethod; 417 _request.Method = RequestMethod;
418 _asyncException = null; 418 _asyncException = null;
419 _request.ContentLength = src.Length; 419 _request.ContentLength = src.Length;
@@ -428,18 +428,23 @@ namespace OpenSim.Framework
428 if (WebUtil.DebugLevel >= 5) 428 if (WebUtil.DebugLevel >= 5)
429 WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src); 429 WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src);
430 430
431 Stream dst = _request.GetRequestStream(); 431
432
433 byte[] buf = new byte[1024];
434 int length = src.Read(buf, 0, 1024);
435 while (length > 0)
436 {
437 dst.Write(buf, 0, length);
438 length = src.Read(buf, 0, 1024);
439 }
440
441 try 432 try
442 { 433 {
434 using (Stream dst = _request.GetRequestStream())
435 {
436// m_log.Debug("[REST]: GetRequestStream is ok");
437
438 byte[] buf = new byte[1024];
439 int length = src.Read(buf, 0, 1024);
440// m_log.Debug("[REST]: First Read is ok");
441 while (length > 0)
442 {
443 dst.Write(buf, 0, length);
444 length = src.Read(buf, 0, 1024);
445 }
446 }
447
443 _response = (HttpWebResponse)_request.GetResponse(); 448 _response = (HttpWebResponse)_request.GetResponse();
444 } 449 }
445 catch (WebException e) 450 catch (WebException e)
@@ -468,7 +473,8 @@ namespace OpenSim.Framework
468 } 473 }
469 } 474 }
470 475
471 _response.Close(); 476 if (_response != null)
477 _response.Close();
472 478
473// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); 479// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
474 480
@@ -673,4 +679,4 @@ namespace OpenSim.Framework
673 } 679 }
674 } 680 }
675 681
676} \ No newline at end of file 682}
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
index e66d5be..9458625 100644
--- a/OpenSim/Framework/SLUtil.cs
+++ b/OpenSim/Framework/SLUtil.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Framework
44 Material = -2 44 Material = -2
45 } 45 }
46 46
47 47
48 #region SL / file extension / content-type conversions 48 #region SL / file extension / content-type conversions
49 49
50 /// <summary> 50 /// <summary>
@@ -175,10 +175,10 @@ namespace OpenSim.Framework
175 new TypeMapping(AssetType.Folder, FolderType.CurrentOutfit, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), 175 new TypeMapping(AssetType.Folder, FolderType.CurrentOutfit, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"),
176 new TypeMapping(AssetType.Folder, FolderType.Outfit, "application/vnd.ll.outfitfolder", "outfitfolder"), 176 new TypeMapping(AssetType.Folder, FolderType.Outfit, "application/vnd.ll.outfitfolder", "outfitfolder"),
177 new TypeMapping(AssetType.Folder, FolderType.MyOutfits, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), 177 new TypeMapping(AssetType.Folder, FolderType.MyOutfits, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"),
178 178
179 // This next mappping is an asset to inventory item mapping. 179 // This next mappping is an asset to inventory item mapping.
180 // Note: LL stores folders as assets of type Folder = 8, and it has a corresponding InventoryType = 8 180 // Note: LL stores folders as assets of type Folder = 8, and it has a corresponding InventoryType = 8
181 // OpenSim doesn't store folders as assets, so this mapping should only be used when parsing things from the viewer to the server 181 // OpenSim doesn't store folders as assets, so this mapping should only be used when parsing things from the viewer to the server
182 new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), 182 new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
183 183
184 // OpenSim specific 184 // OpenSim specific
@@ -198,7 +198,7 @@ namespace OpenSim.Framework
198 inventory2Content = new Dictionary<sbyte, string>(); 198 inventory2Content = new Dictionary<sbyte, string>();
199 content2Asset = new Dictionary<string, sbyte>(); 199 content2Asset = new Dictionary<string, sbyte>();
200 content2Inventory = new Dictionary<string, sbyte>(); 200 content2Inventory = new Dictionary<string, sbyte>();
201 201
202 foreach (TypeMapping mapping in MAPPINGS) 202 foreach (TypeMapping mapping in MAPPINGS)
203 { 203 {
204 sbyte assetType = mapping.AssetTypeCode; 204 sbyte assetType = mapping.AssetTypeCode;
@@ -226,7 +226,7 @@ namespace OpenSim.Framework
226 } 226 }
227 } 227 }
228 } 228 }
229 229
230 public static string SLAssetTypeToContentType(int assetType) 230 public static string SLAssetTypeToContentType(int assetType)
231 { 231 {
232 string contentType; 232 string contentType;
@@ -406,7 +406,7 @@ namespace OpenSim.Framework
406 if(data[0] == "inv_item") 406 if(data[0] == "inv_item")
407 { 407 {
408 skipInventoryItem(reader); 408 skipInventoryItem(reader);
409 } 409 }
410 else if (line.IndexOf('{') >= 0) 410 else if (line.IndexOf('{') >= 0)
411 { 411 {
412 throw new NotANotecardFormatException(reader.LineNumber); 412 throw new NotANotecardFormatException(reader.LineNumber);
@@ -462,7 +462,7 @@ namespace OpenSim.Framework
462 { 462 {
463 int length = Int32.Parse(data[2]); 463 int length = Int32.Parse(data[2]);
464 notecardString = reader.getBlock(length); 464 notecardString = reader.getBlock(length);
465 } 465 }
466 else if (line.IndexOf('{') >= 0) 466 else if (line.IndexOf('{') >= 0)
467 { 467 {
468 throw new NotANotecardFormatException(reader.LineNumber); 468 throw new NotANotecardFormatException(reader.LineNumber);
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs
index ab3c285..9081411 100644
--- a/OpenSim/Framework/Serialization/ArchiveConstants.cs
+++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs
@@ -72,12 +72,12 @@ namespace OpenSim.Framework.Serialization
72 /// Path for region settings. 72 /// Path for region settings.
73 /// </value> 73 /// </value>
74 public const string SETTINGS_PATH = "settings/"; 74 public const string SETTINGS_PATH = "settings/";
75 75
76 /// <value> 76 /// <value>
77 /// Path for region settings. 77 /// Path for region settings.
78 /// </value> 78 /// </value>
79 public const string LANDDATA_PATH = "landdata/"; 79 public const string LANDDATA_PATH = "landdata/";
80 80
81 /// <value> 81 /// <value>
82 /// Path for user profiles 82 /// Path for user profiles
83 /// </value> 83 /// </value>
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
index 55640ac..af130a5 100644
--- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -106,13 +106,13 @@ namespace OpenSim.Framework.Serialization.External
106 { 106 {
107 errors = true; 107 errors = true;
108 parseExceptionAction(nodeToFill, nodeName, e); 108 parseExceptionAction(nodeToFill, nodeName, e);
109 109
110 if (xtr.EOF) 110 if (xtr.EOF)
111 { 111 {
112 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to unexpected end of XML"); 112 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to unexpected end of XML");
113 break; 113 break;
114 } 114 }
115 115
116 if (++numErrors == 10) 116 if (++numErrors == 10)
117 { 117 {
118 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to too many parsing errors"); 118 m_log.Debug("[ExternalRepresentationUtils]: Aborting ExecuteReadProcessors due to too many parsing errors");
@@ -156,6 +156,7 @@ namespace OpenSim.Framework.Serialization.External
156 return xml; 156 return xml;
157 157
158 XmlDocument doc = new XmlDocument(); 158 XmlDocument doc = new XmlDocument();
159 doc.XmlResolver=null;
159 doc.LoadXml(xml); 160 doc.LoadXml(xml);
160 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); 161 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
161 162
@@ -220,7 +221,7 @@ namespace OpenSim.Framework.Serialization.External
220 using (StringWriter sw = new StringWriter()) 221 using (StringWriter sw = new StringWriter())
221 using (XmlTextWriter writer = new XmlTextWriter(sw)) 222 using (XmlTextWriter writer = new XmlTextWriter(sw))
222 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) 223 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
223 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) 224 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, ProhibitDtd = true}))
224 { 225 {
225 TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); 226 TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);
226 227
@@ -369,7 +370,7 @@ namespace OpenSim.Framework.Serialization.External
369 break; 370 break;
370 371
371 case XmlNodeType.XmlDeclaration: 372 case XmlNodeType.XmlDeclaration:
372 // For various reasons, not all serializations have xml declarations (or consistent ones) 373 // For various reasons, not all serializations have xml declarations (or consistent ones)
373 // and as it's embedded inside a byte stream we don't need it anyway, so ignore. 374 // and as it's embedded inside a byte stream we don't need it anyway, so ignore.
374 break; 375 break;
375 376
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
index e42d56f..33ffd83 100644
--- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -178,6 +178,7 @@ namespace OpenSim.Framework.Serialization.External
178 178
179 using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData))) 179 using (XmlTextReader reader = new XmlTextReader(new StringReader(serializedLandData)))
180 { 180 {
181 reader.ProhibitDtd = true;
181 reader.ReadStartElement("LandData"); 182 reader.ReadStartElement("LandData");
182 183
183 ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); 184 ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader);
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index fa7160f..a1e9d55 100644
--- a/OpenSim/Framework/Serialization/External/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -35,13 +35,13 @@ using OpenSim.Services.Interfaces;
35namespace OpenSim.Framework.Serialization 35namespace OpenSim.Framework.Serialization
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for 38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for
39 /// identifying user profiles or supplying a simple name if no profile is available. 39 /// identifying user profiles or supplying a simple name if no profile is available.
40 /// </summary> 40 /// </summary>
41 public class OspResolver 41 public class OspResolver
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 public const string OSPA_PREFIX = "ospa:"; 45 public const string OSPA_PREFIX = "ospa:";
46 public const string OSPA_NAME_KEY = "n"; 46 public const string OSPA_NAME_KEY = "n";
47 public const string OSPA_NAME_VALUE_SEPARATOR = " "; 47 public const string OSPA_NAME_VALUE_SEPARATOR = " ";
@@ -76,7 +76,7 @@ namespace OpenSim.Framework.Serialization
76 76
77 return null; 77 return null;
78 } 78 }
79 79
80 /// <summary> 80 /// <summary>
81 /// Make an OSPA given a user name 81 /// Make an OSPA given a user name
82 /// </summary> 82 /// </summary>
@@ -89,17 +89,17 @@ namespace OpenSim.Framework.Serialization
89 89
90// m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); 90// m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
91// System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); 91// System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName);
92 92
93 return ospa; 93 return ospa;
94 } 94 }
95 95
96 /// <summary> 96 /// <summary>
97 /// Resolve an osp string into the most suitable internal OpenSim identifier. 97 /// Resolve an osp string into the most suitable internal OpenSim identifier.
98 /// </summary> 98 /// </summary>
99 /// 99 ///
100 /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may 100 /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may
101 /// just return the same identifier after creating a temporary profile. 101 /// just return the same identifier after creating a temporary profile.
102 /// 102 ///
103 /// <param name="ospa"></param> 103 /// <param name="ospa"></param>
104 /// <param name="commsManager"></param> 104 /// <param name="commsManager"></param>
105 /// <returns> 105 /// <returns>
@@ -111,14 +111,14 @@ namespace OpenSim.Framework.Serialization
111 if (!ospa.StartsWith(OSPA_PREFIX)) 111 if (!ospa.StartsWith(OSPA_PREFIX))
112 { 112 {
113// m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa); 113// m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa);
114 return UUID.Zero; 114 return UUID.Zero;
115 } 115 }
116 116
117// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); 117// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa);
118 118
119 string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); 119 string ospaMeat = ospa.Substring(OSPA_PREFIX.Length);
120 string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); 120 string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY);
121 121
122 foreach (string tuple in ospaTuples) 122 foreach (string tuple in ospaTuples)
123 { 123 {
124 int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); 124 int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR);
@@ -128,17 +128,17 @@ namespace OpenSim.Framework.Serialization
128 m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa); 128 m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa);
129 continue; 129 continue;
130 } 130 }
131 131
132 string key = tuple.Remove(tupleSeparatorIndex).Trim(); 132 string key = tuple.Remove(tupleSeparatorIndex).Trim();
133 string value = tuple.Substring(tupleSeparatorIndex + 1).Trim(); 133 string value = tuple.Substring(tupleSeparatorIndex + 1).Trim();
134 134
135 if (OSPA_NAME_KEY == key) 135 if (OSPA_NAME_KEY == key)
136 return ResolveOspaName(value, userService); 136 return ResolveOspaName(value, userService);
137 } 137 }
138 138
139 return UUID.Zero; 139 return UUID.Zero;
140 } 140 }
141 141
142 /// <summary> 142 /// <summary>
143 /// Hash a profile name into a UUID 143 /// Hash a profile name into a UUID
144 /// </summary> 144 /// </summary>
@@ -148,7 +148,7 @@ namespace OpenSim.Framework.Serialization
148 { 148 {
149 return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0); 149 return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0);
150 } 150 }
151 151
152 /// <summary> 152 /// <summary>
153 /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile 153 /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile
154 /// then a temporary user profile is inserted in the cache. 154 /// then a temporary user profile is inserted in the cache.
@@ -164,13 +164,13 @@ namespace OpenSim.Framework.Serialization
164 return UUID.Zero; 164 return UUID.Zero;
165 165
166 int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); 166 int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR);
167 167
168 if (nameSeparatorIndex < 0) 168 if (nameSeparatorIndex < 0)
169 { 169 {
170 m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); 170 m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name);
171 return UUID.Zero; 171 return UUID.Zero;
172 } 172 }
173 173
174 string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); 174 string firstName = name.Remove(nameSeparatorIndex).TrimEnd();
175 string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart(); 175 string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart();
176 176
@@ -178,14 +178,14 @@ namespace OpenSim.Framework.Serialization
178 if (account != null) 178 if (account != null)
179 { 179 {
180// m_log.DebugFormat( 180// m_log.DebugFormat(
181// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}", 181// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}",
182// account.PrincipalID, firstName, lastName); 182// account.PrincipalID, firstName, lastName);
183 183
184 return account.PrincipalID; 184 return account.PrincipalID;
185 } 185 }
186// else 186// else
187// { 187// {
188// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name); 188// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name);
189// } 189// }
190 190
191 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc 191 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
@@ -194,11 +194,11 @@ namespace OpenSim.Framework.Serialization
194 tempUserProfile.FirstName = firstName; 194 tempUserProfile.FirstName = firstName;
195 tempUserProfile.SurName = lastName; 195 tempUserProfile.SurName = lastName;
196 tempUserProfile.ID = HashName(tempUserProfile.Name); 196 tempUserProfile.ID = HashName(tempUserProfile.Name);
197 197
198 m_log.DebugFormat( 198 m_log.DebugFormat(
199 "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); 199 "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID);
200 commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); 200 commsManager.UserService.AddTemporaryUserProfile(tempUserProfile);
201 201
202 return tempUserProfile.ID; 202 return tempUserProfile.ID;
203 */ 203 */
204 204
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
index 19468c3..fd21f3e 100644
--- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Serialization.External
50 { 50 {
51 return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length)); 51 return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length));
52 } 52 }
53 53
54 /// <summary> 54 /// <summary>
55 /// Deserialize settings 55 /// Deserialize settings
56 /// </summary> 56 /// </summary>
@@ -60,14 +60,15 @@ namespace OpenSim.Framework.Serialization.External
60 public static RegionSettings Deserialize(string serializedSettings) 60 public static RegionSettings Deserialize(string serializedSettings)
61 { 61 {
62 RegionSettings settings = new RegionSettings(); 62 RegionSettings settings = new RegionSettings();
63 63
64 StringReader sr = new StringReader(serializedSettings); 64 StringReader sr = new StringReader(serializedSettings);
65 XmlTextReader xtr = new XmlTextReader(sr); 65 XmlTextReader xtr = new XmlTextReader(sr);
66 66 xtr.ProhibitDtd = true;
67
67 xtr.ReadStartElement("RegionSettings"); 68 xtr.ReadStartElement("RegionSettings");
68 69
69 xtr.ReadStartElement("General"); 70 xtr.ReadStartElement("General");
70 71
71 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 72 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
72 { 73 {
73 switch (xtr.Name) 74 switch (xtr.Name)
@@ -113,10 +114,10 @@ namespace OpenSim.Framework.Serialization.External
113 break; 114 break;
114 } 115 }
115 } 116 }
116 117
117 xtr.ReadEndElement(); 118 xtr.ReadEndElement();
118 xtr.ReadStartElement("GroundTextures"); 119 xtr.ReadStartElement("GroundTextures");
119 120
120 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 121 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
121 { 122 {
122 switch (xtr.Name) 123 switch (xtr.Name)
@@ -159,10 +160,10 @@ namespace OpenSim.Framework.Serialization.External
159 break; 160 break;
160 } 161 }
161 } 162 }
162 163
163 xtr.ReadEndElement(); 164 xtr.ReadEndElement();
164 xtr.ReadStartElement("Terrain"); 165 xtr.ReadStartElement("Terrain");
165 166
166 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 167 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
167 { 168 {
168 switch (xtr.Name) 169 switch (xtr.Name)
@@ -212,19 +213,19 @@ namespace OpenSim.Framework.Serialization.External
212 213
213 xtr.Close(); 214 xtr.Close();
214 sr.Close(); 215 sr.Close();
215 216
216 return settings; 217 return settings;
217 } 218 }
218 219
219 public static string Serialize(RegionSettings settings) 220 public static string Serialize(RegionSettings settings)
220 { 221 {
221 StringWriter sw = new StringWriter(); 222 StringWriter sw = new StringWriter();
222 XmlTextWriter xtw = new XmlTextWriter(sw); 223 XmlTextWriter xtw = new XmlTextWriter(sw);
223 xtw.Formatting = Formatting.Indented; 224 xtw.Formatting = Formatting.Indented;
224 xtw.WriteStartDocument(); 225 xtw.WriteStartDocument();
225 226
226 xtw.WriteStartElement("RegionSettings"); 227 xtw.WriteStartElement("RegionSettings");
227 228
228 xtw.WriteStartElement("General"); 229 xtw.WriteStartElement("General");
229 xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString()); 230 xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString());
230 xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString()); 231 xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString());
@@ -255,7 +256,7 @@ namespace OpenSim.Framework.Serialization.External
255 xtw.WriteElementString("ElevationHighSE", settings.Elevation2SE.ToString()); 256 xtw.WriteElementString("ElevationHighSE", settings.Elevation2SE.ToString());
256 xtw.WriteElementString("ElevationHighNE", settings.Elevation2NE.ToString()); 257 xtw.WriteElementString("ElevationHighNE", settings.Elevation2NE.ToString());
257 xtw.WriteEndElement(); 258 xtw.WriteEndElement();
258 259
259 xtw.WriteStartElement("Terrain"); 260 xtw.WriteStartElement("Terrain");
260 xtw.WriteElementString("WaterHeight", settings.WaterHeight.ToString()); 261 xtw.WriteElementString("WaterHeight", settings.WaterHeight.ToString());
261 xtw.WriteElementString("TerrainRaiseLimit", settings.TerrainRaiseLimit.ToString()); 262 xtw.WriteElementString("TerrainRaiseLimit", settings.TerrainRaiseLimit.ToString());
@@ -275,12 +276,12 @@ namespace OpenSim.Framework.Serialization.External
275 xtw.WriteElementString("SpawnPoint", sp.ToString()); 276 xtw.WriteElementString("SpawnPoint", sp.ToString());
276 } 277 }
277 xtw.WriteEndElement(); 278 xtw.WriteEndElement();
278 279
279 xtw.WriteEndElement(); 280 xtw.WriteEndElement();
280 281
281 xtw.Close(); 282 xtw.Close();
282 sw.Close(); 283 sw.Close();
283 284
284 return sw.ToString(); 285 return sw.ToString();
285 } 286 }
286 } 287 }
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index 994cede..12194ad 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -36,9 +36,9 @@ using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39 39
40namespace OpenSim.Framework.Serialization.External 40namespace OpenSim.Framework.Serialization.External
41{ 41{
42 /// <summary> 42 /// <summary>
43 /// Serialize and deserialize user inventory items as an external format. 43 /// Serialize and deserialize user inventory items as an external format.
44 /// </summary> 44 /// </summary>
@@ -49,14 +49,14 @@ namespace OpenSim.Framework.Serialization.External
49 private static Dictionary<string, Action<InventoryItemBase, XmlReader>> m_InventoryItemXmlProcessors 49 private static Dictionary<string, Action<InventoryItemBase, XmlReader>> m_InventoryItemXmlProcessors
50 = new Dictionary<string, Action<InventoryItemBase, XmlReader>>(); 50 = new Dictionary<string, Action<InventoryItemBase, XmlReader>>();
51 51
52 #region InventoryItemBase Processor initialization 52 #region InventoryItemBase Processor initialization
53 static UserInventoryItemSerializer() 53 static UserInventoryItemSerializer()
54 { 54 {
55 m_InventoryItemXmlProcessors.Add("Name", ProcessName); 55 m_InventoryItemXmlProcessors.Add("Name", ProcessName);
56 m_InventoryItemXmlProcessors.Add("ID", ProcessID); 56 m_InventoryItemXmlProcessors.Add("ID", ProcessID);
57 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); 57 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType);
58 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); 58 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID);
59 m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID); 59 m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID);
60 m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData); 60 m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData);
61 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); 61 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate);
62 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); 62 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner);
@@ -73,7 +73,7 @@ namespace OpenSim.Framework.Serialization.External
73 m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID); 73 m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID);
74 m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned); 74 m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned);
75 } 75 }
76 #endregion 76 #endregion
77 77
78 #region InventoryItemBase Processors 78 #region InventoryItemBase Processors
79 private static void ProcessName(InventoryItemBase item, XmlReader reader) 79 private static void ProcessName(InventoryItemBase item, XmlReader reader)
@@ -189,7 +189,7 @@ namespace OpenSim.Framework.Serialization.External
189 { 189 {
190 return Deserialize(Encoding.ASCII.GetString(serialization, 0, serialization.Length)); 190 return Deserialize(Encoding.ASCII.GetString(serialization, 0, serialization.Length));
191 } 191 }
192 192
193 /// <summary> 193 /// <summary>
194 /// Deserialize settings 194 /// Deserialize settings
195 /// </summary> 195 /// </summary>
@@ -202,6 +202,8 @@ namespace OpenSim.Framework.Serialization.External
202 202
203 using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization))) 203 using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
204 { 204 {
205 reader.ProhibitDtd = true;
206
205 reader.ReadStartElement("InventoryItem"); 207 reader.ReadStartElement("InventoryItem");
206 208
207 ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>( 209 ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>(
@@ -212,8 +214,8 @@ namespace OpenSim.Framework.Serialization.External
212 214
213 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); 215 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
214 return item; 216 return item;
215 } 217 }
216 218
217 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) 219 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService)
218 { 220 {
219 StringWriter sw = new StringWriter(); 221 StringWriter sw = new StringWriter();
@@ -294,11 +296,11 @@ namespace OpenSim.Framework.Serialization.External
294 } 296 }
295 297
296 writer.WriteEndElement(); 298 writer.WriteEndElement();
297 299
298 writer.Close(); 300 writer.Close();
299 sw.Close(); 301 sw.Close();
300 302
301 return sw.ToString(); 303 return sw.ToString();
302 } 304 }
303 } 305 }
304} 306}
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
index c685a15..34eaa99 100644
--- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
@@ -42,31 +42,31 @@ namespace OpenSim.Framework.Serialization.External
42 { 42 {
43 public const int MAJOR_VERSION = 0; 43 public const int MAJOR_VERSION = 0;
44 public const int MINOR_VERSION = 1; 44 public const int MINOR_VERSION = 1;
45 45
46 public static string Serialize(UUID userID, string firstName, string lastName) 46 public static string Serialize(UUID userID, string firstName, string lastName)
47 { 47 {
48 StringWriter sw = new StringWriter(); 48 StringWriter sw = new StringWriter();
49 XmlTextWriter xtw = new XmlTextWriter(sw); 49 XmlTextWriter xtw = new XmlTextWriter(sw);
50 xtw.Formatting = Formatting.Indented; 50 xtw.Formatting = Formatting.Indented;
51 xtw.WriteStartDocument(); 51 xtw.WriteStartDocument();
52 52
53 xtw.WriteStartElement("user_profile"); 53 xtw.WriteStartElement("user_profile");
54 xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString()); 54 xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString());
55 xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString()); 55 xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString());
56 56
57 xtw.WriteElementString("name", firstName + " " + lastName); 57 xtw.WriteElementString("name", firstName + " " + lastName);
58 xtw.WriteElementString("id", userID.ToString()); 58 xtw.WriteElementString("id", userID.ToString());
59 xtw.WriteElementString("about", ""); 59 xtw.WriteElementString("about", "");
60 60
61 // Not sure if we're storing this yet, need to take a look 61 // Not sure if we're storing this yet, need to take a look
62// xtw.WriteElementString("Url", profile.Url); 62// xtw.WriteElementString("Url", profile.Url);
63 // or, indeed, interests 63 // or, indeed, interests
64 64
65 xtw.WriteEndElement(); 65 xtw.WriteEndElement();
66 66
67 xtw.Close(); 67 xtw.Close();
68 sw.Close(); 68 sw.Close();
69 69
70 return sw.ToString(); 70 return sw.ToString();
71 } 71 }
72 } 72 }
diff --git a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs
index acec20f..7dfb87b 100644
--- a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Framework.Serialization")] 8[assembly: AssemblyTitle("OpenSim.Framework.Serialization")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
index 2a3bc48..a5c3d0a 100644
--- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs
+++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Framework.Serialization
113 lock (m_bw) 113 lock (m_bw)
114 { 114 {
115 m_bw.Write(finalZeroPadding); 115 m_bw.Write(finalZeroPadding);
116 116
117 m_bw.Flush(); 117 m_bw.Flush();
118 m_bw.Close(); 118 m_bw.Close();
119 } 119 }
@@ -149,7 +149,7 @@ namespace OpenSim.Framework.Serialization
149 { 149 {
150// m_log.DebugFormat( 150// m_log.DebugFormat(
151// "[TAR ARCHIVE WRITER]: Data for {0} is {1} bytes", filePath, (null == data ? "null" : data.Length.ToString())); 151// "[TAR ARCHIVE WRITER]: Data for {0} is {1} bytes", filePath, (null == data ? "null" : data.Length.ToString()));
152 152
153 byte[] header = new byte[512]; 153 byte[] header = new byte[512];
154 154
155 // file path field (100) 155 // file path field (100)
@@ -208,18 +208,18 @@ namespace OpenSim.Framework.Serialization
208 { 208 {
209 // Write out header 209 // Write out header
210 m_bw.Write(header); 210 m_bw.Write(header);
211 211
212 // Write out data 212 // Write out data
213 // An IOException occurs if we try to write out an empty array in Mono 2.6 213 // An IOException occurs if we try to write out an empty array in Mono 2.6
214 if (data.Length > 0) 214 if (data.Length > 0)
215 m_bw.Write(data); 215 m_bw.Write(data);
216 216
217 if (data.Length % 512 != 0) 217 if (data.Length % 512 != 0)
218 { 218 {
219 int paddingRequired = 512 - (data.Length % 512); 219 int paddingRequired = 512 - (data.Length % 512);
220 220
221 //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); 221 //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired);
222 222
223 byte[] padding = new byte[paddingRequired]; 223 byte[] padding = new byte[paddingRequired];
224 m_bw.Write(padding); 224 m_bw.Write(padding);
225 } 225 }
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 5ce978e..81dd357 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -65,11 +65,12 @@ namespace OpenSim.Framework.Servers
65 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this 65 /// This will control a periodic log printout of the current 'show stats' (if they are active) for this
66 /// server. 66 /// server.
67 /// </summary> 67 /// </summary>
68
68 private int m_periodDiagnosticTimerMS = 60 * 60 * 1000; 69 private int m_periodDiagnosticTimerMS = 60 * 60 * 1000;
69 private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); 70 private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
70 71
71 /// <summary> 72 /// <summary>
72 /// Random uuid for private data 73 /// Random uuid for private data
73 /// </summary> 74 /// </summary>
74 protected string m_osSecret = String.Empty; 75 protected string m_osSecret = String.Empty;
75 76
@@ -83,9 +84,8 @@ namespace OpenSim.Framework.Servers
83 { 84 {
84 // Random uuid for private data 85 // Random uuid for private data
85 m_osSecret = UUID.Random().ToString(); 86 m_osSecret = UUID.Random().ToString();
86
87 } 87 }
88 88
89 /// <summary> 89 /// <summary>
90 /// Must be overriden by child classes for their own server specific startup behaviour. 90 /// Must be overriden by child classes for their own server specific startup behaviour.
91 /// </summary> 91 /// </summary>
@@ -104,26 +104,33 @@ namespace OpenSim.Framework.Servers
104 m_periodicDiagnosticsTimer.Interval = m_periodDiagnosticTimerMS; 104 m_periodicDiagnosticsTimer.Interval = m_periodDiagnosticTimerMS;
105 m_periodicDiagnosticsTimer.Enabled = true; 105 m_periodicDiagnosticsTimer.Enabled = true;
106 } 106 }
107 } 107 }
108 108
109 protected override void ShutdownSpecific() 109 protected override void ShutdownSpecific()
110 { 110 {
111 m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); 111 Watchdog.Enabled = false;
112 base.ShutdownSpecific();
113
114 MainServer.Stop();
115
116 Thread.Sleep(5000);
117 Util.StopThreadPool();
118 WorkManager.Stop();
112 119
120 Thread.Sleep(1000);
113 RemovePIDFile(); 121 RemovePIDFile();
114 122
115 base.ShutdownSpecific(); 123 m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting...");
116 124
117 if (!SuppressExit) 125 if (!SuppressExit)
118 System.Diagnostics.Process.GetCurrentProcess().Kill(); 126 Environment.Exit(0);
119//// Environment.Exit(0);
120 } 127 }
121 128
122 /// <summary> 129 /// <summary>
123 /// Provides a list of help topics that are available. Overriding classes should append their topics to the 130 /// Provides a list of help topics that are available. Overriding classes should append their topics to the
124 /// information returned when the base method is called. 131 /// information returned when the base method is called.
125 /// </summary> 132 /// </summary>
126 /// 133 ///
127 /// <returns> 134 /// <returns>
128 /// A list of strings that represent different help topics on which more information is available 135 /// A list of strings that represent different help topics on which more information is available
129 /// </returns> 136 /// </returns>
@@ -147,20 +154,38 @@ namespace OpenSim.Framework.Servers
147 /// Performs initialisation of the scene, such as loading configuration from disk. 154 /// Performs initialisation of the scene, such as loading configuration from disk.
148 /// </summary> 155 /// </summary>
149 public virtual void Startup() 156 public virtual void Startup()
150 { 157 {
151 StartupSpecific(); 158 m_log.Info("[STARTUP]: Beginning startup processing");
152 159
160 m_log.Info("[STARTUP]: version: " + m_version + Environment.NewLine);
161 // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
162 // the clr version number doesn't match the project version number under Mono.
163 //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
164 m_log.InfoFormat(
165 "[STARTUP]: Operating system version: {0}, .NET platform {1}, {2}-bit\n",
166 Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32");
167
168 try
169 {
170 StartupSpecific();
171 }
172 catch(Exception e)
173 {
174 m_log.Fatal("Fatal error: " + e.ToString());
175 Environment.Exit(1);
176 }
177
153 TimeSpan timeTaken = DateTime.Now - m_startuptime; 178 TimeSpan timeTaken = DateTime.Now - m_startuptime;
154 179
155 MainConsole.Instance.OutputFormat( 180// MainConsole.Instance.OutputFormat(
156 "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.", 181// "PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED. Non-script portion of startup took {0}m {1}s.",
157 timeTaken.Minutes, timeTaken.Seconds); 182// timeTaken.Minutes, timeTaken.Seconds);
158 } 183 }
159 184
160 public string osSecret 185 public string osSecret
161 { 186 {
162 // Secret uuid for the simulator 187 // Secret uuid for the simulator
163 get { return m_osSecret; } 188 get { return m_osSecret; }
164 } 189 }
165 190
166 public string StatReport(IOSHttpRequest httpRequest) 191 public string StatReport(IOSHttpRequest httpRequest)
@@ -169,8 +194,8 @@ namespace OpenSim.Framework.Servers
169 if (httpRequest.Query.ContainsKey("callback")) 194 if (httpRequest.Query.ContainsKey("callback"))
170 { 195 {
171 return httpRequest.Query["callback"].ToString() + "(" + StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");"; 196 return httpRequest.Query["callback"].ToString() + "(" + StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");";
172 } 197 }
173 else 198 else
174 { 199 {
175 return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); 200 return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
176 } 201 }
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index f252bd5..f4ba02f 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Framework.Servers.HttpServer
58 58
59 /// <summary> 59 /// <summary>
60 /// This is a pending websocket request before it got an sucessful upgrade response. 60 /// This is a pending websocket request before it got an sucessful upgrade response.
61 /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to 61 /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
62 /// start the connection and optionally provide an origin authentication method. 62 /// start the connection and optionally provide an origin authentication method.
63 /// </summary> 63 /// </summary>
64 /// <param name="servicepath"></param> 64 /// <param name="servicepath"></param>
@@ -104,7 +104,7 @@ namespace OpenSim.Framework.Servers.HttpServer
104 new Dictionary<string, PollServiceEventArgs>(); 104 new Dictionary<string, PollServiceEventArgs>();
105 105
106 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers = 106 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
107 new Dictionary<string, WebSocketRequestDelegate>(); 107 new Dictionary<string, WebSocketRequestDelegate>();
108 108
109 protected uint m_port; 109 protected uint m_port;
110 protected uint m_sslport; 110 protected uint m_sslport;
@@ -253,7 +253,7 @@ namespace OpenSim.Framework.Servers.HttpServer
253 return new List<string>(m_rpcHandlers.Keys); 253 return new List<string>(m_rpcHandlers.Keys);
254 } 254 }
255 255
256 // JsonRPC 256 // JsonRPC
257 public bool AddJsonRPCHandler(string method, JsonRPCMethod handler) 257 public bool AddJsonRPCHandler(string method, JsonRPCMethod handler)
258 { 258 {
259 lock(jsonRpcHandlers) 259 lock(jsonRpcHandlers)
@@ -399,10 +399,10 @@ namespace OpenSim.Framework.Servers.HttpServer
399 399
400 Stream requestStream = req.InputStream; 400 Stream requestStream = req.InputStream;
401 401
402 string requestBody;
402 Encoding encoding = Encoding.UTF8; 403 Encoding encoding = Encoding.UTF8;
403 StreamReader reader = new StreamReader(requestStream, encoding); 404 using(StreamReader reader = new StreamReader(requestStream, encoding))
404 405 requestBody = reader.ReadToEnd();
405 string requestBody = reader.ReadToEnd();
406 406
407 Hashtable keysvals = new Hashtable(); 407 Hashtable keysvals = new Hashtable();
408 Hashtable headervals = new Hashtable(); 408 Hashtable headervals = new Hashtable();
@@ -458,10 +458,11 @@ namespace OpenSim.Framework.Servers.HttpServer
458 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192)); 458 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192));
459 return; 459 return;
460 } 460 }
461 461
462 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 462 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
463 resp.ReuseContext = true; 463 resp.ReuseContext = true;
464 HandleRequest(req, resp); 464// resp.ReuseContext = false;
465 HandleRequest(req, resp);
465 466
466 // !!!HACK ALERT!!! 467 // !!!HACK ALERT!!!
467 // There seems to be a bug in the underlying http code that makes subsequent requests 468 // There seems to be a bug in the underlying http code that makes subsequent requests
@@ -552,7 +553,7 @@ namespace OpenSim.Framework.Servers.HttpServer
552 LogIncomingToStreamHandler(request, requestHandler); 553 LogIncomingToStreamHandler(request, requestHandler);
553 554
554 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 555 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
555 556
556 if (requestHandler is IStreamedRequestHandler) 557 if (requestHandler is IStreamedRequestHandler)
557 { 558 {
558 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 559 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@@ -565,13 +566,10 @@ namespace OpenSim.Framework.Servers.HttpServer
565 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; 566 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
566 Stream requestStream = request.InputStream; 567 Stream requestStream = request.InputStream;
567 568
569 string requestBody;
568 Encoding encoding = Encoding.UTF8; 570 Encoding encoding = Encoding.UTF8;
569 StreamReader reader = new StreamReader(requestStream, encoding); 571 using(StreamReader reader = new StreamReader(requestStream, encoding))
570 572 requestBody = reader.ReadToEnd();
571 string requestBody = reader.ReadToEnd();
572
573 reader.Close();
574 //requestStream.Close();
575 573
576 Hashtable keysvals = new Hashtable(); 574 Hashtable keysvals = new Hashtable();
577 Hashtable headervals = new Hashtable(); 575 Hashtable headervals = new Hashtable();
@@ -628,16 +626,16 @@ namespace OpenSim.Framework.Servers.HttpServer
628 case "text/html": 626 case "text/html":
629 if (DebugLevel >= 3) 627 if (DebugLevel >= 3)
630 LogIncomingToContentTypeHandler(request); 628 LogIncomingToContentTypeHandler(request);
631 629
632 buffer = HandleHTTPRequest(request, response); 630 buffer = HandleHTTPRequest(request, response);
633 break; 631 break;
634 632
635 case "application/llsd+xml": 633 case "application/llsd+xml":
636 case "application/xml+llsd": 634 case "application/xml+llsd":
637 case "application/llsd+json": 635 case "application/llsd+json":
638 if (DebugLevel >= 3) 636 if (DebugLevel >= 3)
639 LogIncomingToContentTypeHandler(request); 637 LogIncomingToContentTypeHandler(request);
640 638
641 buffer = HandleLLSDRequests(request, response); 639 buffer = HandleLLSDRequests(request, response);
642 break; 640 break;
643 641
@@ -647,7 +645,7 @@ namespace OpenSim.Framework.Servers.HttpServer
647 645
648 buffer = HandleJsonRpcRequests(request, response); 646 buffer = HandleJsonRpcRequests(request, response);
649 break; 647 break;
650 648
651 case "text/xml": 649 case "text/xml":
652 case "application/xml": 650 case "application/xml":
653 case "application/json": 651 case "application/json":
@@ -664,7 +662,7 @@ namespace OpenSim.Framework.Servers.HttpServer
664 { 662 {
665 if (DebugLevel >= 3) 663 if (DebugLevel >= 3)
666 LogIncomingToContentTypeHandler(request); 664 LogIncomingToContentTypeHandler(request);
667 665
668 buffer = HandleLLSDRequests(request, response); 666 buffer = HandleLLSDRequests(request, response);
669 } 667 }
670 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); 668 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
@@ -672,23 +670,24 @@ namespace OpenSim.Framework.Servers.HttpServer
672 { 670 {
673 if (DebugLevel >= 3) 671 if (DebugLevel >= 3)
674 LogIncomingToContentTypeHandler(request); 672 LogIncomingToContentTypeHandler(request);
675 673
676 buffer = HandleHTTPRequest(request, response); 674 buffer = HandleHTTPRequest(request, response);
677 } 675 }
678 else 676 else
679 { 677 {
680 if (DebugLevel >= 3) 678 if (DebugLevel >= 3)
681 LogIncomingToXmlRpcHandler(request); 679 LogIncomingToXmlRpcHandler(request);
682 680
683 // generic login request. 681 // generic login request.
684 buffer = HandleXmlRpcRequests(request, response); 682 buffer = HandleXmlRpcRequests(request, response);
685 } 683 }
686 684
687 break; 685 break;
688 } 686 }
689 } 687 }
690 688
691 request.InputStream.Close(); 689 if(request.InputStream.CanRead)
690 request.InputStream.Dispose();
692 691
693 if (buffer != null) 692 if (buffer != null)
694 { 693 {
@@ -759,7 +758,7 @@ namespace OpenSim.Framework.Servers.HttpServer
759 // Every month or so this will wrap and give bad numbers, not really a problem 758 // Every month or so this will wrap and give bad numbers, not really a problem
760 // since its just for reporting 759 // since its just for reporting
761 int tickdiff = requestEndTick - requestStartTick; 760 int tickdiff = requestEndTick - requestStartTick;
762 if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") 761 if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture"))
763 { 762 {
764 m_log.InfoFormat( 763 m_log.InfoFormat(
765 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", 764 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
@@ -970,7 +969,7 @@ namespace OpenSim.Framework.Servers.HttpServer
970// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) 969// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
971// { 970// {
972// agentHandler = null; 971// agentHandler = null;
973// 972//
974// lock (m_agentHandlers) 973// lock (m_agentHandlers)
975// { 974// {
976// foreach (IHttpAgentHandler handler in m_agentHandlers.Values) 975// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
@@ -996,7 +995,7 @@ namespace OpenSim.Framework.Servers.HttpServer
996 { 995 {
997 String requestBody; 996 String requestBody;
998 997
999 Stream requestStream = request.InputStream; 998 Stream requestStream = Util.Copy(request.InputStream);
1000 Stream innerStream = null; 999 Stream innerStream = null;
1001 try 1000 try
1002 { 1001 {
@@ -1007,9 +1006,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1007 } 1006 }
1008 1007
1009 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) 1008 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
1010 {
1011 requestBody = reader.ReadToEnd(); 1009 requestBody = reader.ReadToEnd();
1012 } 1010
1013 } 1011 }
1014 finally 1012 finally
1015 { 1013 {
@@ -1024,6 +1022,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1024 string responseString = String.Empty; 1022 string responseString = String.Empty;
1025 XmlRpcRequest xmlRprcRequest = null; 1023 XmlRpcRequest xmlRprcRequest = null;
1026 1024
1025 bool gridproxy = false;
1026 if (requestBody.Contains("encoding=\"utf-8"))
1027 {
1028 int channelindx = -1;
1029 int optionsindx = requestBody.IndexOf(">options<");
1030 if(optionsindx >0)
1031 {
1032 channelindx = requestBody.IndexOf(">channel<");
1033 if (optionsindx < channelindx)
1034 gridproxy = true;
1035 }
1036 }
1037
1027 try 1038 try
1028 { 1039 {
1029 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); 1040 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
@@ -1081,6 +1092,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1081 } 1092 }
1082 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] 1093 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
1083 1094
1095 if (gridproxy)
1096 xmlRprcRequest.Params.Add("gridproxy"); // Param[4]
1084 try 1097 try
1085 { 1098 {
1086 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); 1099 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint);
@@ -1154,7 +1167,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1154 return buffer; 1167 return buffer;
1155 } 1168 }
1156 1169
1157 // JsonRpc (v2.0 only) 1170 // JsonRpc (v2.0 only)
1158 // Batch requests not yet supported 1171 // Batch requests not yet supported
1159 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response) 1172 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response)
1160 { 1173 {
@@ -1171,7 +1184,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1171 jsonRpcResponse.Error.Code = ErrorCode.InternalError; 1184 jsonRpcResponse.Error.Code = ErrorCode.InternalError;
1172 jsonRpcResponse.Error.Message = e.Message; 1185 jsonRpcResponse.Error.Message = e.Message;
1173 } 1186 }
1174 1187
1175 requestStream.Close(); 1188 requestStream.Close();
1176 1189
1177 if (jsonRpcRequest != null) 1190 if (jsonRpcRequest != null)
@@ -1236,7 +1249,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1236 string responseData = string.Empty; 1249 string responseData = string.Empty;
1237 1250
1238 responseData = jsonRpcResponse.Serialize(); 1251 responseData = jsonRpcResponse.Serialize();
1239 1252
1240 byte[] buffer = Encoding.UTF8.GetBytes(responseData); 1253 byte[] buffer = Encoding.UTF8.GetBytes(responseData);
1241 return buffer; 1254 return buffer;
1242 } 1255 }
@@ -1246,12 +1259,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1246 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); 1259 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
1247 Stream requestStream = request.InputStream; 1260 Stream requestStream = request.InputStream;
1248 1261
1262 string requestBody;
1249 Encoding encoding = Encoding.UTF8; 1263 Encoding encoding = Encoding.UTF8;
1250 StreamReader reader = new StreamReader(requestStream, encoding); 1264 using(StreamReader reader = new StreamReader(requestStream, encoding))
1251 1265 requestBody= reader.ReadToEnd();
1252 string requestBody = reader.ReadToEnd();
1253 reader.Close();
1254 requestStream.Close();
1255 1266
1256 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); 1267 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
1257 response.KeepAlive = true; 1268 response.KeepAlive = true;
@@ -1516,7 +1527,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1516 } 1527 }
1517 } 1528 }
1518 } 1529 }
1519 1530
1520 if (String.IsNullOrEmpty(bestMatch)) 1531 if (String.IsNullOrEmpty(bestMatch))
1521 { 1532 {
1522 llsdHandler = null; 1533 llsdHandler = null;
@@ -1575,15 +1586,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1575 byte[] buffer; 1586 byte[] buffer;
1576 1587
1577 Stream requestStream = request.InputStream; 1588 Stream requestStream = request.InputStream;
1578 1589 string requestBody;
1579 Encoding encoding = Encoding.UTF8; 1590 Encoding encoding = Encoding.UTF8;
1580 StreamReader reader = new StreamReader(requestStream, encoding); 1591 using(StreamReader reader = new StreamReader(requestStream, encoding))
1581 1592 requestBody = reader.ReadToEnd();
1582 string requestBody = reader.ReadToEnd();
1583 // avoid warning for now
1584 reader.ReadToEnd();
1585 reader.Close();
1586 requestStream.Close();
1587 1593
1588 Hashtable keysvals = new Hashtable(); 1594 Hashtable keysvals = new Hashtable();
1589 Hashtable headervals = new Hashtable(); 1595 Hashtable headervals = new Hashtable();
@@ -1732,10 +1738,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1732 1738
1733 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1739 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1734 { 1740 {
1735 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1741 int responsecode;
1736 int responsecode = (int)responsedata["int_response_code"]; 1742 string responseString = String.Empty;
1737 string responseString = (string)responsedata["str_response_string"]; 1743 byte[] responseData = null;
1738 string contentType = (string)responsedata["content_type"]; 1744 string contentType;
1745
1746 if (responsedata == null)
1747 {
1748 responsecode = 500;
1749 responseString = "No response could be obtained";
1750 contentType = "text/plain";
1751 responsedata = new Hashtable();
1752 }
1753 else
1754 {
1755 try
1756 {
1757 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1758 responsecode = (int)responsedata["int_response_code"];
1759 if (responsedata["bin_response_data"] != null)
1760 responseData = (byte[])responsedata["bin_response_data"];
1761 else
1762 responseString = (string)responsedata["str_response_string"];
1763 contentType = (string)responsedata["content_type"];
1764 if (responseString == null)
1765 responseString = String.Empty;
1766 }
1767 catch
1768 {
1769 responsecode = 500;
1770 responseString = "No response could be obtained";
1771 contentType = "text/plain";
1772 responsedata = new Hashtable();
1773 }
1774 }
1739 1775
1740 if (responsedata.ContainsKey("error_status_text")) 1776 if (responsedata.ContainsKey("error_status_text"))
1741 { 1777 {
@@ -1745,16 +1781,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1745 { 1781 {
1746 response.ProtocolVersion = (string)responsedata["http_protocol_version"]; 1782 response.ProtocolVersion = (string)responsedata["http_protocol_version"];
1747 } 1783 }
1748 1784/*
1749 if (responsedata.ContainsKey("keepalive")) 1785 if (responsedata.ContainsKey("keepalive"))
1750 { 1786 {
1751 bool keepalive = (bool)responsedata["keepalive"]; 1787 bool keepalive = (bool)responsedata["keepalive"];
1752 response.KeepAlive = keepalive; 1788 response.KeepAlive = keepalive;
1753
1754 } 1789 }
1755 1790
1756 if (responsedata.ContainsKey("reusecontext")) 1791 if (responsedata.ContainsKey("reusecontext"))
1757 response.ReuseContext = (bool) responsedata["reusecontext"]; 1792 response.ReuseContext = (bool) responsedata["reusecontext"];
1793*/
1794 // disable this things
1795 response.KeepAlive = false;
1796 response.ReuseContext = false;
1758 1797
1759 // Cross-Origin Resource Sharing with simple requests 1798 // Cross-Origin Resource Sharing with simple requests
1760 if (responsedata.ContainsKey("access_control_allow_origin")) 1799 if (responsedata.ContainsKey("access_control_allow_origin"))
@@ -1768,8 +1807,11 @@ namespace OpenSim.Framework.Servers.HttpServer
1768 contentType = "text/html"; 1807 contentType = "text/html";
1769 } 1808 }
1770 1809
1810
1811
1771 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that 1812 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that
1772 1813
1814
1773 response.StatusCode = responsecode; 1815 response.StatusCode = responsecode;
1774 1816
1775 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) 1817 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
@@ -1780,25 +1822,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1780 1822
1781 response.AddHeader("Content-Type", contentType); 1823 response.AddHeader("Content-Type", contentType);
1782 1824
1825 if (responsedata.ContainsKey("headers"))
1826 {
1827 Hashtable headerdata = (Hashtable)responsedata["headers"];
1828
1829 foreach (string header in headerdata.Keys)
1830 response.AddHeader(header, headerdata[header].ToString());
1831 }
1832
1783 byte[] buffer; 1833 byte[] buffer;
1784 1834
1785 if (!(contentType.Contains("image") 1835 if (responseData != null)
1786 || contentType.Contains("x-shockwave-flash")
1787 || contentType.Contains("application/x-oar")
1788 || contentType.Contains("application/vnd.ll.mesh")))
1789 { 1836 {
1790 // Text 1837 buffer = responseData;
1791 buffer = Encoding.UTF8.GetBytes(responseString);
1792 } 1838 }
1793 else 1839 else
1794 { 1840 {
1795 // Binary! 1841 if (!(contentType.Contains("image")
1796 buffer = Convert.FromBase64String(responseString); 1842 || contentType.Contains("x-shockwave-flash")
1797 } 1843 || contentType.Contains("application/x-oar")
1844 || contentType.Contains("application/vnd.ll.mesh")))
1845 {
1846 // Text
1847 buffer = Encoding.UTF8.GetBytes(responseString);
1848 }
1849 else
1850 {
1851 // Binary!
1852 buffer = Convert.FromBase64String(responseString);
1853 }
1798 1854
1799 response.SendChunked = false; 1855 response.SendChunked = false;
1800 response.ContentLength64 = buffer.Length; 1856 response.ContentLength64 = buffer.Length;
1801 response.ContentEncoding = Encoding.UTF8; 1857 response.ContentEncoding = Encoding.UTF8;
1858 }
1802 1859
1803 return buffer; 1860 return buffer;
1804 } 1861 }
@@ -1831,8 +1888,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1831 response.SendChunked = false; 1888 response.SendChunked = false;
1832 response.ContentLength64 = buffer.Length; 1889 response.ContentLength64 = buffer.Length;
1833 response.ContentEncoding = Encoding.UTF8; 1890 response.ContentEncoding = Encoding.UTF8;
1834 1891
1835 1892
1836 return buffer; 1893 return buffer;
1837 } 1894 }
1838 1895
@@ -1886,7 +1943,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1886 m_httpListener2.Start(64); 1943 m_httpListener2.Start(64);
1887 1944
1888 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1945 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1889 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 3, 25000); 1946
1947 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000);
1890 PollServiceRequestManager.Start(); 1948 PollServiceRequestManager.Start();
1891 1949
1892 HTTPDRunning = true; 1950 HTTPDRunning = true;
@@ -1908,7 +1966,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1908 throw e; 1966 throw e;
1909 } 1967 }
1910 1968
1911 m_requestsProcessedStat 1969 m_requestsProcessedStat
1912 = new Stat( 1970 = new Stat(
1913 "HTTPRequestsServed", 1971 "HTTPRequestsServed",
1914 "Number of inbound HTTP requests processed", 1972 "Number of inbound HTTP requests processed",
@@ -1920,7 +1978,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1920 MeasuresOfInterest.AverageChangeOverTime, 1978 MeasuresOfInterest.AverageChangeOverTime,
1921 stat => stat.Value = RequestNumber, 1979 stat => stat.Value = RequestNumber,
1922 StatVerbosity.Debug); 1980 StatVerbosity.Debug);
1923 1981
1924 StatsManager.RegisterStat(m_requestsProcessedStat); 1982 StatsManager.RegisterStat(m_requestsProcessedStat);
1925 } 1983 }
1926 1984
@@ -1937,7 +1995,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1937 1995
1938 public void httpServerException(object source, Exception exception) 1996 public void httpServerException(object source, Exception exception)
1939 { 1997 {
1940 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 1998 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
1999 return;
2000 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1941 /* 2001 /*
1942 if (HTTPDRunning)// && NotSocketErrors > 5) 2002 if (HTTPDRunning)// && NotSocketErrors > 5)
1943 { 2003 {
@@ -1957,7 +2017,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1957 2017
1958 try 2018 try
1959 { 2019 {
1960 PollServiceRequestManager.Stop(); 2020 if(PollServiceRequestManager != null)
2021 PollServiceRequestManager.Stop();
1961 2022
1962 m_httpListener2.ExceptionThrown -= httpServerException; 2023 m_httpListener2.ExceptionThrown -= httpServerException;
1963 //m_httpListener2.DisconnectHandler = null; 2024 //m_httpListener2.DisconnectHandler = null;
@@ -1984,6 +2045,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1984 2045
1985 public void RemoveHTTPHandler(string httpMethod, string path) 2046 public void RemoveHTTPHandler(string httpMethod, string path)
1986 { 2047 {
2048 if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null
1987 lock (m_HTTPHandlers) 2049 lock (m_HTTPHandlers)
1988 { 2050 {
1989 if (httpMethod != null && httpMethod.Length == 0) 2051 if (httpMethod != null && httpMethod.Length == 0)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
index d4a1ec3..01d95e9 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
@@ -69,13 +69,13 @@ namespace OpenSim.Framework.Servers.HttpServer
69 { 69 {
70 StatsManager.RegisterStat( 70 StatsManager.RegisterStat(
71 new Stat( 71 new Stat(
72 "requests", 72 "requests",
73 "requests", 73 "requests",
74 "Number of requests received by this service endpoint", 74 "Number of requests received by this service endpoint",
75 "requests", 75 "requests",
76 "service", 76 "service",
77 string.Format("{0}:{1}", httpMethod, path), 77 string.Format("{0}:{1}", httpMethod, path),
78 StatType.Pull, 78 StatType.Pull,
79 MeasuresOfInterest.AverageChangeOverTime, 79 MeasuresOfInterest.AverageChangeOverTime,
80 s => s.Value = RequestsReceived, 80 s => s.Value = RequestsReceived,
81 StatVerbosity.Debug)); 81 StatVerbosity.Debug));
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
index 41aa19b..7fc9f0b 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Framework.Servers.HttpServer
47 : base(httpMethod, path, name, description) {} 47 : base(httpMethod, path, name, description) {}
48 48
49 protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth) 49 protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth)
50 : base(httpMethod, path, null, null) 50 : base(httpMethod, path, null, null)
51 { 51 {
52 m_Auth = auth; 52 m_Auth = auth;
53 } 53 }
@@ -62,7 +62,7 @@ namespace OpenSim.Framework.Servers.HttpServer
62 HttpStatusCode statusCode; 62 HttpStatusCode statusCode;
63 63
64 if (!m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader, out statusCode)) 64 if (!m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader, out statusCode))
65 { 65 {
66 httpResponse.StatusCode = (int)statusCode; 66 httpResponse.StatusCode = (int)statusCode;
67 httpResponse.ContentType = "text/plain"; 67 httpResponse.ContentType = "text/plain";
68 return new byte[0]; 68 return new byte[0];
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandlerBasicDOSProtector.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandlerBasicDOSProtector.cs
index 1b88545..9619e03 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandlerBasicDOSProtector.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandlerBasicDOSProtector.cs
@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Servers.HttpServer
37 /// </remarks> 37 /// </remarks>
38 public abstract class BaseStreamHandlerBasicDOSProtector : BaseRequestHandler, IStreamedRequestHandler 38 public abstract class BaseStreamHandlerBasicDOSProtector : BaseRequestHandler, IStreamedRequestHandler
39 { 39 {
40 40
41 private readonly BasicDosProtectorOptions _options; 41 private readonly BasicDosProtectorOptions _options;
42 private readonly BasicDOSProtector _dosProtector; 42 private readonly BasicDOSProtector _dosProtector;
43 43
@@ -63,7 +63,7 @@ namespace OpenSim.Framework.Servers.HttpServer
63 result = ThrottledRequest(path, request, httpRequest, httpResponse); 63 result = ThrottledRequest(path, request, httpRequest, httpResponse);
64 if (_options.MaxConcurrentSessions > 0) 64 if (_options.MaxConcurrentSessions > 0)
65 _dosProtector.ProcessEnd(clientstring, endpoint); 65 _dosProtector.ProcessEnd(clientstring, endpoint);
66 66
67 RequestsHandled++; 67 RequestsHandled++;
68 68
69 return result; 69 return result;
@@ -81,7 +81,7 @@ namespace OpenSim.Framework.Servers.HttpServer
81 return new byte[0]; 81 return new byte[0];
82 } 82 }
83 83
84 84
85 private string GetRemoteAddr(IOSHttpRequest httpRequest) 85 private string GetRemoteAddr(IOSHttpRequest httpRequest)
86 { 86 {
87 string remoteaddr = string.Empty; 87 string remoteaddr = string.Empty;
@@ -101,7 +101,7 @@ namespace OpenSim.Framework.Servers.HttpServer
101 clientstring = GetRemoteAddr(httpRequest); 101 clientstring = GetRemoteAddr(httpRequest);
102 102
103 return clientstring; 103 return clientstring;
104 104
105 } 105 }
106 } 106 }
107} 107}
diff --git a/OpenSim/Framework/Servers/HttpServer/GenericHTTPBasicDOSProtector.cs b/OpenSim/Framework/Servers/HttpServer/GenericHTTPBasicDOSProtector.cs
index cd4b8ff..98d33e4 100644
--- a/OpenSim/Framework/Servers/HttpServer/GenericHTTPBasicDOSProtector.cs
+++ b/OpenSim/Framework/Servers/HttpServer/GenericHTTPBasicDOSProtector.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Framework.Servers.HttpServer
33 { 33 {
34 private readonly GenericHTTPMethod _normalMethod; 34 private readonly GenericHTTPMethod _normalMethod;
35 private readonly GenericHTTPMethod _throttledMethod; 35 private readonly GenericHTTPMethod _throttledMethod;
36 36
37 private readonly BasicDosProtectorOptions _options; 37 private readonly BasicDosProtectorOptions _options;
38 private readonly BasicDOSProtector _dosProtector; 38 private readonly BasicDOSProtector _dosProtector;
39 39
@@ -41,7 +41,7 @@ namespace OpenSim.Framework.Servers.HttpServer
41 { 41 {
42 _normalMethod = normalMethod; 42 _normalMethod = normalMethod;
43 _throttledMethod = throttledMethod; 43 _throttledMethod = throttledMethod;
44 44
45 _options = options; 45 _options = options;
46 _dosProtector = new BasicDOSProtector(_options); 46 _dosProtector = new BasicDOSProtector(_options);
47 } 47 }
@@ -60,7 +60,7 @@ namespace OpenSim.Framework.Servers.HttpServer
60 60
61 return process; 61 return process;
62 } 62 }
63 63
64 private string GetRemoteAddr(Hashtable request) 64 private string GetRemoteAddr(Hashtable request)
65 { 65 {
66 string remoteaddr = ""; 66 string remoteaddr = "";
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
index d162bc1..3a04074 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
@@ -45,26 +45,26 @@ namespace OpenSim.Framework.Servers.HttpServer
45// // the handlers - it is NOT required to be an actual agent header 45// // the handlers - it is NOT required to be an actual agent header
46// // value. 46// // value.
47// bool AddAgentHandler(string agent, IHttpAgentHandler handler); 47// bool AddAgentHandler(string agent, IHttpAgentHandler handler);
48 48
49 /// <summary> 49 /// <summary>
50 /// Add a handler for an HTTP request. 50 /// Add a handler for an HTTP request.
51 /// </summary> 51 /// </summary>
52 /// <remarks> 52 /// <remarks>
53 /// This handler can actually be invoked either as 53 /// This handler can actually be invoked either as
54 /// 54 ///
55 /// http://<hostname>:<port>/?method=<methodName> 55 /// http://<hostname>:<port>/?method=<methodName>
56 /// 56 ///
57 /// or 57 /// or
58 /// 58 ///
59 /// http://<hostname>:<port><method> 59 /// http://<hostname>:<port><method>
60 /// 60 ///
61 /// if the method name starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region 61 /// if the method name starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
62 /// server will register a handler that can be invoked with either 62 /// server will register a handler that can be invoked with either
63 /// 63 ///
64 /// http://localhost:9000/?method=/object/ 64 /// http://localhost:9000/?method=/object/
65 /// 65 ///
66 /// or 66 /// or
67 /// 67 ///
68 /// http://localhost:9000/object/ 68 /// http://localhost:9000/object/
69 /// 69 ///
70 /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request 70 /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request
@@ -87,7 +87,7 @@ namespace OpenSim.Framework.Servers.HttpServer
87 /// <param name="handler">handle the LLSD response</param> 87 /// <param name="handler">handle the LLSD response</param>
88 /// <returns></returns> 88 /// <returns></returns>
89 bool AddLLSDHandler(string path, LLSDMethod handler); 89 bool AddLLSDHandler(string path, LLSDMethod handler);
90 90
91 /// <summary> 91 /// <summary>
92 /// Add a stream handler to the http server. If the handler already exists, then nothing happens. 92 /// Add a stream handler to the http server. If the handler already exists, then nothing happens.
93 /// </summary> 93 /// </summary>
@@ -98,7 +98,7 @@ namespace OpenSim.Framework.Servers.HttpServer
98 bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive); 98 bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive);
99 99
100 bool AddJsonRPCHandler(string method, JsonRPCMethod handler); 100 bool AddJsonRPCHandler(string method, JsonRPCMethod handler);
101 101
102 /// <summary> 102 /// <summary>
103 /// Websocket HTTP server handlers. 103 /// Websocket HTTP server handlers.
104 /// </summary> 104 /// </summary>
@@ -108,7 +108,7 @@ namespace OpenSim.Framework.Servers.HttpServer
108 108
109 109
110 void RemoveWebSocketHandler(string servicepath); 110 void RemoveWebSocketHandler(string servicepath);
111 111
112 /// <summary> 112 /// <summary>
113 /// Gets the XML RPC handler for given method name 113 /// Gets the XML RPC handler for given method name
114 /// </summary> 114 /// </summary>
@@ -125,7 +125,7 @@ namespace OpenSim.Framework.Servers.HttpServer
125// /// <param name="handler"></param> 125// /// <param name="handler"></param>
126// /// <returns></returns> 126// /// <returns></returns>
127// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); 127// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
128 128
129 /// <summary> 129 /// <summary>
130 /// Remove an HTTP handler 130 /// Remove an HTTP handler
131 /// </summary> 131 /// </summary>
@@ -134,15 +134,15 @@ namespace OpenSim.Framework.Servers.HttpServer
134 void RemoveHTTPHandler(string httpMethod, string path); 134 void RemoveHTTPHandler(string httpMethod, string path);
135 135
136 void RemovePollServiceHTTPHandler(string httpMethod, string path); 136 void RemovePollServiceHTTPHandler(string httpMethod, string path);
137 137
138 bool RemoveLLSDHandler(string path, LLSDMethod handler); 138 bool RemoveLLSDHandler(string path, LLSDMethod handler);
139 139
140 void RemoveStreamHandler(string httpMethod, string path); 140 void RemoveStreamHandler(string httpMethod, string path);
141 141
142 void RemoveXmlRPCHandler(string method); 142 void RemoveXmlRPCHandler(string method);
143 143
144 void RemoveJsonRPCHandler(string method); 144 void RemoveJsonRPCHandler(string method);
145 145
146 string GetHTTP404(string host); 146 string GetHTTP404(string host);
147 147
148 string GetHTTP500(); 148 string GetHTTP500();
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
index b8541cb..62d92fb 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Framework.Servers.HttpServer
83 { 83 {
84 void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); 84 void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse);
85 } 85 }
86 86
87 public interface IGenericHTTPHandler : IRequestHandler 87 public interface IGenericHTTPHandler : IRequestHandler
88 { 88 {
89 Hashtable Handle(string path, Hashtable request); 89 Hashtable Handle(string path, Hashtable request);
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs
index 2fe1a7d..411ee31 100644
--- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework.Servers.HttpServer
43 public class JsonRpcRequestManager 43 public class JsonRpcRequestManager
44 { 44 {
45 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 public JsonRpcRequestManager() 47 public JsonRpcRequestManager()
48 { 48 {
49 } 49 }
@@ -77,6 +77,9 @@ namespace OpenSim.Framework.Servers.HttpServer
77 if (parameters == null) 77 if (parameters == null)
78 throw new ArgumentNullException("parameters"); 78 throw new ArgumentNullException("parameters");
79 79
80 if(string.IsNullOrWhiteSpace(uri))
81 return false;
82
80 OSDMap request = new OSDMap(); 83 OSDMap request = new OSDMap();
81 request.Add("jsonrpc", OSD.FromString("2.0")); 84 request.Add("jsonrpc", OSD.FromString("2.0"));
82 request.Add("id", OSD.FromString(jsonId)); 85 request.Add("id", OSD.FromString(jsonId));
@@ -185,6 +188,6 @@ namespace OpenSim.Framework.Servers.HttpServer
185 188
186 return true; 189 return true;
187 } 190 }
188 191
189 } 192 }
190} 193}
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs
index 2c50587..91d284b 100644
--- a/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs
+++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs
@@ -144,7 +144,7 @@ namespace OpenSim.Framework.Servers.HttpServer
144 { 144 {
145 145
146 } 146 }
147 return result; 147 return result;
148 } 148 }
149 } 149 }
150} 150}
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
index 05ec6dc..1a6b8cf 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs
@@ -155,11 +155,11 @@ namespace OpenSim.Framework.Servers.HttpServer
155 private string _userAgent; 155 private string _userAgent;
156 156
157 internal IHttpRequest IHttpRequest 157 internal IHttpRequest IHttpRequest
158 { 158 {
159 get { return _request; } 159 get { return _request; }
160 } 160 }
161 161
162 internal IHttpClientContext IHttpClientContext 162 internal IHttpClientContext IHttpClientContext
163 { 163 {
164 get { return _context; } 164 get { return _context; }
165 } 165 }
@@ -192,19 +192,19 @@ namespace OpenSim.Framework.Servers.HttpServer
192 // ignore 192 // ignore
193 } 193 }
194 } 194 }
195 195
196 if (null != req.Headers["content-type"]) 196 if (null != req.Headers["content-type"])
197 _contentType = _request.Headers["content-type"]; 197 _contentType = _request.Headers["content-type"];
198 if (null != req.Headers["user-agent"]) 198 if (null != req.Headers["user-agent"])
199 _userAgent = req.Headers["user-agent"]; 199 _userAgent = req.Headers["user-agent"];
200 200
201 if (null != req.Headers["remote_addr"]) 201 if (null != req.Headers["remote_addr"])
202 { 202 {
203 try 203 try
204 { 204 {
205 IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]); 205 IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]);
206 // sometimes req.Headers["remote_port"] returns a comma separated list, so use 206 // sometimes req.Headers["remote_port"] returns a comma separated list, so use
207 // the first one in the list and log it 207 // the first one in the list and log it
208 string[] strPorts = req.Headers["remote_port"].Split(new char[] { ',' }); 208 string[] strPorts = req.Headers["remote_port"].Split(new char[] { ',' });
209 if (strPorts.Length > 1) 209 if (strPorts.Length > 1)
210 { 210 {
@@ -216,7 +216,7 @@ namespace OpenSim.Framework.Servers.HttpServer
216 } 216 }
217 catch (FormatException) 217 catch (FormatException)
218 { 218 {
219 _log.ErrorFormat("[OSHttpRequest]: format exception on addr/port {0}:{1}, ignoring", 219 _log.ErrorFormat("[OSHttpRequest]: format exception on addr/port {0}:{1}, ignoring",
220 req.Headers["remote_addr"], req.Headers["remote_port"]); 220 req.Headers["remote_addr"], req.Headers["remote_port"]);
221 } 221 }
222 } 222 }
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
index 89fb5d4..d7744fc 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs
@@ -115,7 +115,7 @@ namespace OpenSim.Framework.Servers.HttpServer
115 115
116 public bool KeepAlive 116 public bool KeepAlive
117 { 117 {
118 get 118 get
119 { 119 {
120 return _httpResponse.Connection == ConnectionType.KeepAlive; 120 return _httpResponse.Connection == ConnectionType.KeepAlive;
121 } 121 }
@@ -148,6 +148,7 @@ namespace OpenSim.Framework.Servers.HttpServer
148 _httpResponse.Connection = ConnectionType.Close; 148 _httpResponse.Connection = ConnectionType.Close;
149 _httpResponse.KeepAlive = 0; 149 _httpResponse.KeepAlive = 0;
150 } 150 }
151
151 else 152 else
152 { 153 {
153 _httpResponse.Connection = ConnectionType.KeepAlive; 154 _httpResponse.Connection = ConnectionType.KeepAlive;
@@ -320,6 +321,7 @@ namespace OpenSim.Framework.Servers.HttpServer
320 public void Send() 321 public void Send()
321 { 322 {
322 _httpResponse.Body.Flush(); 323 _httpResponse.Body.Flush();
324
323 _httpResponse.Send(); 325 _httpResponse.Send();
324 } 326 }
325 327
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpStatusCodes.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpStatusCodes.cs
index a736c8b..88e3068 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpStatusCodes.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpStatusCodes.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Framework.Servers.HttpServer
91 /// 300 Redirect: different presentation forms available, take a pick 91 /// 300 Redirect: different presentation forms available, take a pick
92 /// </summary> 92 /// </summary>
93 RedirectMultipleChoices = 300, 93 RedirectMultipleChoices = 300,
94 94
95 /// <summary> 95 /// <summary>
96 /// 301 Redirect: requested resource has moved and now lives somewhere else 96 /// 301 Redirect: requested resource has moved and now lives somewhere else
97 /// </summary> 97 /// </summary>
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index 9477100..7150aad 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -46,13 +46,15 @@ namespace OpenSim.Framework.Servers.HttpServer
46 public RequestMethod Request; 46 public RequestMethod Request;
47 public UUID Id; 47 public UUID Id;
48 public int TimeOutms; 48 public int TimeOutms;
49 public EventType Type; 49 public EventType Type;
50 50
51 public enum EventType : int 51 public enum EventType : int
52 { 52 {
53 LongPoll = 0, 53 Poll = 0,
54 LslHttp = 1, 54 LslHttp = 1,
55 Inventory = 2 55 Inventory = 2,
56 Texture = 3,
57 Mesh = 4
56 } 58 }
57 59
58 public string Url { get; set; } 60 public string Url { get; set; }
@@ -80,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer
80 NoEvents = pNoEvents; 82 NoEvents = pNoEvents;
81 Id = pId; 83 Id = pId;
82 TimeOutms = pTimeOutms; 84 TimeOutms = pTimeOutms;
83 Type = EventType.LongPoll; 85 Type = EventType.Poll;
84 } 86 }
85 } 87 }
86} 88}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index caf0e98..fefcb20 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using System.Text; 32using System.Text;
32using HttpServer; 33using HttpServer;
@@ -44,6 +45,24 @@ namespace OpenSim.Framework.Servers.HttpServer
44 public readonly IHttpRequest Request; 45 public readonly IHttpRequest Request;
45 public readonly int RequestTime; 46 public readonly int RequestTime;
46 public readonly UUID RequestID; 47 public readonly UUID RequestID;
48 public int contextHash;
49
50 private void GenContextHash()
51 {
52 Random rnd = new Random();
53 contextHash = 0;
54 if (Request.Headers["remote_addr"] != null)
55 contextHash = (Request.Headers["remote_addr"]).GetHashCode() << 16;
56 else
57 contextHash = rnd.Next() << 16;
58 if (Request.Headers["remote_port"] != null)
59 {
60 string[] strPorts = Request.Headers["remote_port"].Split(new char[] { ',' });
61 contextHash += Int32.Parse(strPorts[0]);
62 }
63 else
64 contextHash += rnd.Next() & 0xffff;
65 }
47 66
48 public PollServiceHttpRequest( 67 public PollServiceHttpRequest(
49 PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) 68 PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
@@ -53,6 +72,7 @@ namespace OpenSim.Framework.Servers.HttpServer
53 Request = pRequest; 72 Request = pRequest;
54 RequestTime = System.Environment.TickCount; 73 RequestTime = System.Environment.TickCount;
55 RequestID = UUID.Random(); 74 RequestID = UUID.Random();
75 GenContextHash();
56 } 76 }
57 77
58 internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) 78 internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata)
@@ -62,36 +82,69 @@ namespace OpenSim.Framework.Servers.HttpServer
62 82
63 byte[] buffer = server.DoHTTPGruntWork(responsedata, response); 83 byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
64 84
85 if(Request.Body.CanRead)
86 Request.Body.Dispose();
87
65 response.SendChunked = false; 88 response.SendChunked = false;
66 response.ContentLength64 = buffer.Length; 89 response.ContentLength64 = buffer.Length;
67 response.ContentEncoding = Encoding.UTF8; 90 response.ContentEncoding = Encoding.UTF8;
91 response.ReuseContext = false;
68 92
69 try 93 try
70 { 94 {
71 response.OutputStream.Write(buffer, 0, buffer.Length); 95 response.OutputStream.Write(buffer, 0, buffer.Length);
96 response.OutputStream.Flush();
97 response.Send();
98 buffer = null;
72 } 99 }
73 catch (Exception ex) 100 catch (Exception ex)
74 { 101 {
75 m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", ex); 102 m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", ex);
76 } 103 }
77 finally 104
105 PollServiceArgs.RequestsHandled++;
106 }
107
108 internal void DoHTTPstop(BaseHttpServer server)
109 {
110 OSHttpResponse response
111 = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);
112
113 if(Request.Body.CanRead)
114 Request.Body.Dispose();
115
116 response.SendChunked = false;
117 response.ContentLength64 = 0;
118 response.ContentEncoding = Encoding.UTF8;
119 response.ReuseContext = false;
120 response.KeepAlive = false;
121 response.SendChunked = false;
122 response.StatusCode = 503;
123
124 try
78 { 125 {
79 //response.OutputStream.Close(); 126 response.OutputStream.Flush();
80 try 127 response.Send();
81 {
82 response.OutputStream.Flush();
83 response.Send();
84
85 //if (!response.KeepAlive && response.ReuseContext)
86 // response.FreeContext();
87 }
88 catch (Exception e)
89 {
90 m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", e);
91 }
92
93 PollServiceArgs.RequestsHandled++;
94 } 128 }
129 catch (Exception e)
130 {
131 }
132 }
133 }
134
135 class PollServiceHttpRequestComparer : IEqualityComparer<PollServiceHttpRequest>
136 {
137 public bool Equals(PollServiceHttpRequest b1, PollServiceHttpRequest b2)
138 {
139 if (b1.contextHash != b2.contextHash)
140 return false;
141 bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext);
142 return b;
143 }
144
145 public int GetHashCode(PollServiceHttpRequest b2)
146 {
147 return (int)b2.contextHash;
95 } 148 }
96 } 149 }
97} \ No newline at end of file 150} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 28bba70..c6a3e65 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -44,200 +44,183 @@ namespace OpenSim.Framework.Servers.HttpServer
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 /// <summary>
48 /// Is the poll service request manager running?
49 /// </summary>
50 /// <remarks>
51 /// Can be running either synchronously or asynchronously
52 /// </remarks>
53 public bool IsRunning { get; private set; }
54
55 /// <summary>
56 /// Is the poll service performing responses asynchronously (with its own threads) or synchronously (via
57 /// external calls)?
58 /// </summary>
59 public bool PerformResponsesAsync { get; private set; }
60
61 /// <summary>
62 /// Number of responses actually processed and sent to viewer (or aborted due to error).
63 /// </summary>
64 public int ResponsesProcessed { get; private set; }
65
66 private readonly BaseHttpServer m_server; 47 private readonly BaseHttpServer m_server;
67 48
49 private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext;
68 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); 50 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
69 private static List<PollServiceHttpRequest> m_longPollRequests = new List<PollServiceHttpRequest>(); 51 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
70 52
71 private uint m_WorkerThreadCount = 0; 53 private uint m_WorkerThreadCount = 0;
72 private Thread[] m_workerThreads; 54 private Thread[] m_workerThreads;
55 private Thread m_retrysThread;
73 56
74 private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2); 57 private bool m_running = false;
75 58
76// private int m_timeout = 1000; // increase timeout 250; now use the event one 59 private SmartThreadPool m_threadPool;
77 60
78 public PollServiceRequestManager( 61 public PollServiceRequestManager(
79 BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) 62 BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout)
80 { 63 {
81 m_server = pSrv; 64 m_server = pSrv;
82 PerformResponsesAsync = performResponsesAsync;
83 m_WorkerThreadCount = pWorkerThreadCount; 65 m_WorkerThreadCount = pWorkerThreadCount;
84 m_workerThreads = new Thread[m_WorkerThreadCount]; 66 m_workerThreads = new Thread[m_WorkerThreadCount];
85 67
86 StatsManager.RegisterStat( 68 PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer();
87 new Stat( 69 m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp);
88 "QueuedPollResponses", 70
89 "Number of poll responses queued for processing.", 71 STPStartInfo startInfo = new STPStartInfo();
90 "", 72 startInfo.IdleTimeout = 30000;
91 "", 73 startInfo.MaxWorkerThreads = 20;
92 "httpserver", 74 startInfo.MinWorkerThreads = 1;
93 m_server.Port.ToString(), 75 startInfo.ThreadPriority = ThreadPriority.Normal;
94 StatType.Pull, 76 startInfo.StartSuspended = true;
95 MeasuresOfInterest.AverageChangeOverTime, 77 startInfo.ThreadPoolName = "PoolService";
96 stat => stat.Value = m_requests.Count(), 78
97 StatVerbosity.Debug)); 79 m_threadPool = new SmartThreadPool(startInfo);
98
99 StatsManager.RegisterStat(
100 new Stat(
101 "ProcessedPollResponses",
102 "Number of poll responses processed.",
103 "",
104 "",
105 "httpserver",
106 m_server.Port.ToString(),
107 StatType.Pull,
108 MeasuresOfInterest.AverageChangeOverTime,
109 stat => stat.Value = ResponsesProcessed,
110 StatVerbosity.Debug));
111 } 80 }
112 81
113 public void Start() 82 public void Start()
114 { 83 {
115 IsRunning = true; 84 m_running = true;
116 85 m_threadPool.Start();
117 if (PerformResponsesAsync) 86 //startup worker threads
87 for (uint i = 0; i < m_WorkerThreadCount; i++)
118 { 88 {
119 //startup worker threads 89 m_workerThreads[i]
120 for (uint i = 0; i < m_WorkerThreadCount; i++) 90 = WorkManager.StartThread(
121 { 91 PoolWorkerJob,
122 m_workerThreads[i] 92 string.Format("PollServiceWorkerThread {0}:{1}", i, m_server.Port),
123 = WorkManager.StartThread( 93 ThreadPriority.Normal,
124 PoolWorkerJob, 94 true,
125 string.Format("PollServiceWorkerThread{0}:{1}", i, m_server.Port), 95 false,
126 ThreadPriority.Normal, 96 null,
127 false, 97 int.MaxValue);
128 false,
129 null,
130 int.MaxValue);
131 }
132
133 WorkManager.StartThread(
134 this.CheckLongPollThreads,
135 string.Format("LongPollServiceWatcherThread:{0}", m_server.Port),
136 ThreadPriority.Normal,
137 false,
138 true,
139 null,
140 1000 * 60 * 10);
141 } 98 }
99
100 m_retrysThread = WorkManager.StartThread(
101 this.CheckRetries,
102 string.Format("PollServiceWatcherThread:{0}", m_server.Port),
103 ThreadPriority.Normal,
104 true,
105 true,
106 null,
107 1000 * 60 * 10);
108
109
142 } 110 }
143 111
144 private void ReQueueEvent(PollServiceHttpRequest req) 112 private void ReQueueEvent(PollServiceHttpRequest req)
145 { 113 {
146 if (IsRunning) 114 if (m_running)
147 { 115 {
148 // delay the enqueueing for 100ms. There's no need to have the event 116 lock (m_retryRequests)
149 // actively on the queue 117 m_retryRequests.Enqueue(req);
150 Timer t = new Timer(self => {
151 ((Timer)self).Dispose();
152 m_requests.Enqueue(req);
153 });
154
155 t.Change(100, Timeout.Infinite);
156
157 } 118 }
158 } 119 }
159 120
160 public void Enqueue(PollServiceHttpRequest req) 121 public void Enqueue(PollServiceHttpRequest req)
161 { 122 {
162 if (IsRunning) 123 lock (m_bycontext)
163 { 124 {
164 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) 125 Queue<PollServiceHttpRequest> ctxQeueue;
126 if (m_bycontext.TryGetValue(req, out ctxQeueue))
165 { 127 {
166 lock (m_longPollRequests) 128 ctxQeueue.Enqueue(req);
167 m_longPollRequests.Add(req);
168 } 129 }
169 else 130 else
170 m_requests.Enqueue(req); 131 {
132 ctxQeueue = new Queue<PollServiceHttpRequest>();
133 m_bycontext[req] = ctxQeueue;
134 EnqueueInt(req);
135 }
171 } 136 }
172 } 137 }
173 138
174 private void CheckLongPollThreads() 139 public void byContextDequeue(PollServiceHttpRequest req)
175 { 140 {
176 // The only purpose of this thread is to check the EQs for events. 141 Queue<PollServiceHttpRequest> ctxQeueue;
177 // If there are events, that thread will be placed in the "ready-to-serve" queue, m_requests. 142 lock (m_bycontext)
178 // If there are no events, that thread will be back to its "waiting" queue, m_longPollRequests.
179 // All other types of tasks (Inventory handlers, http-in, etc) don't have the long-poll nature,
180 // so if they aren't ready to be served by a worker thread (no events), they are placed
181 // directly back in the "ready-to-serve" queue by the worker thread.
182 while (IsRunning)
183 { 143 {
184 Thread.Sleep(500); 144 if (m_bycontext.TryGetValue(req, out ctxQeueue))
185 Watchdog.UpdateThread();
186
187// List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
188 lock (m_longPollRequests)
189 { 145 {
190 if (m_longPollRequests.Count > 0 && IsRunning) 146 if (ctxQeueue.Count > 0)
147 {
148 PollServiceHttpRequest newreq = ctxQeueue.Dequeue();
149 EnqueueInt(newreq);
150 }
151 else
191 { 152 {
192 List<PollServiceHttpRequest> ready = m_longPollRequests.FindAll(req => 153 m_bycontext.Remove(req);
193 (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ 154 }
194 (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout 155 }
195 ); 156 }
157 }
196 158
197 ready.ForEach(req => 159 public void EnqueueInt(PollServiceHttpRequest req)
198 { 160 {
199 m_requests.Enqueue(req); 161 if (m_running)
200 m_longPollRequests.Remove(req); 162 m_requests.Enqueue(req);
201 }); 163 }
202 164
203 } 165 private void CheckRetries()
166 {
167 while (m_running)
204 168
169 {
170 Thread.Sleep(100); // let the world move .. back to faster rate
171 Watchdog.UpdateThread();
172 lock (m_retryRequests)
173 {
174 while (m_retryRequests.Count > 0 && m_running)
175 m_requests.Enqueue(m_retryRequests.Dequeue());
205 } 176 }
206 } 177 }
207 } 178 }
208 179
209 public void Stop() 180 public void Stop()
210 { 181 {
211 IsRunning = false; 182 m_running = false;
212// m_timeout = -10000; // cause all to expire 183
213 Thread.Sleep(1000); // let the world move 184 Thread.Sleep(100); // let the world move
214 185
215 foreach (Thread t in m_workerThreads) 186 foreach (Thread t in m_workerThreads)
216 Watchdog.AbortThread(t.ManagedThreadId); 187 Watchdog.AbortThread(t.ManagedThreadId);
217 188
218 PollServiceHttpRequest wreq; 189 m_threadPool.Shutdown();
190
191 // any entry in m_bycontext should have a active request on the other queues
192 // so just delete contents to easy GC
193 foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values)
194 qu.Clear();
195 m_bycontext.Clear();
219 196
220 lock (m_longPollRequests) 197 try
198 {
199 foreach (PollServiceHttpRequest req in m_retryRequests)
200 {
201 req.DoHTTPstop(m_server);
202 }
203 }
204 catch
221 { 205 {
222 if (m_longPollRequests.Count > 0 && IsRunning)
223 m_longPollRequests.ForEach(req => m_requests.Enqueue(req));
224 } 206 }
225 207
208 PollServiceHttpRequest wreq;
209
210 m_retryRequests.Clear();
211
226 while (m_requests.Count() > 0) 212 while (m_requests.Count() > 0)
227 { 213 {
228 try 214 try
229 { 215 {
230 wreq = m_requests.Dequeue(0); 216 wreq = m_requests.Dequeue(0);
231 ResponsesProcessed++; 217 wreq.DoHTTPstop(m_server);
232 wreq.DoHTTPGruntWork(
233 m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
234 } 218 }
235 catch 219 catch
236 { 220 {
237 } 221 }
238 } 222 }
239 223
240 m_longPollRequests.Clear();
241 m_requests.Clear(); 224 m_requests.Clear();
242 } 225 }
243 226
@@ -245,87 +228,69 @@ namespace OpenSim.Framework.Servers.HttpServer
245 228
246 private void PoolWorkerJob() 229 private void PoolWorkerJob()
247 { 230 {
248 while (IsRunning) 231 while (m_running)
249 { 232 {
233 PollServiceHttpRequest req = m_requests.Dequeue(4500);
250 Watchdog.UpdateThread(); 234 Watchdog.UpdateThread();
251 WaitPerformResponse(); 235 if (req != null)
252 }
253 }
254
255 public void WaitPerformResponse()
256 {
257 PollServiceHttpRequest req = m_requests.Dequeue(5000);
258// m_log.DebugFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString()));
259
260 if (req != null)
261 {
262 try
263 { 236 {
264 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) 237 try
265 { 238 {
266 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); 239 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
267
268 if (responsedata == null)
269 return;
270
271 // This is the event queue.
272 // Even if we're not running we can still perform responses by explicit request.
273 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll
274 || !PerformResponsesAsync)
275 {
276 try
277 {
278 ResponsesProcessed++;
279 req.DoHTTPGruntWork(m_server, responsedata);
280 }
281 catch (ObjectDisposedException e) // Browser aborted before we could read body, server closed the stream
282 {
283 // Ignore it, no need to reply
284 m_log.Error(e);
285 }
286 }
287 else
288 { 240 {
241 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
242
289 m_threadPool.QueueWorkItem(x => 243 m_threadPool.QueueWorkItem(x =>
290 { 244 {
291 try 245 try
292 { 246 {
293 ResponsesProcessed++;
294 req.DoHTTPGruntWork(m_server, responsedata); 247 req.DoHTTPGruntWork(m_server, responsedata);
295 } 248 }
296 catch (ObjectDisposedException e) // Browser aborted before we could read body, server closed the stream 249 catch (ObjectDisposedException)
297 { 250 {
298 // Ignore it, no need to reply
299 m_log.Error(e);
300 } 251 }
301 catch (Exception e) 252 finally
302 { 253 {
303 m_log.Error(e); 254 byContextDequeue(req);
304 } 255 }
305
306 return null; 256 return null;
307 }, null); 257 }, null);
308 } 258 }
309 }
310 else
311 {
312 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
313 {
314 ResponsesProcessed++;
315 req.DoHTTPGruntWork(
316 m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
317 }
318 else 259 else
319 { 260 {
320 ReQueueEvent(req); 261 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
262 {
263 m_threadPool.QueueWorkItem(x =>
264 {
265 try
266 {
267 req.DoHTTPGruntWork(m_server,
268 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
269 }
270 catch (ObjectDisposedException)
271 {
272 // Ignore it, no need to reply
273 }
274 finally
275 {
276 byContextDequeue(req);
277 }
278 return null;
279 }, null);
280 }
281 else
282 {
283 ReQueueEvent(req);
284 }
321 } 285 }
322 } 286 }
323 } 287 catch (Exception e)
324 catch (Exception e) 288 {
325 { 289 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
326 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); 290 }
327 } 291 }
328 } 292 }
329 } 293 }
294
330 } 295 }
331} \ No newline at end of file 296}
diff --git a/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs
index 5e630dc..9b663ba 100644
--- a/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Framework.Servers.HttpServer")] 8[assembly: AssemblyTitle("OpenSim.Framework.Servers.HttpServer")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.3.*")] 32[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
33 33
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
index bd55657..67fc14e 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Framework.Servers.HttpServer
54 TRequest deserial; 54 TRequest deserial;
55 using (XmlTextReader xmlReader = new XmlTextReader(request)) 55 using (XmlTextReader xmlReader = new XmlTextReader(request))
56 { 56 {
57 xmlReader.ProhibitDtd = true;
58
57 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); 59 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
58 deserial = (TRequest) deserializer.Deserialize(xmlReader); 60 deserial = (TRequest) deserializer.Deserialize(xmlReader);
59 } 61 }
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
index ad69cd2..158befa 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
@@ -210,6 +210,8 @@ namespace OpenSim.Framework.Servers.HttpServer
210 { 210 {
211 try 211 try
212 { 212 {
213 xmlReader.ProhibitDtd = true;
214
213 XmlSerializer deserializer = new XmlSerializer(typeof(RestSessionObject<TRequest>)); 215 XmlSerializer deserializer = new XmlSerializer(typeof(RestSessionObject<TRequest>));
214 deserial = (RestSessionObject<TRequest>)deserializer.Deserialize(xmlReader); 216 deserial = (RestSessionObject<TRequest>)deserializer.Deserialize(xmlReader);
215 } 217 }
@@ -269,6 +271,8 @@ namespace OpenSim.Framework.Servers.HttpServer
269 { 271 {
270 try 272 try
271 { 273 {
274 xmlReader.ProhibitDtd = true;
275
272 XmlSerializer deserializer = new XmlSerializer(typeof(TRequest)); 276 XmlSerializer deserializer = new XmlSerializer(typeof(TRequest));
273 deserial = (TRequest)deserializer.Deserialize(xmlReader); 277 deserial = (TRequest)deserializer.Deserialize(xmlReader);
274 } 278 }
@@ -291,5 +295,5 @@ namespace OpenSim.Framework.Servers.HttpServer
291 serializer.Serialize(xmlWriter, response); 295 serializer.Serialize(xmlWriter, response);
292 } 296 }
293 } 297 }
294 } 298 }
295} \ No newline at end of file 299} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
index 0305dee..dfc2715 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
@@ -50,11 +50,10 @@ namespace OpenSim.Framework.Servers.HttpServer
50 50
51 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 51 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
52 { 52 {
53 string requestBody;
53 Encoding encoding = Encoding.UTF8; 54 Encoding encoding = Encoding.UTF8;
54 StreamReader streamReader = new StreamReader(request, encoding); 55 using(StreamReader streamReader = new StreamReader(request,encoding))
55 56 requestBody = streamReader.ReadToEnd();
56 string requestBody = streamReader.ReadToEnd();
57 streamReader.Close();
58 57
59 string param = GetParam(path); 58 string param = GetParam(path);
60 string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse); 59 string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse);
diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
index c2925e3..c8af90f 100644
--- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Servers.HttpServer
75 public event PongDelegate OnPong; 75 public event PongDelegate OnPong;
76 76
77 /// <summary> 77 /// <summary>
78 /// This is a regular HTTP Request... This may be removed in the future. 78 /// This is a regular HTTP Request... This may be removed in the future.
79 /// </summary> 79 /// </summary>
80// public event RegularHttpRequestDelegate OnRegularHttpRequest; 80// public event RegularHttpRequestDelegate OnRegularHttpRequest;
81 81
@@ -93,9 +93,9 @@ namespace OpenSim.Framework.Servers.HttpServer
93 /// When the websocket is closed, this will be fired. 93 /// When the websocket is closed, this will be fired.
94 /// </summary> 94 /// </summary>
95 public event CloseDelegate OnClose; 95 public event CloseDelegate OnClose;
96 96
97 /// <summary> 97 /// <summary>
98 /// Set this delegate to allow your module to validate the origin of the 98 /// Set this delegate to allow your module to validate the origin of the
99 /// Websocket request. Primary line of defense against cross site scripting 99 /// Websocket request. Primary line of defense against cross site scripting
100 /// </summary> 100 /// </summary>
101 public ValidateHandshake HandshakeValidateMethodOverride = null; 101 public ValidateHandshake HandshakeValidateMethodOverride = null;
@@ -181,7 +181,7 @@ namespace OpenSim.Framework.Servers.HttpServer
181 { 181 {
182 throw new InvalidOperationException("The socket has been shutdown"); 182 throw new InvalidOperationException("The socket has been shutdown");
183 } 183 }
184 } 184 }
185 set 185 set
186 { 186 {
187 if (_networkContext != null && _networkContext.Socket != null) 187 if (_networkContext != null && _networkContext.Socket != null)
@@ -194,8 +194,8 @@ namespace OpenSim.Framework.Servers.HttpServer
194 } 194 }
195 195
196 /// <summary> 196 /// <summary>
197 /// This triggers the websocket to start the upgrade process... 197 /// This triggers the websocket to start the upgrade process...
198 /// This is a Generalized Networking 'common sense' helper method. Some people expect to call Start() instead 198 /// This is a Generalized Networking 'common sense' helper method. Some people expect to call Start() instead
199 /// of the more context appropriate HandshakeAndUpgrade() 199 /// of the more context appropriate HandshakeAndUpgrade()
200 /// </summary> 200 /// </summary>
201 public void Start() 201 public void Start()
@@ -261,7 +261,7 @@ namespace OpenSim.Framework.Servers.HttpServer
261 acceptKey = GenerateAcceptKey(websocketKey); 261 acceptKey = GenerateAcceptKey(websocketKey);
262 string rawaccept = string.Format(HandshakeAcceptText, acceptKey); 262 string rawaccept = string.Format(HandshakeAcceptText, acceptKey);
263 SendUpgradeSuccess(rawaccept); 263 SendUpgradeSuccess(rawaccept);
264 264
265 265
266 } 266 }
267 else 267 else
@@ -282,7 +282,7 @@ namespace OpenSim.Framework.Servers.HttpServer
282 } 282 }
283 283
284 /// <summary> 284 /// <summary>
285 /// Generates a handshake response key string based on the client's 285 /// Generates a handshake response key string based on the client's
286 /// provided key to prove to the client that we're allowing the Websocket 286 /// provided key to prove to the client that we're allowing the Websocket
287 /// upgrade of our own free will and we were not coerced into doing it. 287 /// upgrade of our own free will and we were not coerced into doing it.
288 /// </summary> 288 /// </summary>
@@ -298,7 +298,7 @@ namespace OpenSim.Framework.Servers.HttpServer
298 SHA1 hashobj = SHA1.Create(); 298 SHA1 hashobj = SHA1.Create();
299 string ret = Convert.ToBase64String(hashobj.ComputeHash(Encoding.UTF8.GetBytes(acceptkey))); 299 string ret = Convert.ToBase64String(hashobj.ComputeHash(Encoding.UTF8.GetBytes(acceptkey)));
300 hashobj.Clear(); 300 hashobj.Clear();
301 301
302 return ret; 302 return ret;
303 } 303 }
304 304
@@ -310,11 +310,11 @@ namespace OpenSim.Framework.Servers.HttpServer
310 { 310 {
311 // Create a new websocket state so we can keep track of data in between network reads. 311 // Create a new websocket state so we can keep track of data in between network reads.
312 WebSocketState socketState = new WebSocketState() { ReceivedBytes = new List<byte>(), Header = WebsocketFrameHeader.HeaderDefault(), FrameComplete = true}; 312 WebSocketState socketState = new WebSocketState() { ReceivedBytes = new List<byte>(), Header = WebsocketFrameHeader.HeaderDefault(), FrameComplete = true};
313 313
314 byte[] bhandshakeResponse = Encoding.UTF8.GetBytes(pHandshakeResponse); 314 byte[] bhandshakeResponse = Encoding.UTF8.GetBytes(pHandshakeResponse);
315 315
316 316
317 317
318 318
319 try 319 try
320 { 320 {
@@ -324,7 +324,7 @@ namespace OpenSim.Framework.Servers.HttpServer
324 } 324 }
325 // Begin reading the TCP stream before writing the Upgrade success message to the other side of the stream. 325 // Begin reading the TCP stream before writing the Upgrade success message to the other side of the stream.
326 _networkContext.Stream.BeginRead(_buffer, 0, _bufferLength, OnReceive, socketState); 326 _networkContext.Stream.BeginRead(_buffer, 0, _bufferLength, OnReceive, socketState);
327 327
328 // Write the upgrade handshake success message 328 // Write the upgrade handshake success message
329 _networkContext.Stream.Write(bhandshakeResponse, 0, bhandshakeResponse.Length); 329 _networkContext.Stream.Write(bhandshakeResponse, 0, bhandshakeResponse.Length);
330 _networkContext.Stream.Flush(); 330 _networkContext.Stream.Flush();
@@ -345,7 +345,7 @@ namespace OpenSim.Framework.Servers.HttpServer
345 catch (ObjectDisposedException) 345 catch (ObjectDisposedException)
346 { 346 {
347 Close(string.Empty); 347 Close(string.Empty);
348 } 348 }
349 } 349 }
350 350
351 /// <summary> 351 /// <summary>
@@ -369,7 +369,7 @@ namespace OpenSim.Framework.Servers.HttpServer
369 369
370 /// <summary> 370 /// <summary>
371 /// This is our ugly Async OnReceive event handler. 371 /// This is our ugly Async OnReceive event handler.
372 /// This chunks the input stream based on the length of the provided buffer and processes out 372 /// This chunks the input stream based on the length of the provided buffer and processes out
373 /// as many frames as it can. It then moves the unprocessed data to the beginning of the buffer. 373 /// as many frames as it can. It then moves the unprocessed data to the beginning of the buffer.
374 /// </summary> 374 /// </summary>
375 /// <param name="ar">Our Async State from beginread</param> 375 /// <param name="ar">Our Async State from beginread</param>
@@ -390,7 +390,7 @@ namespace OpenSim.Framework.Servers.HttpServer
390 390
391 if (_bufferPosition > _bufferLength) 391 if (_bufferPosition > _bufferLength)
392 { 392 {
393 // Message too big for chunksize.. not sure how this happened... 393 // Message too big for chunksize.. not sure how this happened...
394 //Close(string.Empty); 394 //Close(string.Empty);
395 } 395 }
396 396
@@ -413,7 +413,7 @@ namespace OpenSim.Framework.Servers.HttpServer
413 if (pheader.PayloadLen > (ulong) _maxPayloadBytes) 413 if (pheader.PayloadLen > (ulong) _maxPayloadBytes)
414 { 414 {
415 Close("Invalid Payload size"); 415 Close("Invalid Payload size");
416 416
417 return; 417 return;
418 } 418 }
419 if (pheader.PayloadLen > 0) 419 if (pheader.PayloadLen > 0)
@@ -487,7 +487,7 @@ namespace OpenSim.Framework.Servers.HttpServer
487 _socketState.ReceivedBytes.Clear(); 487 _socketState.ReceivedBytes.Clear();
488 _socketState.ExpectedBytes = 0; 488 _socketState.ExpectedBytes = 0;
489 // do some processing 489 // do some processing
490 } 490 }
491 } 491 }
492 } 492 }
493 if (offset > 0) 493 if (offset > 0)
@@ -504,7 +504,7 @@ namespace OpenSim.Framework.Servers.HttpServer
504 } 504 }
505 else 505 else
506 { 506 {
507 // We can't read the stream anymore... 507 // We can't read the stream anymore...
508 } 508 }
509 } 509 }
510 catch (IOException) 510 catch (IOException)
@@ -533,7 +533,7 @@ namespace OpenSim.Framework.Servers.HttpServer
533 textMessageFrame.Header.Opcode = WebSocketReader.OpCode.Text; 533 textMessageFrame.Header.Opcode = WebSocketReader.OpCode.Text;
534 textMessageFrame.Header.IsEnd = true; 534 textMessageFrame.Header.IsEnd = true;
535 SendSocket(textMessageFrame.ToBytes()); 535 SendSocket(textMessageFrame.ToBytes());
536 536
537 } 537 }
538 538
539 public void SendData(byte[] data) 539 public void SendData(byte[] data)
@@ -657,7 +657,7 @@ namespace OpenSim.Framework.Servers.HttpServer
657 SendSocket(pongFrame.ToBytes()); 657 SendSocket(pongFrame.ToBytes());
658 break; 658 break;
659 case WebSocketReader.OpCode.Pong: 659 case WebSocketReader.OpCode.Pong:
660 660
661 PongDelegate pongD = OnPong; 661 PongDelegate pongD = OnPong;
662 if (pongD != null) 662 if (pongD != null)
663 { 663 {
@@ -701,7 +701,7 @@ namespace OpenSim.Framework.Servers.HttpServer
701 { 701 {
702 textD(this, new WebsocketTextEventArgs() { Data = Encoding.UTF8.GetString(psocketState.ReceivedBytes.ToArray()) }); 702 textD(this, new WebsocketTextEventArgs() { Data = Encoding.UTF8.GetString(psocketState.ReceivedBytes.ToArray()) });
703 } 703 }
704 704
705 // Send Done Event! 705 // Send Done Event!
706 } 706 }
707 break; 707 break;
@@ -719,7 +719,7 @@ namespace OpenSim.Framework.Servers.HttpServer
719 { 719 {
720 if (psocketState.ContinuationFrame.Header.Opcode == WebSocketReader.OpCode.Text) 720 if (psocketState.ContinuationFrame.Header.Opcode == WebSocketReader.OpCode.Text)
721 { 721 {
722 // Send Done event 722 // Send Done event
723 TextDelegate textD = OnText; 723 TextDelegate textD = OnText;
724 if (textD != null) 724 if (textD != null)
725 { 725 {
@@ -744,9 +744,9 @@ namespace OpenSim.Framework.Servers.HttpServer
744 break; 744 break;
745 case WebSocketReader.OpCode.Close: 745 case WebSocketReader.OpCode.Close:
746 Close(string.Empty); 746 Close(string.Empty);
747 747
748 break; 748 break;
749 749
750 } 750 }
751 psocketState.Header.SetDefault(); 751 psocketState.Header.SetDefault();
752 psocketState.ReceivedBytes.Clear(); 752 psocketState.ReceivedBytes.Clear();
@@ -837,12 +837,12 @@ namespace OpenSim.Framework.Servers.HttpServer
837 } 837 }
838 838
839 /// <summary> 839 /// <summary>
840 /// Attempts to read a header off the provided buffer. Returns true, exports a WebSocketFrameheader, 840 /// Attempts to read a header off the provided buffer. Returns true, exports a WebSocketFrameheader,
841 /// and an int to move the buffer forward when it reads a header. False when it can't read a header 841 /// and an int to move the buffer forward when it reads a header. False when it can't read a header
842 /// </summary> 842 /// </summary>
843 /// <param name="pBuffer">Bytes read from the stream</param> 843 /// <param name="pBuffer">Bytes read from the stream</param>
844 /// <param name="pOffset">Starting place in the stream to begin trying to read from</param> 844 /// <param name="pOffset">Starting place in the stream to begin trying to read from</param>
845 /// <param name="length">Lenth in the stream to try and read from. Provided for cases where the 845 /// <param name="length">Lenth in the stream to try and read from. Provided for cases where the
846 /// buffer's length is larger then the data in it</param> 846 /// buffer's length is larger then the data in it</param>
847 /// <param name="oHeader">Outputs the read WebSocket frame header</param> 847 /// <param name="oHeader">Outputs the read WebSocket frame header</param>
848 /// <param name="moveBuffer">Informs the calling stream to move the buffer forward</param> 848 /// <param name="moveBuffer">Informs the calling stream to move the buffer forward</param>
@@ -897,7 +897,7 @@ namespace OpenSim.Framework.Servers.HttpServer
897 oHeader.PayloadLen = BitConverter.ToUInt16(pBuffer, pOffset + index); 897 oHeader.PayloadLen = BitConverter.ToUInt16(pBuffer, pOffset + index);
898 index += 2; 898 index += 2;
899 break; 899 break;
900 case 127: // we got more this is a bigger frame 900 case 127: // we got more this is a bigger frame
901 // 8 bytes - uint64 - most significant bit 0 network byte order 901 // 8 bytes - uint64 - most significant bit 0 network byte order
902 minumheadersize += 8; 902 minumheadersize += 8;
903 if (length < minumheadersize) 903 if (length < minumheadersize)
@@ -909,7 +909,7 @@ namespace OpenSim.Framework.Servers.HttpServer
909 oHeader.PayloadLen = BitConverter.ToUInt64(pBuffer, pOffset + index); 909 oHeader.PayloadLen = BitConverter.ToUInt64(pBuffer, pOffset + index);
910 index += 8; 910 index += 8;
911 break; 911 break;
912 912
913 } 913 }
914 //oHeader.PayloadLeft = oHeader.PayloadLen; // Start the count in case it's chunked over the network. This is different then frame fragmentation 914 //oHeader.PayloadLeft = oHeader.PayloadLen; // Start the count in case it's chunked over the network. This is different then frame fragmentation
915 if (oHeader.IsMasked) 915 if (oHeader.IsMasked)
@@ -937,9 +937,9 @@ namespace OpenSim.Framework.Servers.HttpServer
937 /* 937 /*
938 * RFC6455 938 * RFC6455
939nib 0 1 2 3 4 5 6 7 939nib 0 1 2 3 4 5 6 7
940byt 0 1 2 3 940byt 0 1 2 3
941dec 0 1 2 3 941dec 0 1 2 3
942 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 942 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
943 +-+-+-+-+-------+-+-------------+-------------------------------+ 943 +-+-+-+-+-------+-+-------------+-------------------------------+
944 |F|R|R|R| opcode|M| Payload len | Extended payload length | 944 |F|R|R|R| opcode|M| Payload len | Extended payload length |
945 |I|S|S|S| (4) |A| (7) | (16/64) + 945 |I|S|S|S| (4) |A| (7) | (16/64) +
@@ -963,7 +963,7 @@ dec 0 1 2 3
963 public static readonly WebSocketFrame DefaultFrame = new WebSocketFrame(){Header = new WebsocketFrameHeader(),WebSocketPayload = new byte[0]}; 963 public static readonly WebSocketFrame DefaultFrame = new WebSocketFrame(){Header = new WebsocketFrameHeader(),WebSocketPayload = new byte[0]};
964 public WebsocketFrameHeader Header; 964 public WebsocketFrameHeader Header;
965 public byte[] WebSocketPayload; 965 public byte[] WebSocketPayload;
966 966
967 public byte[] ToBytes() 967 public byte[] ToBytes()
968 { 968 {
969 Header.PayloadLen = (ulong)WebSocketPayload.Length; 969 Header.PayloadLen = (ulong)WebSocketPayload.Length;
@@ -991,7 +991,7 @@ dec 0 1 2 3
991 public int Mask; 991 public int Mask;
992 /* 992 /*
993byt 0 1 2 3 993byt 0 1 2 3
994 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 994 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
995 +---------------+---------------+---------------+---------------+ 995 +---------------+---------------+---------------+---------------+
996 | Octal 1 | Octal 2 | Octal 3 | Octal 4 | 996 | Octal 1 | Octal 2 | Octal 3 | Octal 4 |
997 +---------------+---------------+---------------+---------------+ 997 +---------------+---------------+---------------+---------------+
@@ -1002,11 +1002,11 @@ byt 0 1 2 3
1002 1002
1003 public UInt64 PayloadLen; 1003 public UInt64 PayloadLen;
1004 //public UInt64 PayloadLeft; 1004 //public UInt64 PayloadLeft;
1005 // Payload is X + Y 1005 // Payload is X + Y
1006 //public UInt64 ExtensionDataLength; 1006 //public UInt64 ExtensionDataLength;
1007 //public UInt64 ApplicationDataLength; 1007 //public UInt64 ApplicationDataLength;
1008 public static readonly WebsocketFrameHeader ZeroHeader = WebsocketFrameHeader.HeaderDefault(); 1008 public static readonly WebsocketFrameHeader ZeroHeader = WebsocketFrameHeader.HeaderDefault();
1009 1009
1010 public void SetDefault() 1010 public void SetDefault()
1011 { 1011 {
1012 1012
@@ -1025,16 +1025,16 @@ byt 0 1 2 3
1025 /// <summary> 1025 /// <summary>
1026 /// Returns a byte array representing the Frame header 1026 /// Returns a byte array representing the Frame header
1027 /// </summary> 1027 /// </summary>
1028 /// <param name="payload">This is the frame data payload. The header describes the size of the payload. 1028 /// <param name="payload">This is the frame data payload. The header describes the size of the payload.
1029 /// If payload is null, a Zero sized payload is assumed</param> 1029 /// If payload is null, a Zero sized payload is assumed</param>
1030 /// <returns>Returns a byte array representing the frame header</returns> 1030 /// <returns>Returns a byte array representing the frame header</returns>
1031 public byte[] ToBytes(byte[] payload) 1031 public byte[] ToBytes(byte[] payload)
1032 { 1032 {
1033 List<byte> result = new List<byte>(); 1033 List<byte> result = new List<byte>();
1034 1034
1035 // Squeeze in our opcode and our ending bit. 1035 // Squeeze in our opcode and our ending bit.
1036 result.Add((byte)((byte)Opcode | (IsEnd?0x80:0x00) )); 1036 result.Add((byte)((byte)Opcode | (IsEnd?0x80:0x00) ));
1037 1037
1038 // Again with the three different byte interpretations of size.. 1038 // Again with the three different byte interpretations of size..
1039 1039
1040 //bytesize 1040 //bytesize
@@ -1056,7 +1056,7 @@ byt 0 1 2 3
1056 Array.Reverse(payloadLengthByte); 1056 Array.Reverse(payloadLengthByte);
1057 result.AddRange(payloadLengthByte); 1057 result.AddRange(payloadLengthByte);
1058 } 1058 }
1059 1059
1060 // Only add a payload if it's not null 1060 // Only add a payload if it's not null
1061 if (payload != null) 1061 if (payload != null)
1062 { 1062 {
@@ -1155,5 +1155,5 @@ byt 0 1 2 3
1155 1155
1156 } 1156 }
1157 1157
1158 1158
1159} 1159}
diff --git a/OpenSim/Framework/Servers/HttpServer/XmlRpcBasicDOSProtector.cs b/OpenSim/Framework/Servers/HttpServer/XmlRpcBasicDOSProtector.cs
index f212208..6b2c0ab 100644
--- a/OpenSim/Framework/Servers/HttpServer/XmlRpcBasicDOSProtector.cs
+++ b/OpenSim/Framework/Servers/HttpServer/XmlRpcBasicDOSProtector.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Servers.HttpServer
36 { 36 {
37 private readonly XmlRpcMethod _normalMethod; 37 private readonly XmlRpcMethod _normalMethod;
38 private readonly XmlRpcMethod _throttledMethod; 38 private readonly XmlRpcMethod _throttledMethod;
39 39
40 private readonly BasicDosProtectorOptions _options; 40 private readonly BasicDosProtectorOptions _options;
41 private readonly BasicDOSProtector _dosProtector; 41 private readonly BasicDOSProtector _dosProtector;
42 42
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Servers.HttpServer
44 { 44 {
45 _normalMethod = normalMethod; 45 _normalMethod = normalMethod;
46 _throttledMethod = throttledMethod; 46 _throttledMethod = throttledMethod;
47 47
48 _options = options; 48 _options = options;
49 _dosProtector = new BasicDOSProtector(_options); 49 _dosProtector = new BasicDOSProtector(_options);
50 50
@@ -87,5 +87,5 @@ namespace OpenSim.Framework.Servers.HttpServer
87 87
88 } 88 }
89 89
90 90
91} 91}
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index 57931d4..9b1d906 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -223,11 +223,11 @@ namespace OpenSim.Framework.Servers
223 { 223 {
224 handlers.AppendFormat( 224 handlers.AppendFormat(
225 "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); 225 "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port);
226 226
227 handlers.AppendFormat("* XMLRPC:\n"); 227 handlers.AppendFormat("* XMLRPC:\n");
228 foreach (String s in httpServer.GetXmlRpcHandlerKeys()) 228 foreach (String s in httpServer.GetXmlRpcHandlerKeys())
229 handlers.AppendFormat("\t{0}\n", s); 229 handlers.AppendFormat("\t{0}\n", s);
230 230
231 handlers.AppendFormat("* HTTP:\n"); 231 handlers.AppendFormat("* HTTP:\n");
232 foreach (String s in httpServer.GetHTTPHandlerKeys()) 232 foreach (String s in httpServer.GetHTTPHandlerKeys())
233 handlers.AppendFormat("\t{0}\n", s); 233 handlers.AppendFormat("\t{0}\n", s);
@@ -235,19 +235,19 @@ namespace OpenSim.Framework.Servers
235 handlers.AppendFormat("* HTTP (poll):\n"); 235 handlers.AppendFormat("* HTTP (poll):\n");
236 foreach (String s in httpServer.GetPollServiceHandlerKeys()) 236 foreach (String s in httpServer.GetPollServiceHandlerKeys())
237 handlers.AppendFormat("\t{0}\n", s); 237 handlers.AppendFormat("\t{0}\n", s);
238 238
239 handlers.AppendFormat("* JSONRPC:\n"); 239 handlers.AppendFormat("* JSONRPC:\n");
240 foreach (String s in httpServer.GetJsonRpcHandlerKeys()) 240 foreach (String s in httpServer.GetJsonRpcHandlerKeys())
241 handlers.AppendFormat("\t{0}\n", s); 241 handlers.AppendFormat("\t{0}\n", s);
242 242
243// handlers.AppendFormat("* Agent:\n"); 243// handlers.AppendFormat("* Agent:\n");
244// foreach (String s in httpServer.GetAgentHandlerKeys()) 244// foreach (String s in httpServer.GetAgentHandlerKeys())
245// handlers.AppendFormat("\t{0}\n", s); 245// handlers.AppendFormat("\t{0}\n", s);
246 246
247 handlers.AppendFormat("* LLSD:\n"); 247 handlers.AppendFormat("* LLSD:\n");
248 foreach (String s in httpServer.GetLLSDHandlerKeys()) 248 foreach (String s in httpServer.GetLLSDHandlerKeys())
249 handlers.AppendFormat("\t{0}\n", s); 249 handlers.AppendFormat("\t{0}\n", s);
250 250
251 handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); 251 handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count);
252 foreach (String s in httpServer.GetStreamHandlerKeys()) 252 foreach (String s in httpServer.GetStreamHandlerKeys())
253 handlers.AppendFormat("\t{0}\n", s); 253 handlers.AppendFormat("\t{0}\n", s);
@@ -334,7 +334,7 @@ namespace OpenSim.Framework.Servers
334 { 334 {
335 if (port == 0) 335 if (port == 0)
336 return Instance; 336 return Instance;
337 337
338 if (instance != null && port == Instance.Port) 338 if (instance != null && port == Instance.Port)
339 return Instance; 339 return Instance;
340 340
@@ -353,5 +353,17 @@ namespace OpenSim.Framework.Servers
353 return m_Servers[port]; 353 return m_Servers[port];
354 } 354 }
355 } 355 }
356
357 public static void Stop()
358 {
359 lock (m_Servers)
360 {
361 foreach (BaseHttpServer httpServer in m_Servers.Values)
362 {
363 httpServer.Stop();
364 }
365 }
366 }
367
356 } 368 }
357} \ No newline at end of file 369} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs
index 792c62e..4469e7c 100644
--- a/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs
+++ b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@
2using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4 4
5// General Information about an assembly is controlled through the following 5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information 6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly. 7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Framework.Servers")] 8[assembly: AssemblyTitle("OpenSim.Framework.Servers")]
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
14[assembly: AssemblyTrademark("")] 14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")] 15[assembly: AssemblyCulture("")]
16 16
17// Setting ComVisible to false makes the types in this assembly not visible 17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from 18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type. 19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)] 20[assembly: ComVisible(false)]
21 21
@@ -25,7 +25,7 @@ using System.Runtime.InteropServices;
25// Version information for an assembly consists of the following four values: 25// Version information for an assembly consists of the following four values:
26// 26//
27// Major Version 27// Major Version
28// Minor Version 28// Minor Version
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 07a09e6..3c2dce8 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -56,7 +56,8 @@ namespace OpenSim.Framework.Servers
56 protected ICommandConsole m_console; 56 protected ICommandConsole m_console;
57 57
58 protected OpenSimAppender m_consoleAppender; 58 protected OpenSimAppender m_consoleAppender;
59 protected FileAppender m_logFileAppender; 59 protected FileAppender m_logFileAppender;
60 protected FileAppender m_statsLogFileAppender;
60 61
61 protected DateTime m_startuptime; 62 protected DateTime m_startuptime;
62 protected string m_startupDirectory = Environment.CurrentDirectory; 63 protected string m_startupDirectory = Environment.CurrentDirectory;
@@ -81,7 +82,7 @@ namespace OpenSim.Framework.Servers
81 { 82 {
82 if (File.Exists(path)) 83 if (File.Exists(path))
83 m_log.ErrorFormat( 84 m_log.ErrorFormat(
84 "[SERVER BASE]: Previous pid file {0} still exists on startup. Possibly previously unclean shutdown.", 85 "[SERVER BASE]: Previous pid file {0} still exists on startup. Possibly previously unclean shutdown.",
85 path); 86 path);
86 87
87 try 88 try
@@ -103,7 +104,7 @@ namespace OpenSim.Framework.Servers
103 m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e); 104 m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
104 } 105 }
105 } 106 }
106 107
107 protected void RemovePIDFile() 108 protected void RemovePIDFile()
108 { 109 {
109 if (m_pidFile != String.Empty) 110 if (m_pidFile != String.Empty)
@@ -156,6 +157,10 @@ namespace OpenSim.Framework.Servers
156 { 157 {
157 m_logFileAppender = (FileAppender)appender; 158 m_logFileAppender = (FileAppender)appender;
158 } 159 }
160 else if (appender.Name == "StatsLogFileAppender")
161 {
162 m_statsLogFileAppender = (FileAppender)appender;
163 }
159 } 164 }
160 165
161 if (null == m_consoleAppender) 166 if (null == m_consoleAppender)
@@ -166,11 +171,11 @@ namespace OpenSim.Framework.Servers
166 { 171 {
167 // FIXME: This should be done through an interface rather than casting. 172 // FIXME: This should be done through an interface rather than casting.
168 m_consoleAppender.Console = (ConsoleBase)m_console; 173 m_consoleAppender.Console = (ConsoleBase)m_console;
169 174
170 // If there is no threshold set then the threshold is effectively everything. 175 // If there is no threshold set then the threshold is effectively everything.
171 if (null == m_consoleAppender.Threshold) 176 if (null == m_consoleAppender.Threshold)
172 m_consoleAppender.Threshold = Level.All; 177 m_consoleAppender.Threshold = Level.All;
173 178
174 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); 179 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
175 } 180 }
176 181
@@ -185,6 +190,18 @@ namespace OpenSim.Framework.Servers
185 190
186 m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); 191 m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
187 } 192 }
193
194 if (m_statsLogFileAppender != null && startupConfig != null)
195 {
196 string cfgStatsFileName = startupConfig.GetString("StatsLogFile", null);
197 if (cfgStatsFileName != null)
198 {
199 m_statsLogFileAppender.File = cfgStatsFileName;
200 m_statsLogFileAppender.ActivateOptions();
201 }
202
203 m_log.InfoFormat("[SERVER BASE]: Stats Logging started to file {0}", m_statsLogFileAppender.File);
204 }
188 } 205 }
189 206
190 /// <summary> 207 /// <summary>
@@ -205,11 +222,11 @@ namespace OpenSim.Framework.Servers
205 "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); 222 "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
206 223
207 m_console.Commands.AddCommand( 224 m_console.Commands.AddCommand(
208 "General", false, "get log level", "get log level", "Get the current console logging level", 225 "General", false, "get log level", "get log level", "Get the current console logging level",
209 (mod, cmd) => ShowLogLevel()); 226 (mod, cmd) => ShowLogLevel());
210 227
211 m_console.Commands.AddCommand( 228 m_console.Commands.AddCommand(
212 "General", false, "set log level", "set log level <level>", 229 "General", false, "set log level", "set log level <level>",
213 "Set the console logging level for this session.", HandleSetLogLevel); 230 "Set the console logging level for this session.", HandleSetLogLevel);
214 231
215 m_console.Commands.AddCommand( 232 m_console.Commands.AddCommand(
@@ -222,14 +239,14 @@ namespace OpenSim.Framework.Servers
222 "config get [<section>] [<key>]", 239 "config get [<section>] [<key>]",
223 "Synonym for config show", 240 "Synonym for config show",
224 HandleConfig); 241 HandleConfig);
225 242
226 m_console.Commands.AddCommand( 243 m_console.Commands.AddCommand(
227 "General", false, "config show", 244 "General", false, "config show",
228 "config show [<section>] [<key>]", 245 "config show [<section>] [<key>]",
229 "Show config information", 246 "Show config information",
230 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine 247 "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
231 + "If a section is given but not a field, then all fields in that section are printed.", 248 + "If a section is given but not a field, then all fields in that section are printed.",
232 HandleConfig); 249 HandleConfig);
233 250
234 m_console.Commands.AddCommand( 251 m_console.Commands.AddCommand(
235 "General", false, "config save", 252 "General", false, "config save",
@@ -258,18 +275,6 @@ namespace OpenSim.Framework.Servers
258 (string module, string[] args) => Notice(GetThreadsReport())); 275 (string module, string[] args) => Notice(GetThreadsReport()));
259 276
260 m_console.Commands.AddCommand ( 277 m_console.Commands.AddCommand (
261 "Debug", false, "debug comms set",
262 "debug comms set serialosdreq true|false",
263 "Set comms parameters. For debug purposes.",
264 HandleDebugCommsSet);
265
266 m_console.Commands.AddCommand (
267 "Debug", false, "debug comms status",
268 "debug comms status",
269 "Show current debug comms parameters.",
270 HandleDebugCommsStatus);
271
272 m_console.Commands.AddCommand (
273 "Debug", false, "debug threadpool set", 278 "Debug", false, "debug threadpool set",
274 "debug threadpool set worker|iocp min|max <n>", 279 "debug threadpool set worker|iocp min|max <n>",
275 "Set threadpool parameters. For debug purposes.", 280 "Set threadpool parameters. For debug purposes.",
@@ -280,7 +285,7 @@ namespace OpenSim.Framework.Servers
280 "debug threadpool status", 285 "debug threadpool status",
281 "Show current debug threadpool parameters.", 286 "Show current debug threadpool parameters.",
282 HandleDebugThreadpoolStatus); 287 HandleDebugThreadpoolStatus);
283 288
284 m_console.Commands.AddCommand( 289 m_console.Commands.AddCommand(
285 "Debug", false, "debug threadpool level", 290 "Debug", false, "debug threadpool level",
286 "debug threadpool level 0.." + Util.MAX_THREADPOOL_LEVEL, 291 "debug threadpool level 0.." + Util.MAX_THREADPOOL_LEVEL,
@@ -326,47 +331,13 @@ namespace OpenSim.Framework.Servers
326 331
327 public void RegisterCommonComponents(IConfigSource configSource) 332 public void RegisterCommonComponents(IConfigSource configSource)
328 { 333 {
329 IConfig networkConfig = configSource.Configs["Network"]; 334// IConfig networkConfig = configSource.Configs["Network"];
330 335
331 if (networkConfig != null)
332 {
333 WebUtil.SerializeOSDRequestsPerEndpoint = networkConfig.GetBoolean("SerializeOSDRequests", false);
334 }
335
336 m_serverStatsCollector = new ServerStatsCollector(); 336 m_serverStatsCollector = new ServerStatsCollector();
337 m_serverStatsCollector.Initialise(configSource); 337 m_serverStatsCollector.Initialise(configSource);
338 m_serverStatsCollector.Start(); 338 m_serverStatsCollector.Start();
339 } 339 }
340 340
341 private void HandleDebugCommsStatus(string module, string[] args)
342 {
343 Notice("serialosdreq is {0}", WebUtil.SerializeOSDRequestsPerEndpoint);
344 }
345
346 private void HandleDebugCommsSet(string module, string[] args)
347 {
348 if (args.Length != 5)
349 {
350 Notice("Usage: debug comms set serialosdreq true|false");
351 return;
352 }
353
354 if (args[3] != "serialosdreq")
355 {
356 Notice("Usage: debug comms set serialosdreq true|false");
357 return;
358 }
359
360 bool setSerializeOsdRequests;
361
362 if (!ConsoleUtil.TryParseConsoleBool(m_console, args[4], out setSerializeOsdRequests))
363 return;
364
365 WebUtil.SerializeOSDRequestsPerEndpoint = setSerializeOsdRequests;
366
367 Notice("serialosdreq is now {0}", setSerializeOsdRequests);
368 }
369
370 private void HandleShowThreadpoolCallsActive(string module, string[] args) 341 private void HandleShowThreadpoolCallsActive(string module, string[] args)
371 { 342 {
372 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsInProgress().ToList(); 343 List<KeyValuePair<string, int>> calls = Util.GetFireAndForgetCallsInProgress().ToList();
@@ -432,7 +403,7 @@ namespace OpenSim.Framework.Servers
432 403
433 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); 404 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
434 Notice("Available worker threads: {0}", workerThreads); 405 Notice("Available worker threads: {0}", workerThreads);
435 Notice("Available IOCP threads: {0}", iocpThreads); 406 Notice("Available IOCP threads: {0}", iocpThreads);
436 } 407 }
437 408
438 private void HandleDebugThreadpoolSet(string module, string[] args) 409 private void HandleDebugThreadpoolSet(string module, string[] args)
@@ -488,7 +459,7 @@ namespace OpenSim.Framework.Servers
488 fail = true; 459 fail = true;
489 } 460 }
490 } 461 }
491 462
492 if (fail) 463 if (fail)
493 { 464 {
494 Notice("ERROR: Could not set {0} {1} threads to {2}", poolType, bound, newThreads); 465 Notice("ERROR: Could not set {0} {1} threads to {2}", poolType, bound, newThreads);
@@ -582,7 +553,7 @@ namespace OpenSim.Framework.Servers
582 if (cmdparams.Length > 0) 553 if (cmdparams.Length > 0)
583 { 554 {
584 string firstParam = cmdparams[0].ToLower(); 555 string firstParam = cmdparams[0].ToLower();
585 556
586 switch (firstParam) 557 switch (firstParam)
587 { 558 {
588 case "set": 559 case "set":
@@ -633,12 +604,12 @@ namespace OpenSim.Framework.Servers
633 { 604 {
634 Notice("[{0}]", config.Name); 605 Notice("[{0}]", config.Name);
635 foreach (string key in config.GetKeys()) 606 foreach (string key in config.GetKeys())
636 Notice(" {0} = {1}", key, config.GetString(key)); 607 Notice(" {0} = {1}", key, config.GetString(key));
637 } 608 }
638 else 609 else
639 { 610 {
640 Notice( 611 Notice(
641 "config get {0} {1} : {2}", 612 "config get {0} {1} : {2}",
642 cmdparams[1], cmdparams[2], config.GetString(cmdparams[2])); 613 cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
643 } 614 }
644 } 615 }
@@ -692,10 +663,10 @@ namespace OpenSim.Framework.Servers
692 } 663 }
693 664
694 string rawLevel = cmd[3]; 665 string rawLevel = cmd[3];
695 666
696 ILoggerRepository repository = LogManager.GetRepository(); 667 ILoggerRepository repository = LogManager.GetRepository();
697 Level consoleLevel = repository.LevelMap[rawLevel]; 668 Level consoleLevel = repository.LevelMap[rawLevel];
698 669
699 if (consoleLevel != null) 670 if (consoleLevel != null)
700 m_consoleAppender.Threshold = consoleLevel; 671 m_consoleAppender.Threshold = consoleLevel;
701 else 672 else
@@ -770,9 +741,9 @@ namespace OpenSim.Framework.Servers
770 protected void ShowInfo() 741 protected void ShowInfo()
771 { 742 {
772 Notice(GetVersionText()); 743 Notice(GetVersionText());
773 Notice("Startup directory: " + m_startupDirectory); 744 Notice("Startup directory: " + m_startupDirectory);
774 if (null != m_consoleAppender) 745 if (null != m_consoleAppender)
775 Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold)); 746 Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold));
776 } 747 }
777 748
778 /// <summary> 749 /// <summary>
@@ -842,7 +813,7 @@ namespace OpenSim.Framework.Servers
842 { 813 {
843 StreamReader RevisionFile = File.OpenText(svnRevisionFileName); 814 StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
844 buildVersion = RevisionFile.ReadLine(); 815 buildVersion = RevisionFile.ReadLine();
845 buildVersion.Trim(); 816 buildVersion = buildVersion.Trim();
846 RevisionFile.Close(); 817 RevisionFile.Close();
847 } 818 }
848 819
@@ -871,9 +842,9 @@ namespace OpenSim.Framework.Servers
871 } 842 }
872 } 843 }
873 844
874 protected string GetVersionText() 845 public string GetVersionText()
875 { 846 {
876 return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})", 847 return String.Format("Version: {0} (SIMULATION/{1} - SIMULATION/{2})",
877 m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax); 848 m_version, VersionInfo.SimulationServiceVersionSupportedMin, VersionInfo.SimulationServiceVersionSupportedMax);
878 } 849 }
879 850
@@ -898,7 +869,7 @@ namespace OpenSim.Framework.Servers
898 foreach (Watchdog.ThreadWatchdogInfo twi in threads) 869 foreach (Watchdog.ThreadWatchdogInfo twi in threads)
899 { 870 {
900 Thread t = twi.Thread; 871 Thread t = twi.Thread;
901 872
902 sb.AppendFormat( 873 sb.AppendFormat(
903 reportFormat, 874 reportFormat,
904 t.ManagedThreadId, 875 t.ManagedThreadId,
@@ -911,16 +882,12 @@ namespace OpenSim.Framework.Servers
911 sb.Append("\n"); 882 sb.Append("\n");
912 } 883 }
913 884
914 sb.Append("\n"); 885 sb.Append(GetThreadPoolReport());
915 886
916 // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting 887 sb.Append("\n");
917 // zero active threads.
918 int totalThreads = Process.GetCurrentProcess().Threads.Count; 888 int totalThreads = Process.GetCurrentProcess().Threads.Count;
919 if (totalThreads > 0) 889 if (totalThreads > 0)
920 sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); 890 sb.AppendFormat("Total process threads active: {0}\n\n", totalThreads);
921
922 sb.Append("Main threadpool (excluding script engine pools)\n");
923 sb.Append(GetThreadPoolReport());
924 891
925 return sb.ToString(); 892 return sb.ToString();
926 } 893 }
@@ -931,15 +898,46 @@ namespace OpenSim.Framework.Servers
931 /// <returns></returns> 898 /// <returns></returns>
932 public static string GetThreadPoolReport() 899 public static string GetThreadPoolReport()
933 { 900 {
901
902 StringBuilder sb = new StringBuilder();
903
904 // framework pool is alwasy active
905 int maxWorkers;
906 int minWorkers;
907 int curWorkers;
908 int maxComp;
909 int minComp;
910 int curComp;
911
912 try
913 {
914 ThreadPool.GetMaxThreads(out maxWorkers, out maxComp);
915 ThreadPool.GetMinThreads(out minWorkers, out minComp);
916 ThreadPool.GetAvailableThreads(out curWorkers, out curComp);
917 curWorkers = maxWorkers - curWorkers;
918 curComp = maxComp - curComp;
919
920 sb.Append("\nFramework main threadpool \n");
921 sb.AppendFormat("workers: {0} ({1} / {2})\n", curWorkers, maxWorkers, minWorkers);
922 sb.AppendFormat("Completion: {0} ({1} / {2})\n", curComp, maxComp, minComp);
923 }
924 catch { }
925
926 if (
927 Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
928 || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
929 {
930 sb.AppendFormat("\nThread pool used: Framework main threadpool\n");
931 return sb.ToString();
932 }
933
934 string threadPoolUsed = null; 934 string threadPoolUsed = null;
935 int maxThreads = 0; 935 int maxThreads = 0;
936 int minThreads = 0; 936 int minThreads = 0;
937 int allocatedThreads = 0; 937 int allocatedThreads = 0;
938 int inUseThreads = 0; 938 int inUseThreads = 0;
939 int waitingCallbacks = 0; 939 int waitingCallbacks = 0;
940 int completionPortThreads = 0;
941 940
942 StringBuilder sb = new StringBuilder();
943 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) 941 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
944 { 942 {
945 STPInfo stpi = Util.GetSmartThreadPoolInfo(); 943 STPInfo stpi = Util.GetSmartThreadPoolInfo();
@@ -955,22 +953,10 @@ namespace OpenSim.Framework.Servers
955 waitingCallbacks = stpi.WaitingCallbacks; 953 waitingCallbacks = stpi.WaitingCallbacks;
956 } 954 }
957 } 955 }
958 else if ( 956
959 Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem
960 || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
961 {
962 threadPoolUsed = "BuiltInThreadPool";
963 ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
964 ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
965 int availableThreads;
966 ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
967 inUseThreads = maxThreads - availableThreads;
968 allocatedThreads = -1;
969 waitingCallbacks = -1;
970 }
971
972 if (threadPoolUsed != null) 957 if (threadPoolUsed != null)
973 { 958 {
959 sb.Append("\nThreadpool (excluding script engine pools)\n");
974 sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); 960 sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
975 sb.AppendFormat("Max threads : {0}\n", maxThreads); 961 sb.AppendFormat("Max threads : {0}\n", maxThreads);
976 sb.AppendFormat("Min threads : {0}\n", minThreads); 962 sb.AppendFormat("Min threads : {0}\n", minThreads);
@@ -1005,7 +991,7 @@ namespace OpenSim.Framework.Servers
1005 MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); 991 MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId);
1006 else 992 else
1007 MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); 993 MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
1008 } 994 }
1009 995
1010 /// <summary> 996 /// <summary>
1011 /// Console output is only possible if a console has been established. 997 /// Console output is only possible if a console has been established.
@@ -1020,13 +1006,13 @@ namespace OpenSim.Framework.Servers
1020 m_console.Output(msg); 1006 m_console.Output(msg);
1021 } 1007 }
1022 } 1008 }
1023 1009
1024 /// <summary> 1010 /// <summary>
1025 /// Console output is only possible if a console has been established. 1011 /// Console output is only possible if a console has been established.
1026 /// That is something that cannot be determined within this class. So 1012 /// That is something that cannot be determined within this class. So
1027 /// all attempts to use the console MUST be verified. 1013 /// all attempts to use the console MUST be verified.
1028 /// </summary> 1014 /// </summary>
1029 /// <param name="format"></param> 1015 /// <param name="format"></param>
1030 /// <param name="components"></param> 1016 /// <param name="components"></param>
1031 protected void Notice(string format, params object[] components) 1017 protected void Notice(string format, params object[] components)
1032 { 1018 {
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
index 5c0e0df..e5f7043 100644
--- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
+++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
@@ -39,9 +39,331 @@ using OpenSim.Tests.Common;
39 39
40namespace OpenSim.Framework.Servers.Tests 40namespace OpenSim.Framework.Servers.Tests
41{ 41{
42/*
43
42 [TestFixture] 44 [TestFixture]
43 public class OSHttpTests : OpenSimTestCase 45 public class OSHttpTests : OpenSimTestCase
44 { 46 {
47 // we need an IHttpClientContext for our tests
48 public class TestHttpClientContext: IHttpClientContext
49 {
50 private bool _secured;
51 public bool IsSecured
52 {
53 get { return _secured; }
54 }
55 public bool Secured
56 {
57 get { return _secured; }
58 }
59
60 public TestHttpClientContext(bool secured)
61 {
62 _secured = secured;
63 }
64
65 public void Disconnect(SocketError error) {}
66 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body) {}
67 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason) {}
68 public void Respond(string body) {}
69 public void Send(byte[] buffer) {}
70 public void Send(byte[] buffer, int offset, int size) {}
71 public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {}
72 public void Close() { }
73 public bool EndWhenDone { get { return false;} set { return;}}
74
75 public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
76 {
77 return new HTTPNetworkContext();
78 }
79
80 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
81 /// <summary>
82 /// A request have been received in the context.
83 /// </summary>
84 public event EventHandler<RequestEventArgs> RequestReceived = delegate { };
85
86 public bool CanSend { get { return true; } }
87 public string RemoteEndPoint { get { return ""; } }
88 public string RemoteEndPointAddress { get { return ""; } }
89 public string RemoteEndPointPort { get { return ""; } }
90 }
91
92 public class TestHttpRequest: IHttpRequest
93 {
94 private string _uriPath;
95 public bool BodyIsComplete
96 {
97 get { return true; }
98 }
99 public string[] AcceptTypes
100 {
101 get {return _acceptTypes; }
102 }
103 private string[] _acceptTypes;
104 public Stream Body
105 {
106 get { return _body; }
107 set { _body = value;}
108 }
109 private Stream _body;
110 public ConnectionType Connection
111 {
112 get { return _connection; }
113 set { _connection = value; }
114 }
115 private ConnectionType _connection;
116 public int ContentLength
117 {
118 get { return _contentLength; }
119 set { _contentLength = value; }
120 }
121 private int _contentLength;
122 public NameValueCollection Headers
123 {
124 get { return _headers; }
125 }
126 private NameValueCollection _headers = new NameValueCollection();
127 public string HttpVersion
128 {
129 get { return _httpVersion; }
130 set { _httpVersion = value; }
131 }
132 private string _httpVersion = null;
133 public string Method
134 {
135 get { return _method; }
136 set { _method = value; }
137 }
138 private string _method = null;
139 public HttpInput QueryString
140 {
141 get { return _queryString; }
142 }
143 private HttpInput _queryString = null;
144 public Uri Uri
145 {
146 get { return _uri; }
147 set { _uri = value; }
148 }
149 private Uri _uri = null;
150 public string[] UriParts
151 {
152 get { return _uri.Segments; }
153 }
154 public HttpParam Param
155 {
156 get { return null; }
157 }
158 public HttpForm Form
159 {
160 get { return null; }
161 }
162 public bool IsAjax
163 {
164 get { return false; }
165 }
166 public RequestCookies Cookies
167 {
168 get { return null; }
169 }
170
171 public TestHttpRequest() {}
172
173 public TestHttpRequest(string contentEncoding, string contentType, string userAgent,
174 string remoteAddr, string remotePort, string[] acceptTypes,
175 ConnectionType connectionType, int contentLength, Uri uri)
176 {
177 _headers["content-encoding"] = contentEncoding;
178 _headers["content-type"] = contentType;
179 _headers["user-agent"] = userAgent;
180 _headers["remote_addr"] = remoteAddr;
181 _headers["remote_port"] = remotePort;
182
183 _acceptTypes = acceptTypes;
184 _connection = connectionType;
185 _contentLength = contentLength;
186 _uri = uri;
187 }
188
189 public void DecodeBody(FormDecoderProvider providers) {}
190 public void SetCookies(RequestCookies cookies) {}
191 public void AddHeader(string name, string value)
192 {
193 _headers.Add(name, value);
194 }
195 public int AddToBody(byte[] bytes, int offset, int length)
196 {
197 return 0;
198 }
199 public void Clear() {}
200
201 public object Clone()
202 {
203 TestHttpRequest clone = new TestHttpRequest();
204 clone._acceptTypes = _acceptTypes;
205 clone._connection = _connection;
206 clone._contentLength = _contentLength;
207 clone._uri = _uri;
208 clone._headers = new NameValueCollection(_headers);
209
210 return clone;
211 }
212 public IHttpResponse CreateResponse(IHttpClientContext context)
213 {
214 return new HttpResponse(context, this);
215 }
216 /// <summary>
217 /// Path and query (will be merged with the host header) and put in Uri
218 /// </summary>
219 /// <see cref="Uri"/>
220 public string UriPath
221 {
222 get { return _uriPath; }
223 set
224 {
225 _uriPath = value;
226
227 }
228 }
229
230 }
231
232 public class TestHttpResponse: IHttpResponse
233 {
234 public Stream Body
235 {
236 get { return _body; }
237
238 set { _body = value; }
239 }
240 private Stream _body;
241
242 public string ProtocolVersion
243 {
244 get { return _protocolVersion; }
245 set { _protocolVersion = value; }
246 }
247 private string _protocolVersion;
248
249 public bool Chunked
250 {
251 get { return _chunked; }
252
253 set { _chunked = value; }
254 }
255 private bool _chunked;
256
257 public ConnectionType Connection
258 {
259 get { return _connection; }
260
261 set { _connection = value; }
262 }
263 private ConnectionType _connection;
264
265 public Encoding Encoding
266 {
267 get { return _encoding; }
268
269 set { _encoding = value; }
270 }
271 private Encoding _encoding;
272
273 public int KeepAlive
274 {
275 get { return _keepAlive; }
276
277 set { _keepAlive = value; }
278 }
279 private int _keepAlive;
280
281 public HttpStatusCode Status
282 {
283 get { return _status; }
284
285 set { _status = value; }
286 }
287 private HttpStatusCode _status;
288
289 public string Reason
290 {
291 get { return _reason; }
292
293 set { _reason = value; }
294 }
295 private string _reason;
296
297 public long ContentLength
298 {
299 get { return _contentLength; }
300
301 set { _contentLength = value; }
302 }
303 private long _contentLength;
304
305 public string ContentType
306 {
307 get { return _contentType; }
308
309 set { _contentType = value; }
310 }
311 private string _contentType;
312
313 public bool HeadersSent
314 {
315 get { return _headersSent; }
316 }
317 private bool _headersSent;
318
319 public bool Sent
320 {
321 get { return _sent; }
322 }
323 private bool _sent;
324
325 public ResponseCookies Cookies
326 {
327 get { return _cookies; }
328 }
329 private ResponseCookies _cookies = null;
330
331 public TestHttpResponse()
332 {
333 _headersSent = false;
334 _sent = false;
335 }
336
337 public void AddHeader(string name, string value) {}
338 public void Send()
339 {
340 if (!_headersSent) SendHeaders();
341 if (_sent) throw new InvalidOperationException("stuff already sent");
342 _sent = true;
343 }
344
345 public void SendBody(byte[] buffer, int offset, int count)
346 {
347 if (!_headersSent) SendHeaders();
348 _sent = true;
349 }
350 public void SendBody(byte[] buffer)
351 {
352 if (!_headersSent) SendHeaders();
353 _sent = true;
354 }
355
356 public void SendHeaders()
357 {
358 if (_headersSent) throw new InvalidOperationException("headers already sent");
359 _headersSent = true;
360 }
361
362 public void Redirect(Uri uri) {}
363 public void Redirect(string url) {}
364 }
365
366
45 public OSHttpRequest req0; 367 public OSHttpRequest req0;
46 public OSHttpRequest req1; 368 public OSHttpRequest req1;
47 369
@@ -52,22 +374,22 @@ namespace OpenSim.Framework.Servers.Tests
52 [TestFixtureSetUp] 374 [TestFixtureSetUp]
53 public void Init() 375 public void Init()
54 { 376 {
55 TestHttpRequest threq0 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 377 TestHttpRequest threq0 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711",
56 new string[] {"text/xml"}, 378 new string[] {"text/xml"},
57 ConnectionType.KeepAlive, 4711, 379 ConnectionType.KeepAlive, 4711,
58 new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis")); 380 new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis"));
59 threq0.Method = "GET"; 381 threq0.Method = "GET";
60 threq0.HttpVersion = HttpHelper.HTTP10; 382 threq0.HttpVersion = HttpHelper.HTTP10;
61 383
62 TestHttpRequest threq1 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 384 TestHttpRequest threq1 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711",
63 new string[] {"text/xml"}, 385 new string[] {"text/xml"},
64 ConnectionType.KeepAlive, 4711, 386 ConnectionType.KeepAlive, 4711,
65 new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2")); 387 new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2"));
66 threq1.Method = "POST"; 388 threq1.Method = "POST";
67 threq1.HttpVersion = HttpHelper.HTTP11; 389 threq1.HttpVersion = HttpHelper.HTTP11;
68 threq1.Headers["x-wuff"] = "wuffwuff"; 390 threq1.Headers["x-wuff"] = "wuffwuff";
69 threq1.Headers["www-authenticate"] = "go away"; 391 threq1.Headers["www-authenticate"] = "go away";
70 392
71 req0 = new OSHttpRequest(new TestHttpClientContext(false), threq0); 393 req0 = new OSHttpRequest(new TestHttpClientContext(false), threq0);
72 req1 = new OSHttpRequest(new TestHttpClientContext(false), threq1); 394 req1 = new OSHttpRequest(new TestHttpClientContext(false), threq1);
73 395
@@ -113,4 +435,5 @@ namespace OpenSim.Framework.Servers.Tests
113 Assert.That(rsp0.ContentType, Is.EqualTo("text/xml")); 435 Assert.That(rsp0.ContentType, Is.EqualTo("text/xml"));
114 } 436 }
115 } 437 }
116} \ No newline at end of file 438*/
439}
diff --git a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs b/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs
index 2d72cb8..480f2bb 100644
--- a/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs
+++ b/OpenSim/Framework/Servers/Tests/VersionInfoTests.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Framework.Servers.Tests
47 { 47 {
48 foreach (VersionInfo.Flavour flavour in Enum.GetValues(typeof(VersionInfo.Flavour))) 48 foreach (VersionInfo.Flavour flavour in Enum.GetValues(typeof(VersionInfo.Flavour)))
49 { 49 {
50 Assert.AreEqual(VersionInfo.VERSIONINFO_VERSION_LENGTH, VersionInfo.GetVersionString("0.0.0", "0", flavour).Length, "0.0.0/" + flavour + " failed"); 50 Assert.AreEqual(VersionInfo.VERSIONINFO_VERSION_LENGTH, VersionInfo.GetVersionString("0.0.0", flavour).Length, "0.0.0/" + flavour + " failed");
51 } 51 }
52 } 52 }
53 } 53 }
diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs
index 512ac4f..9126cfb 100644
--- a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs
+++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.ServiceAuth
56 { 56 {
57// remove_me = section; 57// remove_me = section;
58 m_Username = Util.GetConfigVarFromSections<string>(config, "HttpAuthUsername", new string[] { "Network", section }, string.Empty); 58 m_Username = Util.GetConfigVarFromSections<string>(config, "HttpAuthUsername", new string[] { "Network", section }, string.Empty);
59 m_Password = Util.GetConfigVarFromSections<string>(config, "HttpAuthPassword", new string[] { "Network", section }, string.Empty); 59 m_Password = Util.GetConfigVarFromSections<string>(config, "HttpAuthPassword", new string[] { "Network", section }, string.Empty);
60 string str = m_Username + ":" + m_Password; 60 string str = m_Username + ":" + m_Password;
61 byte[] encData_byte = Util.UTF8.GetBytes(str); 61 byte[] encData_byte = Util.UTF8.GetBytes(str);
62 62
diff --git a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs
index a49952c..79d6ff4 100644
--- a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs
+++ b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.ServiceAuth
56 m_authentications.Remove(auth); 56 m_authentications.Remove(auth);
57 } 57 }
58 58
59 public void AddAuthorization(NameValueCollection headers) 59 public void AddAuthorization(NameValueCollection headers)
60 { 60 {
61 foreach (IServiceAuth auth in m_authentications) 61 foreach (IServiceAuth auth in m_authentications)
62 auth.AddAuthorization(headers); 62 auth.AddAuthorization(headers);
diff --git a/OpenSim/Framework/SimStats.cs b/OpenSim/Framework/SimStats.cs
index 3d8f32f..f19a270 100644
--- a/OpenSim/Framework/SimStats.cs
+++ b/OpenSim/Framework/SimStats.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Framework
32{ 32{
33 /// <summary> 33 /// <summary>
34 /// Enapsulate statistics for a simulator/scene. 34 /// Enapsulate statistics for a simulator/scene.
35 /// 35 ///
36 /// TODO: This looks very much like the OpenMetaverse SimStatsPacket. It should be much more generic stats 36 /// TODO: This looks very much like the OpenMetaverse SimStatsPacket. It should be much more generic stats
37 /// storage. 37 /// storage.
38 /// </summary> 38 /// </summary>
@@ -49,25 +49,31 @@ namespace OpenSim.Framework
49 get { return m_regionY; } 49 get { return m_regionY; }
50 } 50 }
51 private uint m_regionY; 51 private uint m_regionY;
52 52
53 public SimStatsPacket.RegionBlock RegionBlock 53 public SimStatsPacket.RegionBlock RegionBlock
54 { 54 {
55 get { return m_regionBlock; } 55 get { return m_regionBlock; }
56 } 56 }
57 private SimStatsPacket.RegionBlock m_regionBlock; 57 private SimStatsPacket.RegionBlock m_regionBlock;
58 58
59 public SimStatsPacket.StatBlock[] StatsBlock 59 public SimStatsPacket.StatBlock[] StatsBlock
60 { 60 {
61 get { return m_statsBlock; } 61 get { return m_statsBlock; }
62 } 62 }
63 private SimStatsPacket.StatBlock[] m_statsBlock; 63 private SimStatsPacket.StatBlock[] m_statsBlock;
64 64
65 public SimStatsPacket.StatBlock[] ExtraStatsBlock
66 {
67 get { return m_extraStatsBlock; }
68 }
69 private SimStatsPacket.StatBlock[] m_extraStatsBlock;
70
65 public uint RegionFlags 71 public uint RegionFlags
66 { 72 {
67 get { return m_regionFlags; } 73 get { return m_regionFlags; }
68 } 74 }
69 private uint m_regionFlags; 75 private uint m_regionFlags;
70 76
71 public uint ObjectCapacity 77 public uint ObjectCapacity
72 { 78 {
73 get { return m_objectCapacity; } 79 get { return m_objectCapacity; }
@@ -79,10 +85,11 @@ namespace OpenSim.Framework
79 get { return regionUUID; } 85 get { return regionUUID; }
80 } 86 }
81 private UUID regionUUID; 87 private UUID regionUUID;
82 88
83 public SimStats( 89 public SimStats(
84 uint regionX, uint regionY, uint regionFlags, uint objectCapacity, 90 uint regionX, uint regionY, uint regionFlags, uint objectCapacity,
85 SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID) 91 SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock,
92 SimStatsPacket.StatBlock[] ExtraStatsBlock, UUID pRUUID)
86 { 93 {
87 regionUUID = pRUUID; 94 regionUUID = pRUUID;
88 m_regionX = regionX; 95 m_regionX = regionX;
@@ -91,6 +98,7 @@ namespace OpenSim.Framework
91 m_objectCapacity = objectCapacity; 98 m_objectCapacity = objectCapacity;
92 m_regionBlock = regionBlock; 99 m_regionBlock = regionBlock;
93 m_statsBlock = statsBlock; 100 m_statsBlock = statsBlock;
101 m_extraStatsBlock = ExtraStatsBlock;
94 } 102 }
95 } 103 }
96} 104}
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs
index 8af2c41..223d91f 100644
--- a/OpenSim/Framework/TaskInventoryDictionary.cs
+++ b/OpenSim/Framework/TaskInventoryDictionary.cs
@@ -27,9 +27,13 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading;
31using System.Reflection;
30using System.Xml; 32using System.Xml;
33using System.Diagnostics;
31using System.Xml.Schema; 34using System.Xml.Schema;
32using System.Xml.Serialization; 35using System.Xml.Serialization;
36using log4net;
33using OpenMetaverse; 37using OpenMetaverse;
34 38
35namespace OpenSim.Framework 39namespace OpenSim.Framework
@@ -47,6 +51,187 @@ namespace OpenSim.Framework
47 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 52
49 private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); 53 private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem));
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private Thread LockedByThread;
57// private string WriterStack;
58
59// private Dictionary<Thread, string> ReadLockers =
60// new Dictionary<Thread, string>();
61
62 /// <value>
63 /// An advanced lock for inventory data
64 /// </value>
65 private volatile System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim();
66
67
68 ~TaskInventoryDictionary()
69 {
70 m_itemLock.Dispose();
71 m_itemLock = null;
72 }
73
74 /// <summary>
75 /// Are we readlocked by the calling thread?
76 /// </summary>
77 public bool IsReadLockedByMe()
78 {
79 if (m_itemLock.RecursiveReadCount > 0)
80 {
81 return true;
82 }
83 else
84 {
85 return false;
86 }
87 }
88
89 /// <summary>
90 /// Lock our inventory list for reading (many can read, one can write)
91 /// </summary>
92 public void LockItemsForRead(bool locked)
93 {
94 if (locked)
95 {
96 if (m_itemLock.IsWriteLockHeld && LockedByThread != null)
97 {
98 if (!LockedByThread.IsAlive)
99 {
100 //Locked by dead thread, reset.
101 m_itemLock = new System.Threading.ReaderWriterLockSlim();
102 }
103 }
104
105 if (m_itemLock.RecursiveReadCount > 0)
106 {
107 m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
108 try
109 {
110 // That call stack is useful for end users only. RealProgrammers need a full dump. Commented.
111 // StackTrace stackTrace = new StackTrace(); // get call stack
112 // StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
113 //
114 // // write call stack method names
115 // foreach (StackFrame stackFrame in stackFrames)
116 // {
117 // m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name
118 // }
119
120 // The below is far more useful
121// System.Console.WriteLine("------------------------------------------");
122// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
123// System.Console.WriteLine("------------------------------------------");
124// foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
125// {
126// System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
127// System.Console.WriteLine("------------------------------------------");
128// }
129 }
130 catch
131 {}
132 m_itemLock.ExitReadLock();
133 }
134 if (m_itemLock.RecursiveWriteCount > 0)
135 {
136 m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
137// try
138// {
139// System.Console.WriteLine("------------------------------------------");
140// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
141// System.Console.WriteLine("------------------------------------------");
142// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
143// System.Console.WriteLine("------------------------------------------");
144// }
145// catch
146// {}
147 m_itemLock.ExitWriteLock();
148 }
149
150 while (!m_itemLock.TryEnterReadLock(60000))
151 {
152 m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
153 //if (m_itemLock.IsWriteLockHeld)
154 //{
155 m_itemLock = new System.Threading.ReaderWriterLockSlim();
156// System.Console.WriteLine("------------------------------------------");
157// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
158// System.Console.WriteLine("------------------------------------------");
159// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
160// System.Console.WriteLine("------------------------------------------");
161// LockedByThread = null;
162// ReadLockers.Clear();
163 //}
164 }
165// ReadLockers[Thread.CurrentThread] = Environment.StackTrace;
166 }
167 else
168 {
169 if (m_itemLock.RecursiveReadCount>0)
170 {
171 m_itemLock.ExitReadLock();
172 }
173// if (m_itemLock.RecursiveReadCount == 0)
174// ReadLockers.Remove(Thread.CurrentThread);
175 }
176 }
177
178 /// <summary>
179 /// Lock our inventory list for writing (many can read, one can write)
180 /// </summary>
181 public void LockItemsForWrite(bool locked)
182 {
183 if (locked)
184 {
185 //Enter a write lock, wait indefinately for one to open.
186 if (m_itemLock.RecursiveReadCount > 0)
187 {
188 m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
189 m_itemLock.ExitReadLock();
190 }
191 if (m_itemLock.RecursiveWriteCount > 0)
192 {
193 m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
194
195 m_itemLock.ExitWriteLock();
196 }
197 while (!m_itemLock.TryEnterWriteLock(60000))
198 {
199 if (m_itemLock.IsWriteLockHeld)
200 {
201 m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
202// System.Console.WriteLine("------------------------------------------");
203// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
204// System.Console.WriteLine("------------------------------------------");
205// System.Console.WriteLine("Locker's call stack:\n" + WriterStack);
206// System.Console.WriteLine("------------------------------------------");
207 }
208 else
209 {
210 m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by a reader. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
211// System.Console.WriteLine("------------------------------------------");
212// System.Console.WriteLine("My call stack:\n" + Environment.StackTrace);
213// System.Console.WriteLine("------------------------------------------");
214// foreach (KeyValuePair<Thread, string> kvp in ReadLockers)
215// {
216// System.Console.WriteLine("Locker name {0} call stack:\n" + kvp.Value, kvp.Key.Name);
217// System.Console.WriteLine("------------------------------------------");
218// }
219 }
220 m_itemLock = new System.Threading.ReaderWriterLockSlim();
221// ReadLockers.Clear();
222 }
223
224 LockedByThread = Thread.CurrentThread;
225// WriterStack = Environment.StackTrace;
226 }
227 else
228 {
229 if (m_itemLock.RecursiveWriteCount > 0)
230 {
231 m_itemLock.ExitWriteLock();
232 }
233 }
234 }
50 235
51 #region ICloneable Members 236 #region ICloneable Members
52 237
@@ -54,14 +239,13 @@ namespace OpenSim.Framework
54 { 239 {
55 TaskInventoryDictionary clone = new TaskInventoryDictionary(); 240 TaskInventoryDictionary clone = new TaskInventoryDictionary();
56 241
57 lock (this) 242 m_itemLock.EnterReadLock();
243 foreach (UUID uuid in Keys)
58 { 244 {
59 foreach (UUID uuid in Keys) 245 clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
60 {
61 clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
62 }
63 } 246 }
64 247 m_itemLock.ExitReadLock();
248
65 return clone; 249 return clone;
66 } 250 }
67 251
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs
index 307cb75..1cc32b3 100644
--- a/OpenSim/Framework/TaskInventoryItem.cs
+++ b/OpenSim/Framework/TaskInventoryItem.cs
@@ -59,6 +59,7 @@ namespace OpenSim.Framework
59 private int _invType = 0; 59 private int _invType = 0;
60 private UUID _itemID = UUID.Zero; 60 private UUID _itemID = UUID.Zero;
61 private UUID _lastOwnerID = UUID.Zero; 61 private UUID _lastOwnerID = UUID.Zero;
62 private UUID _rezzerID = UUID.Zero;
62 private string _name = String.Empty; 63 private string _name = String.Empty;
63 private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; 64 private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
64 private UUID _ownerID = UUID.Zero; 65 private UUID _ownerID = UUID.Zero;
@@ -254,6 +255,16 @@ namespace OpenSim.Framework
254 } 255 }
255 } 256 }
256 257
258 public UUID RezzerID
259 {
260 get {
261 return _rezzerID;
262 }
263 set {
264 _rezzerID = value;
265 }
266 }
267
257 public string Name { 268 public string Name {
258 get { 269 get {
259 return _name; 270 return _name;
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index 6b1be4e..5cec2b5 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.IO.Compression;
31using System.Reflection; 32using System.Reflection;
32 33
33using OpenMetaverse; 34using OpenMetaverse;
@@ -48,6 +49,7 @@ namespace OpenSim.Framework
48 49
49 public abstract float this[int x, int y] { get; set; } 50 public abstract float this[int x, int y] { get; set; }
50 // Someday terrain will have caves 51 // Someday terrain will have caves
52 // at most holes :p
51 public abstract float this[int x, int y, int z] { get; set; } 53 public abstract float this[int x, int y, int z] { get; set; }
52 54
53 public abstract bool IsTaintedAt(int xx, int yy); 55 public abstract bool IsTaintedAt(int xx, int yy);
@@ -72,8 +74,8 @@ namespace OpenSim.Framework
72 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); 74 return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob);
73 } 75 }
74 76
75 // return a special compressed representation of the heightmap in ints 77 // return a special compressed representation of the heightmap in ushort
76 public abstract int[] GetCompressedMap(); 78 public abstract float[] GetCompressedMap();
77 public abstract float CompressionFactor { get; } 79 public abstract float CompressionFactor { get; }
78 80
79 public abstract float[] GetFloatsSerialized(); 81 public abstract float[] GetFloatsSerialized();
@@ -94,14 +96,18 @@ namespace OpenSim.Framework
94 { 96 {
95 // Terrain is 'double[256,256]' 97 // Terrain is 'double[256,256]'
96 Legacy256 = 11, 98 Legacy256 = 11,
99
97 // Terrain is 'int32, int32, float[,]' where the ints are X and Y dimensions 100 // Terrain is 'int32, int32, float[,]' where the ints are X and Y dimensions
98 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 101 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
99 Variable2D = 22, 102 Variable2D = 22,
103 Variable2DGzip = 23,
104
100 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions 105 // Terrain is 'int32, int32, int32, int16[]' where the ints are X and Y dimensions
101 // and third int is the 'compression factor'. The heights are compressed as 106 // and third int is the 'compression factor'. The heights are compressed as
102 // "int compressedHeight = (int)(height * compressionFactor);" 107 // "ushort compressedHeight = (ushort)(height * compressionFactor);"
103 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 108 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
104 Compressed2D = 27, 109 Compressed2D = 27,
110
105 // A revision that is not listed above or any revision greater than this value is 'Legacy256'. 111 // A revision that is not listed above or any revision greater than this value is 'Legacy256'.
106 RevisionHigh = 1234 112 RevisionHigh = 1234
107 } 113 }
@@ -109,7 +115,7 @@ namespace OpenSim.Framework
109 // Version of terrain that is a heightmap. 115 // Version of terrain that is a heightmap.
110 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge 116 // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge
111 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer. 117 // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer.
112 // The heighmap is kept as an array of integers. The integer values are converted to 118 // The heighmap is kept as an array of ushorts. The ushort values are converted to
113 // and from floats by TerrainCompressionFactor. 119 // and from floats by TerrainCompressionFactor.
114 public class HeightmapTerrainData : TerrainData 120 public class HeightmapTerrainData : TerrainData
115 { 121 {
@@ -119,12 +125,12 @@ namespace OpenSim.Framework
119 // TerrainData.this[x, y] 125 // TerrainData.this[x, y]
120 public override float this[int x, int y] 126 public override float this[int x, int y]
121 { 127 {
122 get { return FromCompressedHeight(m_heightmap[x, y]); } 128 get { return m_heightmap[x, y]; }
123 set { 129 set
124 int newVal = ToCompressedHeight(value); 130 {
125 if (m_heightmap[x, y] != newVal) 131 if (m_heightmap[x, y] != value)
126 { 132 {
127 m_heightmap[x, y] = newVal; 133 m_heightmap[x, y] = value;
128 m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; 134 m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true;
129 } 135 }
130 } 136 }
@@ -164,10 +170,9 @@ namespace OpenSim.Framework
164 // TerrainData.ClearLand(float) 170 // TerrainData.ClearLand(float)
165 public override void ClearLand(float pHeight) 171 public override void ClearLand(float pHeight)
166 { 172 {
167 int flatHeight = ToCompressedHeight(pHeight);
168 for (int xx = 0; xx < SizeX; xx++) 173 for (int xx = 0; xx < SizeX; xx++)
169 for (int yy = 0; yy < SizeY; yy++) 174 for (int yy = 0; yy < SizeY; yy++)
170 m_heightmap[xx, yy] = flatHeight; 175 m_heightmap[xx, yy] = pHeight;
171 } 176 }
172 177
173 // Return 'true' of the patch that contains these region coordinates has been modified. 178 // Return 'true' of the patch that contains these region coordinates has been modified.
@@ -177,13 +182,15 @@ namespace OpenSim.Framework
177 { 182 {
178 int tx = xx / Constants.TerrainPatchSize; 183 int tx = xx / Constants.TerrainPatchSize;
179 int ty = yy / Constants.TerrainPatchSize; 184 int ty = yy / Constants.TerrainPatchSize;
180 bool ret = m_taint[tx, ty]; 185 bool ret = m_taint[tx, ty];
181 if (ret && clearOnTest) 186 if (ret && clearOnTest)
182 m_taint[tx, ty] = false; 187 m_taint[tx, ty] = false;
183 return ret; 188 return ret;
184 } 189 }
185 190
186 // Old form that clears the taint flag when we check it. 191 // Old form that clears the taint flag when we check it.
192 // ubit: this dangerus naming should be only check without clear
193 // keeping for old modules outthere
187 public override bool IsTaintedAt(int xx, int yy) 194 public override bool IsTaintedAt(int xx, int yy)
188 { 195 {
189 return IsTaintedAt(xx, yy, true /* clearOnTest */); 196 return IsTaintedAt(xx, yy, true /* clearOnTest */);
@@ -194,6 +201,7 @@ namespace OpenSim.Framework
194 public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) 201 public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob)
195 { 202 {
196 bool ret = false; 203 bool ret = false;
204/* save all as Variable2DGzip
197 if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize) 205 if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize)
198 { 206 {
199 DBRevisionCode = (int)DBTerrainRevision.Legacy256; 207 DBRevisionCode = (int)DBTerrainRevision.Legacy256;
@@ -202,10 +210,13 @@ namespace OpenSim.Framework
202 } 210 }
203 else 211 else
204 { 212 {
205 DBRevisionCode = (int)DBTerrainRevision.Compressed2D; 213*/
206 blob = ToCompressedTerrainSerialization(); 214 DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip;
215// DBRevisionCode = (int)DBTerrainRevision.Variable2D;
216 blob = ToCompressedTerrainSerializationV2DGzip();
217// blob = ToCompressedTerrainSerializationV2D();
207 ret = true; 218 ret = true;
208 } 219// }
209 return ret; 220 return ret;
210 } 221 }
211 222
@@ -214,9 +225,9 @@ namespace OpenSim.Framework
214 public override float CompressionFactor { get { return m_compressionFactor; } } 225 public override float CompressionFactor { get { return m_compressionFactor; } }
215 226
216 // TerrainData.GetCompressedMap 227 // TerrainData.GetCompressedMap
217 public override int[] GetCompressedMap() 228 public override float[] GetCompressedMap()
218 { 229 {
219 int[] newMap = new int[SizeX * SizeY]; 230 float[] newMap = new float[SizeX * SizeY];
220 231
221 int ind = 0; 232 int ind = 0;
222 for (int xx = 0; xx < SizeX; xx++) 233 for (int xx = 0; xx < SizeX; xx++)
@@ -230,7 +241,7 @@ namespace OpenSim.Framework
230 public override TerrainData Clone() 241 public override TerrainData Clone()
231 { 242 {
232 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); 243 HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ);
233 ret.m_heightmap = (int[,])this.m_heightmap.Clone(); 244 ret.m_heightmap = (float[,])this.m_heightmap.Clone();
234 return ret; 245 return ret;
235 } 246 }
236 247
@@ -247,7 +258,7 @@ namespace OpenSim.Framework
247 for (int jj = 0; jj < SizeY; jj++) 258 for (int jj = 0; jj < SizeY; jj++)
248 for (int ii = 0; ii < SizeX; ii++) 259 for (int ii = 0; ii < SizeX; ii++)
249 { 260 {
250 heights[idx++] = FromCompressedHeight(m_heightmap[ii, jj]); 261 heights[idx++] = m_heightmap[ii, jj];
251 } 262 }
252 263
253 return heights; 264 return heights;
@@ -259,7 +270,7 @@ namespace OpenSim.Framework
259 double[,] ret = new double[SizeX, SizeY]; 270 double[,] ret = new double[SizeX, SizeY];
260 for (int xx = 0; xx < SizeX; xx++) 271 for (int xx = 0; xx < SizeX; xx++)
261 for (int yy = 0; yy < SizeY; yy++) 272 for (int yy = 0; yy < SizeY; yy++)
262 ret[xx, yy] = FromCompressedHeight(m_heightmap[xx, yy]); 273 ret[xx, yy] = (double)m_heightmap[xx, yy];
263 274
264 return ret; 275 return ret;
265 } 276 }
@@ -267,19 +278,40 @@ namespace OpenSim.Framework
267 278
268 // ============================================================= 279 // =============================================================
269 280
270 private int[,] m_heightmap; 281 private float[,] m_heightmap;
271 // Remember subregions of the heightmap that has changed. 282 // Remember subregions of the heightmap that has changed.
272 private bool[,] m_taint; 283 private bool[,] m_taint;
273 284
274 // To save space (especially for large regions), keep the height as a short integer
275 // that is coded as the float height times the compression factor (usually '100' 285 // that is coded as the float height times the compression factor (usually '100'
276 // to make for two decimal points). 286 // to make for two decimal points).
277 public int ToCompressedHeight(double pHeight) 287 public short ToCompressedHeightshort(float pHeight)
278 { 288 {
279 return (int)(pHeight * CompressionFactor); 289 // clamp into valid range
290 pHeight *= CompressionFactor;
291 if (pHeight < short.MinValue)
292 return short.MinValue;
293 else if (pHeight > short.MaxValue)
294 return short.MaxValue;
295 return (short)pHeight;
280 } 296 }
281 297
282 public float FromCompressedHeight(int pHeight) 298 public ushort ToCompressedHeightushort(float pHeight)
299 {
300 // clamp into valid range
301 pHeight *= CompressionFactor;
302 if (pHeight < ushort.MinValue)
303 return ushort.MinValue;
304 else if (pHeight > ushort.MaxValue)
305 return ushort.MaxValue;
306 return (ushort)pHeight;
307 }
308
309 public float FromCompressedHeight(short pHeight)
310 {
311 return ((float)pHeight) / CompressionFactor;
312 }
313
314 public float FromCompressedHeight(ushort pHeight)
283 { 315 {
284 return ((float)pHeight) / CompressionFactor; 316 return ((float)pHeight) / CompressionFactor;
285 } 317 }
@@ -293,12 +325,12 @@ namespace OpenSim.Framework
293 SizeZ = (int)Constants.RegionHeight; 325 SizeZ = (int)Constants.RegionHeight;
294 m_compressionFactor = 100.0f; 326 m_compressionFactor = 100.0f;
295 327
296 m_heightmap = new int[SizeX, SizeY]; 328 m_heightmap = new float[SizeX, SizeY];
297 for (int ii = 0; ii < SizeX; ii++) 329 for (int ii = 0; ii < SizeX; ii++)
298 { 330 {
299 for (int jj = 0; jj < SizeY; jj++) 331 for (int jj = 0; jj < SizeY; jj++)
300 { 332 {
301 m_heightmap[ii, jj] = ToCompressedHeight(pTerrain[ii, jj]); 333 m_heightmap[ii, jj] = (float)pTerrain[ii, jj];
302 334
303 } 335 }
304 } 336 }
@@ -315,14 +347,15 @@ namespace OpenSim.Framework
315 SizeY = pY; 347 SizeY = pY;
316 SizeZ = pZ; 348 SizeZ = pZ;
317 m_compressionFactor = 100.0f; 349 m_compressionFactor = 100.0f;
318 m_heightmap = new int[SizeX, SizeY]; 350 m_heightmap = new float[SizeX, SizeY];
319 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; 351 m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize];
320 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); 352 // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ);
321 ClearTaint(); 353 ClearTaint();
322 ClearLand(0f); 354 ClearLand(0f);
323 } 355 }
324 356
325 public HeightmapTerrainData(int[] cmap, float pCompressionFactor, int pX, int pY, int pZ) : this(pX, pY, pZ) 357 public HeightmapTerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ)
358 : this(pX, pY, pZ)
326 { 359 {
327 m_compressionFactor = pCompressionFactor; 360 m_compressionFactor = pCompressionFactor;
328 int ind = 0; 361 int ind = 0;
@@ -333,12 +366,22 @@ namespace OpenSim.Framework
333 } 366 }
334 367
335 // Create a heighmap from a database blob 368 // Create a heighmap from a database blob
336 public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) : this(pSizeX, pSizeY, pSizeZ) 369 public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob)
370 : this(pSizeX, pSizeY, pSizeZ)
337 { 371 {
338 switch ((DBTerrainRevision)pFormatCode) 372 switch ((DBTerrainRevision)pFormatCode)
339 { 373 {
374 case DBTerrainRevision.Variable2DGzip:
375 FromCompressedTerrainSerializationV2DGZip(pBlob);
376 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2DGzip serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
377 break;
378
379 case DBTerrainRevision.Variable2D:
380 FromCompressedTerrainSerializationV2D(pBlob);
381 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
382 break;
340 case DBTerrainRevision.Compressed2D: 383 case DBTerrainRevision.Compressed2D:
341 FromCompressedTerrainSerialization(pBlob); 384 FromCompressedTerrainSerialization2D(pBlob);
342 m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); 385 m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
343 break; 386 break;
344 default: 387 default:
@@ -373,50 +416,116 @@ namespace OpenSim.Framework
373 return ret; 416 return ret;
374 } 417 }
375 418
376 // Just create an array of doubles. Presumes the caller implicitly knows the size. 419 // Presumes the caller implicitly knows the size.
377 public void FromLegacyTerrainSerialization(byte[] pBlob) 420 public void FromLegacyTerrainSerialization(byte[] pBlob)
378 { 421 {
379 // In case database info doesn't match real terrain size, initialize the whole terrain. 422 // In case database info doesn't match real terrain size, initialize the whole terrain.
380 ClearLand(); 423 ClearLand();
381 424
382 using (MemoryStream mstr = new MemoryStream(pBlob)) 425 try
383 { 426 {
384 using (BinaryReader br = new BinaryReader(mstr)) 427 using (MemoryStream mstr = new MemoryStream(pBlob))
385 { 428 {
386 for (int xx = 0; xx < (int)Constants.RegionSize; xx++) 429 using (BinaryReader br = new BinaryReader(mstr))
387 { 430 {
388 for (int yy = 0; yy < (int)Constants.RegionSize; yy++) 431 for (int xx = 0; xx < (int)Constants.RegionSize; xx++)
389 { 432 {
390 float val = (float)br.ReadDouble(); 433 for (int yy = 0; yy < (int)Constants.RegionSize; yy++)
391 if (xx < SizeX && yy < SizeY) 434 {
392 m_heightmap[xx, yy] = ToCompressedHeight(val); 435 float val = (float)br.ReadDouble();
436
437 if (xx < SizeX && yy < SizeY)
438 m_heightmap[xx, yy] = val;
439 }
393 } 440 }
394 } 441 }
395 } 442 }
396 ClearTaint();
397 } 443 }
444 catch
445 {
446 ClearLand();
447 }
448 ClearTaint();
449 }
450
451
452 // stores as variable2D
453 // int32 sizeX
454 // int32 sizeY
455 // float[,] array
456
457 public Array ToCompressedTerrainSerializationV2D()
458 {
459 Array ret = null;
460 try
461 {
462 using (MemoryStream str = new MemoryStream((2 * sizeof(Int32)) + (SizeX * SizeY * sizeof(float))))
463 {
464 using (BinaryWriter bw = new BinaryWriter(str))
465 {
466 bw.Write((Int32)SizeX);
467 bw.Write((Int32)SizeY);
468 for (int yy = 0; yy < SizeY; yy++)
469 for (int xx = 0; xx < SizeX; xx++)
470 {
471 // reduce to 1cm resolution
472 float val = (float)Math.Round(m_heightmap[xx, yy],2,MidpointRounding.ToEven);
473 bw.Write(val);
474 }
475 }
476 ret = str.ToArray();
477 }
478 }
479 catch
480 {
481
482 }
483
484 m_log.DebugFormat("{0} V2D {1} bytes",
485 LogHeader, ret.Length);
486
487 return ret;
398 } 488 }
399 489
400 // See the reader below. 490 // as above with Gzip compression
401 public Array ToCompressedTerrainSerialization() 491 public Array ToCompressedTerrainSerializationV2DGzip()
402 { 492 {
403 Array ret = null; 493 Array ret = null;
404 using (MemoryStream str = new MemoryStream((3 * sizeof(Int32)) + (SizeX * SizeY * sizeof(Int16)))) 494 try
405 { 495 {
406 using (BinaryWriter bw = new BinaryWriter(str)) 496 using (MemoryStream inp = new MemoryStream((2 * sizeof(Int32)) + (SizeX * SizeY * sizeof(float))))
407 { 497 {
408 bw.Write((Int32)DBTerrainRevision.Compressed2D); 498 using (BinaryWriter bw = new BinaryWriter(inp))
409 bw.Write((Int32)SizeX); 499 {
410 bw.Write((Int32)SizeY); 500 bw.Write((Int32)SizeX);
411 bw.Write((Int32)CompressionFactor); 501 bw.Write((Int32)SizeY);
412 for (int yy = 0; yy < SizeY; yy++) 502 for (int yy = 0; yy < SizeY; yy++)
413 for (int xx = 0; xx < SizeX; xx++) 503 for (int xx = 0; xx < SizeX; xx++)
504 {
505 bw.Write((float)m_heightmap[xx, yy]);
506 }
507
508 bw.Flush();
509 inp.Seek(0, SeekOrigin.Begin);
510
511 using (MemoryStream outputStream = new MemoryStream())
414 { 512 {
415 bw.Write((Int16)m_heightmap[xx, yy]); 513 using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress))
514 {
515 inp.CopyStream(compressionStream, int.MaxValue);
516 compressionStream.Close();
517 ret = outputStream.ToArray();
518 }
416 } 519 }
520 }
417 } 521 }
418 ret = str.ToArray();
419 } 522 }
523 catch
524 {
525
526 }
527 m_log.DebugFormat("{0} V2DGzip {1} bytes",
528 LogHeader, ret.Length);
420 return ret; 529 return ret;
421 } 530 }
422 531
@@ -426,7 +535,7 @@ namespace OpenSim.Framework
426 // the forth int is the compression factor for the following int16s 535 // the forth int is the compression factor for the following int16s
427 // This is just sets heightmap info. The actual size of the region was set on this instance's 536 // This is just sets heightmap info. The actual size of the region was set on this instance's
428 // creation and any heights not initialized by theis blob are set to the default height. 537 // creation and any heights not initialized by theis blob are set to the default height.
429 public void FromCompressedTerrainSerialization(byte[] pBlob) 538 public void FromCompressedTerrainSerialization2D(byte[] pBlob)
430 { 539 {
431 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor; 540 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor;
432 541
@@ -448,7 +557,7 @@ namespace OpenSim.Framework
448 { 557 {
449 for (int xx = 0; xx < hmSizeX; xx++) 558 for (int xx = 0; xx < hmSizeX; xx++)
450 { 559 {
451 Int16 val = br.ReadInt16(); 560 float val = FromCompressedHeight(br.ReadInt16());
452 if (xx < SizeX && yy < SizeY) 561 if (xx < SizeX && yy < SizeY)
453 m_heightmap[xx, yy] = val; 562 m_heightmap[xx, yy] = val;
454 } 563 }
@@ -456,9 +565,112 @@ namespace OpenSim.Framework
456 } 565 }
457 ClearTaint(); 566 ClearTaint();
458 567
459 m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}", 568 m_log.DebugFormat("{0} Read (compressed2D) heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}",
460 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); 569 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
461 } 570 }
462 } 571 }
572
573 // Initialize heightmap from blob consisting of:
574 // int32, int32, int32, float[]
575 // where the first int32 is format code, next two int32s are the X and y of heightmap data
576 // This is just sets heightmap info. The actual size of the region was set on this instance's
577 // creation and any heights not initialized by theis blob are set to the default height.
578 public void FromCompressedTerrainSerializationV2D(byte[] pBlob)
579 {
580 Int32 hmSizeX, hmSizeY;
581 try
582 {
583 using (MemoryStream mstr = new MemoryStream(pBlob))
584 {
585 using (BinaryReader br = new BinaryReader(mstr))
586 {
587 hmSizeX = br.ReadInt32();
588 hmSizeY = br.ReadInt32();
589
590 // In case database info doesn't match real terrain size, initialize the whole terrain.
591 ClearLand();
592
593 for (int yy = 0; yy < hmSizeY; yy++)
594 {
595 for (int xx = 0; xx < hmSizeX; xx++)
596 {
597 float val = br.ReadSingle();
598 if (xx < SizeX && yy < SizeY)
599 m_heightmap[xx, yy] = val;
600 }
601 }
602 }
603 }
604 }
605 catch (Exception e)
606 {
607 ClearTaint();
608 m_log.ErrorFormat("{0} 2D error: {1} - terrain may be damaged",
609 LogHeader, e.Message);
610 return;
611 }
612 ClearTaint();
613
614 m_log.DebugFormat("{0} V2D Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
615 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
616
617 }
618
619 // as above but Gzip compressed
620 public void FromCompressedTerrainSerializationV2DGZip(byte[] pBlob)
621 {
622 m_log.InfoFormat("{0} VD2Gzip {1} bytes input",
623 LogHeader, pBlob.Length);
624
625 Int32 hmSizeX, hmSizeY;
626
627 try
628 {
629 using (MemoryStream outputStream = new MemoryStream())
630 {
631 using (MemoryStream inputStream = new MemoryStream(pBlob))
632 {
633 using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
634 {
635 decompressionStream.Flush();
636 decompressionStream.CopyTo(outputStream);
637 }
638 }
639
640 outputStream.Seek(0, SeekOrigin.Begin);
641
642 using (BinaryReader br = new BinaryReader(outputStream))
643 {
644 hmSizeX = br.ReadInt32();
645 hmSizeY = br.ReadInt32();
646
647 // In case database info doesn't match real terrain size, initialize the whole terrain.
648 ClearLand();
649
650 for (int yy = 0; yy < hmSizeY; yy++)
651 {
652 for (int xx = 0; xx < hmSizeX; xx++)
653 {
654 float val = br.ReadSingle();
655 if (xx < SizeX && yy < SizeY)
656 m_heightmap[xx, yy] = val;
657 }
658 }
659 }
660 }
661 }
662 catch( Exception e)
663 {
664 ClearTaint();
665 m_log.ErrorFormat("{0} V2DGzip error: {1} - terrain may be damaged",
666 LogHeader, e.Message);
667 return;
668 }
669
670 ClearTaint();
671 m_log.DebugFormat("{0} V2DGzip. Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
672 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
673
674 }
463 } 675 }
464} 676}
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 95e9439..5ad0030 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -96,7 +96,7 @@ namespace OpenSim.Framework.Tests
96 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOOT_SIZE] = 45; 96 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOOT_SIZE] = 45;
97 97
98 98
99 // head 99 // head
100 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SIZE] = 255; 100 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SIZE] = 255;
101 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SQUASH_STRETCH_HEAD] = 0; // head stretch 101 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_SQUASH_STRETCH_HEAD] = 0; // head stretch
102 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SHAPE] = 155; 102 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEAD_SHAPE] = 155;
@@ -106,7 +106,7 @@ namespace OpenSim.Framework.Tests
106 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FACE_SHEAR] = 127; 106 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FACE_SHEAR] = 127;
107 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOREHEAD_ANGLE] = 104; 107 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_FOREHEAD_ANGLE] = 104;
108 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BIG_BROW] = 94; 108 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_BIG_BROW] = 94;
109 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_PUFFY_UPPER_CHEEKS] = 0; // upper cheeks 109 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_PUFFY_UPPER_CHEEKS] = 0; // upper cheeks
110 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_DOUBLE_CHIN] = 122; // lower cheeks 110 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_DOUBLE_CHIN] = 122; // lower cheeks
111 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HIGH_CHEEK_BONES] = 130; 111 VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HIGH_CHEEK_BONES] = 130;
112 112
@@ -232,7 +232,7 @@ namespace OpenSim.Framework.Tests
232 /// <summary> 232 /// <summary>
233 /// Test to ensure that the serialization format is the same and the underlying types don't change without notice 233 /// Test to ensure that the serialization format is the same and the underlying types don't change without notice
234 /// oldSerialization is just a json serialization of the OSDMap packed for the AgentCircuitData. 234 /// oldSerialization is just a json serialization of the OSDMap packed for the AgentCircuitData.
235 /// The idea is that if the current json serializer cannot parse the old serialization, then the underlying types 235 /// The idea is that if the current json serializer cannot parse the old serialization, then the underlying types
236 /// have changed and are incompatible. 236 /// have changed and are incompatible.
237 /// </summary> 237 /// </summary>
238 [Test] 238 [Test]
@@ -311,14 +311,15 @@ namespace OpenSim.Framework.Tests
311 Agent1Data.SessionID = SessionId; 311 Agent1Data.SessionID = SessionId;
312 Agent1Data.startpos = StartPos; 312 Agent1Data.startpos = StartPos;
313 313
314 EntityTransferContext ctx = new EntityTransferContext();
314 OSDMap map2; 315 OSDMap map2;
315 OSDMap map = Agent1Data.PackAgentCircuitData(); 316 OSDMap map = Agent1Data.PackAgentCircuitData(ctx);
316 try 317 try
317 { 318 {
318 string str = OSDParser.SerializeJsonString(map); 319 string str = OSDParser.SerializeJsonString(map);
319 //System.Console.WriteLine(str); 320 //System.Console.WriteLine(str);
320 map2 = (OSDMap) OSDParser.DeserializeJson(str); 321 map2 = (OSDMap) OSDParser.DeserializeJson(str);
321 } 322 }
322 catch (System.NullReferenceException) 323 catch (System.NullReferenceException)
323 { 324 {
324 //spurious litjson errors :P 325 //spurious litjson errors :P
diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs
index ae132c8..b572afc 100644
--- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Tests
183 183
184 resp = agentCircuitManager.AuthenticateSession(UUID.Random(), AgentId1, circuitcode1); 184 resp = agentCircuitManager.AuthenticateSession(UUID.Random(), AgentId1, circuitcode1);
185 Assert.That(!resp.Authorised); 185 Assert.That(!resp.Authorised);
186 186
187 resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode2); 187 resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode2);
188 Assert.That(!resp.Authorised); 188 Assert.That(!resp.Authorised);
189 189
diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs
index d8f17d0..daf8611 100644
--- a/OpenSim/Framework/Tests/AnimationTests.cs
+++ b/OpenSim/Framework/Tests/AnimationTests.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Framework.Tests
84 anim4.AnimID = anim2.AnimID; 84 anim4.AnimID = anim2.AnimID;
85 anim4.ObjectID = anim2.ObjectID; 85 anim4.ObjectID = anim2.ObjectID;
86 anim4.SequenceNum = anim2.SequenceNum; 86 anim4.SequenceNum = anim2.SequenceNum;
87 87
88 Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); 88 Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly.");
89 } 89 }
90 } 90 }
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs
index c709860..a92ff3c 100644
--- a/OpenSim/Framework/Tests/CacheTests.cs
+++ b/OpenSim/Framework/Tests/CacheTests.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Framework.Tests
70 Assert.That(citem == null, "Item should not be in Cache"); 70 Assert.That(citem == null, "Item should not be in Cache");
71 } 71 }
72 72
73 73
74 [Test] 74 [Test]
75 public void ExpireItemManually() 75 public void ExpireItemManually()
76 { 76 {
@@ -96,7 +96,7 @@ namespace OpenSim.Framework.Tests
96 cachedItem.Store(foo); 96 cachedItem.Store(foo);
97 cache.Store(cacheItemUUID.ToString(), cachedItem); 97 cache.Store(cacheItemUUID.ToString(), cachedItem);
98 cache.Clear(); 98 cache.Clear();
99 99
100 object citem = cache.Get(cacheItemUUID.ToString()); 100 object citem = cache.Get(cacheItemUUID.ToString());
101 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); 101 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
102 } 102 }
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs
index 3d5d1d2..5e84026 100644
--- a/OpenSim/Framework/Tests/LocationTest.cs
+++ b/OpenSim/Framework/Tests/LocationTest.cs
@@ -85,6 +85,6 @@ namespace OpenSim.Framework.Tests
85 Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test"); 85 Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
86 86
87 } 87 }
88 88
89 } 89 }
90} 90}
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index 3f0a031..bde7056 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -110,13 +110,14 @@ namespace OpenSim.Framework.Tests
110 && position2.Center == position1.Center 110 && position2.Center == position1.Center
111 && position2.RegionHandle == position1.RegionHandle 111 && position2.RegionHandle == position1.RegionHandle
112 && position2.Far == position1.Far 112 && position2.Far == position1.Far
113 113
114 ,"Copy From ChildAgentDataUpdate failed"); 114 ,"Copy From ChildAgentDataUpdate failed");
115 115
116 position2 = new AgentPosition(); 116 position2 = new AgentPosition();
117 117
118 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); 118 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
119 position2.Unpack(position1.Pack(), null); 119 EntityTransferContext ctx = new EntityTransferContext();
120 position2.Unpack(position1.Pack(ctx), null, ctx);
120 121
121 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); 122 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
122 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); 123 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
@@ -147,13 +148,13 @@ namespace OpenSim.Framework.Tests
147// string time = settings.LoadedCreationTime; 148// string time = settings.LoadedCreationTime;
148 149
149 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire"); 150 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
150 151
151 } 152 }
152 public void RegionSaveFired(RegionSettings settings) 153 public void RegionSaveFired(RegionSettings settings)
153 { 154 {
154 m_RegionSettingsOnSaveEventFired = true; 155 m_RegionSettingsOnSaveEventFired = true;
155 } 156 }
156 157
157 [Test] 158 [Test]
158 public void InventoryItemBaseConstructorTest01() 159 public void InventoryItemBaseConstructorTest01()
159 { 160 {
@@ -163,7 +164,7 @@ namespace OpenSim.Framework.Tests
163 164
164 UUID ItemID = UUID.Random(); 165 UUID ItemID = UUID.Random();
165 UUID OwnerID = UUID.Random(); 166 UUID OwnerID = UUID.Random();
166 167
167 InventoryItemBase b2 = new InventoryItemBase(ItemID); 168 InventoryItemBase b2 = new InventoryItemBase(ItemID);
168 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID"); 169 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
169 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero"); 170 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
@@ -218,12 +219,12 @@ namespace OpenSim.Framework.Tests
218 BannedHostNameMask = string.Empty, 219 BannedHostNameMask = string.Empty,
219 BannedUserID = bannedUserId} 220 BannedUserID = bannedUserId}
220 ); 221 );
221 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not."); 222 Assert.IsTrue(es.IsBanned(bannedUserId, 32), "User Should be banned but is not.");
222 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is."); 223 Assert.IsFalse(es.IsBanned(UUID.Zero, 32), "User Should not be banned but is.");
223 224
224 es.RemoveBan(bannedUserId); 225 es.RemoveBan(bannedUserId);
225 226
226 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is."); 227 Assert.IsFalse(es.IsBanned(bannedUserId, 32), "User Should not be banned but is.");
227 228
228 es.AddEstateManager(UUID.Zero); 229 es.AddEstateManager(UUID.Zero);
229 230
@@ -267,7 +268,7 @@ namespace OpenSim.Framework.Tests
267 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field."); 268 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
268 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field."); 269 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
269 } 270 }
270 271
271 [Test] 272 [Test]
272 public void AsssetBaseConstructorTest01() 273 public void AsssetBaseConstructorTest01()
273 { 274 {
@@ -303,6 +304,6 @@ namespace OpenSim.Framework.Tests
303 Culture.SetCurrentCulture(); 304 Culture.SetCurrentCulture();
304 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); 305 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
305 306
306 } 307 }
307 } 308 }
308} \ No newline at end of file 309}
diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
index 82e13e5..cc30fb9 100644
--- a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
+++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
@@ -127,9 +127,9 @@ namespace OpenSim.Framework.Tests
127 127
128 int[] nonprimes = { 128 int[] nonprimes = {
129 4, 6, 8, 10, 14, 16, 18, 22, 28, 30, 36, 40, 42, 46, 52, 58, 60, 66, 70, 72, 78, 82, 88, 129 4, 6, 8, 10, 14, 16, 18, 22, 28, 30, 36, 40, 42, 46, 52, 58, 60, 66, 70, 72, 78, 82, 88,
130 96, 366, 372, 378, 382, 388, 396, 400, 408, 418, 420, 430, 432, 438, 442, 448, 456, 460, 462, 130 96, 366, 372, 378, 382, 388, 396, 400, 408, 418, 420, 430, 432, 438, 442, 448, 456, 460, 462,
131 466, 478, 486, 490, 498, 502, 508, 856, 858, 862, 876, 880, 882, 886, 906, 910, 918, 928, 936, 131 466, 478, 486, 490, 498, 502, 508, 856, 858, 862, 876, 880, 882, 886, 906, 910, 918, 928, 936,
132 940, 946, 952, 966, 970, 976, 982, 990, 996, 1008, 1740, 1746, 1752, 1758, 4650, 4656, 4662, 132 940, 946, 952, 966, 970, 976, 982, 990, 996, 1008, 1740, 1746, 1752, 1758, 4650, 4656, 4662,
133 4672, 4678, 4690, 7740, 7752, 7756, 7758, 7788, 7792, 7816, 7822, 7828, 7840, 7852, 7866, 7872, 133 4672, 4678, 4690, 7740, 7752, 7756, 7758, 7788, 7792, 7816, 7822, 7828, 7840, 7852, 7866, 7872,
134 7876, 7878, 7882, 7900, 7906, 7918 134 7876, 7878, 7882, 7900, 7906, 7918
135 }; 135 };
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index cfe3139..b3d79ee 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -59,12 +59,12 @@ namespace OpenSim.Framework.Tests
59 Assert.That(Util.GetMagnitude(v2), 59 Assert.That(Util.GetMagnitude(v2),
60 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), 60 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance),
61 "Magnitude of vector was incorrect."); 61 "Magnitude of vector was incorrect.");
62 62/*
63 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; 63 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
64 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); 64 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
65 Assert.That(causesArgumentException, Is.True, 65 Assert.That(causesArgumentException, Is.True,
66 "Getting magnitude of null vector did not cause argument exception."); 66 "Getting magnitude of null vector did not cause argument exception.");
67 67*/
68 Vector3 expectedNormalizedVector = new Vector3(.577f, .577f, .577f); 68 Vector3 expectedNormalizedVector = new Vector3(.577f, .577f, .577f);
69 double expectedNormalizedMagnitude = 1; 69 double expectedNormalizedMagnitude = 1;
70 Vector3 normalizedVector = Util.GetNormalizedVector(v2); 70 Vector3 normalizedVector = Util.GetNormalizedVector(v2);
@@ -92,7 +92,7 @@ namespace OpenSim.Framework.Tests
92 Assert.That(Util.GetMagnitude(v2), 92 Assert.That(Util.GetMagnitude(v2),
93 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), 93 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance),
94 "Magnitude of vector was incorrect."); 94 "Magnitude of vector was incorrect.");
95 95/*
96 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; 96 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
97 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); 97 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
98 Assert.That(causesArgumentException, Is.True, 98 Assert.That(causesArgumentException, Is.True,
@@ -102,6 +102,7 @@ namespace OpenSim.Framework.Tests
102 causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); 102 causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
103 Assert.That(causesArgumentException, Is.True, 103 Assert.That(causesArgumentException, Is.True,
104 "Getting magnitude of null vector did not cause argument exception."); 104 "Getting magnitude of null vector did not cause argument exception.");
105*/
105 } 106 }
106 107
107 //Lets test a simple case of <0,0,0> and <-5,-5,-5> 108 //Lets test a simple case of <0,0,0> and <-5,-5,-5>
@@ -120,12 +121,12 @@ namespace OpenSim.Framework.Tests
120 Assert.That(Util.GetMagnitude(v2), 121 Assert.That(Util.GetMagnitude(v2),
121 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance), 122 new DoubleToleranceConstraint(expectedMagnitude, lowPrecisionTolerance),
122 "Magnitude of vector was incorrect."); 123 "Magnitude of vector was incorrect.");
123 124/*
124 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); }; 125 TestDelegate d = delegate() { Util.GetNormalizedVector(v1); };
125 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d); 126 bool causesArgumentException = TestHelpers.AssertThisDelegateCausesArgumentException(d);
126 Assert.That(causesArgumentException, Is.True, 127 Assert.That(causesArgumentException, Is.True,
127 "Getting magnitude of null vector did not cause argument exception."); 128 "Getting magnitude of null vector did not cause argument exception.");
128 129*/
129 Vector3 expectedNormalizedVector = new Vector3(-.577f, -.577f, -.577f); 130 Vector3 expectedNormalizedVector = new Vector3(-.577f, -.577f, -.577f);
130 double expectedNormalizedMagnitude = 1; 131 double expectedNormalizedMagnitude = 1;
131 Vector3 normalizedVector = Util.GetNormalizedVector(v2); 132 Vector3 normalizedVector = Util.GetNormalizedVector(v2);
@@ -232,7 +233,7 @@ namespace OpenSim.Framework.Tests
232 "application/vnd.ll.clothing", 233 "application/vnd.ll.clothing",
233 "application/vnd.ll.gesture" 234 "application/vnd.ll.gesture"
234 }; 235 };
235 236
236 for (int i=0;i<inventorytypes.Length;i++) 237 for (int i=0;i<inventorytypes.Length;i++)
237 { 238 {
238 Assert.AreEqual(invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]), 239 Assert.AreEqual(invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]),
diff --git a/OpenSim/Framework/ThrottleOutPacketType.cs b/OpenSim/Framework/ThrottleOutPacketType.cs
index ca4b126..87899f0 100644
--- a/OpenSim/Framework/ThrottleOutPacketType.cs
+++ b/OpenSim/Framework/ThrottleOutPacketType.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Framework
47 Texture = 5, 47 Texture = 5,
48 /// <summary>Non-texture assets</summary> 48 /// <summary>Non-texture assets</summary>
49 Asset = 6, 49 Asset = 6,
50
51 HighPriority = 128,
50 } 52 }
51 53
52 [Flags] 54 [Flags]
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index 266ccf0..d8fa629 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -159,12 +159,12 @@ namespace OpenSim.Framework
159 /// </summary> 159 /// </summary>
160 public virtual ulong HomeRegion 160 public virtual ulong HomeRegion
161 { 161 {
162 get 162 get
163 { 163 {
164 return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY)); 164 return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY));
165 // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize); 165 // return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize);
166 } 166 }
167 167
168 set 168 set
169 { 169 {
170 uint regionWorldLocX, regionWorldLocY; 170 uint regionWorldLocX, regionWorldLocY;
@@ -212,7 +212,7 @@ namespace OpenSim.Framework
212 get { return m_surname; } 212 get { return m_surname; }
213 set { m_surname = value; } 213 set { m_surname = value; }
214 } 214 }
215 215
216 /// <value> 216 /// <value>
217 /// The concatentation of the various name components. 217 /// The concatentation of the various name components.
218 /// </value> 218 /// </value>
diff --git a/OpenSim/Framework/UserProfiles.cs b/OpenSim/Framework/UserProfiles.cs
index 98ab651..7c6a6fe 100644
--- a/OpenSim/Framework/UserProfiles.cs
+++ b/OpenSim/Framework/UserProfiles.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using System.Collections.Generic;
31
30 32
31namespace OpenSim.Framework 33namespace OpenSim.Framework
32{ 34{
@@ -48,7 +50,7 @@ namespace OpenSim.Framework
48 public byte Flags = 0; 50 public byte Flags = 0;
49 public int Price = 0; 51 public int Price = 0;
50 } 52 }
51 53
52 public class UserProfileProperties 54 public class UserProfileProperties
53 { 55 {
54 public UUID UserId = UUID.Zero; 56 public UUID UserId = UUID.Zero;
@@ -66,7 +68,7 @@ namespace OpenSim.Framework
66 public UUID FirstLifeImageId = UUID.Zero; 68 public UUID FirstLifeImageId = UUID.Zero;
67 public string FirstLifeText = string.Empty; 69 public string FirstLifeText = string.Empty;
68 } 70 }
69 71
70 public class UserProfilePick 72 public class UserProfilePick
71 { 73 {
72 public UUID PickId = UUID.Zero; 74 public UUID PickId = UUID.Zero;
@@ -84,7 +86,7 @@ namespace OpenSim.Framework
84 public int SortOrder = 0; 86 public int SortOrder = 0;
85 public bool Enabled = false; 87 public bool Enabled = false;
86 } 88 }
87 89
88 public class UserProfileNotes 90 public class UserProfileNotes
89 { 91 {
90 public UUID UserId; 92 public UUID UserId;
@@ -99,7 +101,7 @@ namespace OpenSim.Framework
99 public bool Visible = false; 101 public bool Visible = false;
100 public string EMail = string.Empty; 102 public string EMail = string.Empty;
101 } 103 }
102 104
103 public class UserAccountProperties 105 public class UserAccountProperties
104 { 106 {
105 public string EmailAddress = string.Empty; 107 public string EmailAddress = string.Empty;
@@ -108,13 +110,13 @@ namespace OpenSim.Framework
108 public string Password = string.Empty; 110 public string Password = string.Empty;
109 public string UserId = string.Empty; 111 public string UserId = string.Empty;
110 } 112 }
111 113
112 public class UserAccountAuth 114 public class UserAccountAuth
113 { 115 {
114 public string UserId = UUID.Zero.ToString(); 116 public string UserId = UUID.Zero.ToString();
115 public string Password = string.Empty; 117 public string Password = string.Empty;
116 } 118 }
117 119
118 public class UserAppData 120 public class UserAppData
119 { 121 {
120 public string TagId = string.Empty; 122 public string TagId = string.Empty;
@@ -122,5 +124,18 @@ namespace OpenSim.Framework
122 public string UserId = UUID.Zero.ToString(); 124 public string UserId = UUID.Zero.ToString();
123 public string DataVal = string.Empty; 125 public string DataVal = string.Empty;
124 } 126 }
127
128 public class UserProfileCacheEntry
129 {
130 public Dictionary<UUID, string> picksList;
131 public Dictionary<UUID, UserProfilePick> picks;
132 public Dictionary<UUID, string> classifiedsLists;
133 public Dictionary<UUID, UserClassifiedAdd> classifieds;
134 public UserProfileProperties props;
135 public string born;
136 public byte[] membershipType;
137 public uint flags;
138 public HashSet<IClientAPI> ClientsWaitingProps;
139 }
125} 140}
126 141
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index b5c3e75..7093010 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -59,17 +59,41 @@ namespace OpenSim.Framework
59{ 59{
60 [Flags] 60 [Flags]
61 public enum PermissionMask : uint 61 public enum PermissionMask : uint
62 { 62 {
63 None = 0, 63 None = 0,
64 Transfer = 1 << 13, 64
65 Modify = 1 << 14, 65 // folded perms
66 Copy = 1 << 15, 66 FoldedTransfer = 1,
67 Export = 1 << 16, 67 FoldedModify = 1 << 1,
68 Move = 1 << 19, 68 FoldedCopy = 1 << 2,
69 Damage = 1 << 20, 69 FoldedExport = 1 << 3,
70
71 // DO NOT USE THIS FOR NEW WORK. IT IS DEPRECATED AND
72 // EXISTS ONLY TO REACT TO EXISTING OBJECTS HAVING IT.
73 // NEW CODE SHOULD NEVER SET THIS BIT!
74 // Use InventoryItemFlags.ObjectSlamPerm in the Flags field of
75 // this legacy slam bit. It comes from prior incomplete
76 // understanding of the code and the prohibition on
77 // reading viewer code that used to be in place.
78 Slam = (1 << 4),
79
80 FoldedMask = 0x0f,
81
82 FoldingShift = 13 , // number of bit shifts from normal perm to folded or back (same as Transfer shift below)
83 // when doing as a block
84
85 Transfer = 1 << 13, // 0x02000
86 Modify = 1 << 14, // 0x04000
87 Copy = 1 << 15, // 0x08000
88 Export = 1 << 16, // 0x10000
89 Move = 1 << 19, // 0x80000
90 Damage = 1 << 20, // 0x100000 does not seem to be in use
70 // All does not contain Export, which is special and must be 91 // All does not contain Export, which is special and must be
71 // explicitly given 92 // explicitly given
72 All = (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19) 93 All = 0x8e000,
94 AllAndExport = 0x9e000,
95 AllEffective = 0x9e000,
96 UnfoldedMask = 0x1e000
73 } 97 }
74 98
75 /// <summary> 99 /// <summary>
@@ -103,7 +127,7 @@ namespace OpenSim.Framework
103 public STPStartInfo STPStartInfo { get; set; } 127 public STPStartInfo STPStartInfo { get; set; }
104 public WIGStartInfo WIGStartInfo { get; set; } 128 public WIGStartInfo WIGStartInfo { get; set; }
105 public bool IsIdle { get; set; } 129 public bool IsIdle { get; set; }
106 public bool IsShuttingDown { get; set; } 130 public bool IsShuttingDown { get; set; }
107 public int MaxThreads { get; set; } 131 public int MaxThreads { get; set; }
108 public int MinThreads { get; set; } 132 public int MinThreads { get; set; }
109 public int InUseThreads { get; set; } 133 public int InUseThreads { get; set; }
@@ -131,10 +155,16 @@ namespace OpenSim.Framework
131 155
132 public static readonly int MAX_THREADPOOL_LEVEL = 3; 156 public static readonly int MAX_THREADPOOL_LEVEL = 3;
133 157
158 public static double TimeStampClockPeriodMS;
159 public static double TimeStampClockPeriod;
160
134 static Util() 161 static Util()
135 { 162 {
136 LogThreadPool = 0; 163 LogThreadPool = 0;
137 LogOverloads = true; 164 LogOverloads = true;
165 TimeStampClockPeriod = 1.0D/ (double)Stopwatch.Frequency;
166 TimeStampClockPeriodMS = 1e3 * TimeStampClockPeriod;
167 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero));
138 } 168 }
139 169
140 private static uint nextXferID = 5000; 170 private static uint nextXferID = 5000;
@@ -217,7 +247,7 @@ namespace OpenSim.Framework
217 public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false); 247 public static Encoding UTF8NoBomEncoding = new UTF8Encoding(false);
218 248
219 /// <value> 249 /// <value>
220 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) 250 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
221 /// </value> 251 /// </value>
222 public static UUID BLANK_TEXTURE_UUID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); 252 public static UUID BLANK_TEXTURE_UUID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f");
223 253
@@ -267,14 +297,12 @@ namespace OpenSim.Framework
267 /// </summary> 297 /// </summary>
268 /// <param name="a">A 3d vector</param> 298 /// <param name="a">A 3d vector</param>
269 /// <returns>A new vector which is normalized form of the vector</returns> 299 /// <returns>A new vector which is normalized form of the vector</returns>
270 /// <remarks>The vector paramater cannot be <0,0,0></remarks> 300
271 public static Vector3 GetNormalizedVector(Vector3 a) 301 public static Vector3 GetNormalizedVector(Vector3 a)
272 { 302 {
273 if (IsZeroVector(a)) 303 Vector3 v = new Vector3(a.X, a.Y, a.Z);
274 throw new ArgumentException("Vector paramater cannot be a zero vector."); 304 v.Normalize();
275 305 return v;
276 float Mag = (float) GetMagnitude(a);
277 return new Vector3(a.X / Mag, a.Y / Mag, a.Z / Mag);
278 } 306 }
279 307
280 /// <summary> 308 /// <summary>
@@ -357,47 +385,185 @@ namespace OpenSim.Framework
357 return Utils.UIntsToLong(X, Y); 385 return Utils.UIntsToLong(X, Y);
358 } 386 }
359 387
360 // Regions are identified with a 'handle' made up of its region coordinates packed into a ulong. 388 // Regions are identified with a 'handle' made up of its world coordinates packed into a ulong.
361 // Several places rely on the ability to extract a region's location from its handle. 389 // Region handles are based on the coordinate of the region corner with lower X and Y
362 // Note the location is in 'world coordinates' (see below). 390 // var regions need more work than this to get that right corner from a generic world position
363 // Region handles are based on the lowest coordinate of the region so trim the passed x,y to be the regions 0,0. 391 // this corner must be on a grid point
364 public static ulong RegionWorldLocToHandle(uint X, uint Y) 392 public static ulong RegionWorldLocToHandle(uint X, uint Y)
365 { 393 {
366 return Utils.UIntsToLong(X, Y); 394 ulong handle = X & 0xffffff00; // make sure it matchs grid coord points.
395 handle <<= 32; // to higher half
396 handle |= (Y & 0xffffff00);
397 return handle;
367 } 398 }
368 399
369 public static ulong RegionLocToHandle(uint X, uint Y) 400 public static ulong RegionGridLocToHandle(uint X, uint Y)
370 { 401 {
371 return Utils.UIntsToLong(Util.RegionToWorldLoc(X), Util.RegionToWorldLoc(Y)); 402 ulong handle = X;
403 handle <<= 40; // shift to higher half and mult by 256)
404 handle |= (Y << 8); // mult by 256)
405 return handle;
372 } 406 }
373 407
374 public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y) 408 public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y)
375 { 409 {
376 X = (uint)(handle >> 32); 410 X = (uint)(handle >> 32);
377 Y = (uint)(handle & (ulong)uint.MaxValue); 411 Y = (uint)(handle & 0xfffffffful);
378 } 412 }
379 413
380 public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y) 414 public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y)
381 { 415 {
382 uint worldX, worldY; 416 X = (uint)(handle >> 40) & 0x00ffffffu; // bring from higher half, divide by 256 and clean
383 RegionHandleToWorldLoc(handle, out worldX, out worldY); 417 Y = (uint)(handle >> 8) & 0x00ffffffu; // divide by 256 and clean
384 X = WorldToRegionLoc(worldX); 418 // if you trust the uint cast then the clean can be removed.
385 Y = WorldToRegionLoc(worldY);
386 } 419 }
387 420
388 // A region location can be 'world coordinates' (meters from zero) or 'region coordinates' 421 // A region location can be 'world coordinates' (meters) or 'region grid coordinates'
389 // (number of regions from zero). This measurement of regions relies on the legacy 256 region size. 422 // grid coordinates have a fixed step of 256m as defined by viewers
390 // These routines exist to make what is being converted explicit so the next person knows what was meant.
391 // Convert a region's 'world coordinate' to its 'region coordinate'.
392 public static uint WorldToRegionLoc(uint worldCoord) 423 public static uint WorldToRegionLoc(uint worldCoord)
393 { 424 {
394 return worldCoord / Constants.RegionSize; 425 return worldCoord >> 8;
395 } 426 }
396 427
397 // Convert a region's 'region coordinate' to its 'world coordinate'. 428 // Convert a region's 'region grid coordinate' to its 'world coordinate'.
398 public static uint RegionToWorldLoc(uint regionCoord) 429 public static uint RegionToWorldLoc(uint regionCoord)
399 { 430 {
400 return regionCoord * Constants.RegionSize; 431 return regionCoord << 8;
432 }
433
434
435 public static bool checkServiceURI(string uristr, out string serviceURI)
436 {
437 serviceURI = string.Empty;
438 try
439 {
440 Uri uri = new Uri(uristr);
441 serviceURI = uri.AbsoluteUri;
442 if(uri.Port == 80)
443 serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":80/";
444 else if(uri.Port == 443)
445 serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":443/";
446 return true;
447 }
448 catch
449 {
450 serviceURI = string.Empty;
451 }
452 return false;
453 }
454
455 public static bool buildHGRegionURI(string inputName, out string serverURI, out string regionName)
456 {
457 serverURI = string.Empty;
458 regionName = string.Empty;
459
460 inputName = inputName.Trim();
461
462 if (!inputName.StartsWith("http") && !inputName.StartsWith("https"))
463 {
464 // Formats: grid.example.com:8002:region name
465 // grid.example.com:region name
466 // grid.example.com:8002
467 // grid.example.com
468
469 string host;
470 uint port = 80;
471
472 string[] parts = inputName.Split(new char[] { ':' });
473 int indx;
474 if(parts.Length == 0)
475 return false;
476 if (parts.Length == 1)
477 {
478 indx = inputName.IndexOf('/');
479 if (indx < 0)
480 serverURI = "http://"+ inputName + "/";
481 else
482 {
483 serverURI = "http://"+ inputName.Substring(0,indx + 1);
484 if(indx + 2 < inputName.Length)
485 regionName = inputName.Substring(indx + 1);
486 }
487 }
488 else
489 {
490 host = parts[0];
491
492 if (parts.Length >= 2)
493 {
494 indx = parts[1].IndexOf('/');
495 if(indx < 0)
496 {
497 // If it's a number then assume it's a port. Otherwise, it's a region name.
498 if (!UInt32.TryParse(parts[1], out port))
499 {
500 port = 80;
501 regionName = parts[1];
502 }
503 }
504 else
505 {
506 string portstr = parts[1].Substring(0, indx);
507 if(indx + 2 < parts[1].Length)
508 regionName = parts[1].Substring(indx + 1);
509 if (!UInt32.TryParse(portstr, out port))
510 port = 80;
511 }
512 }
513 // always take the last one
514 if (parts.Length >= 3)
515 {
516 regionName = parts[2];
517 }
518
519 serverURI = "http://"+ host +":"+ port.ToString() + "/";
520 }
521 }
522 else
523 {
524 // Formats: http://grid.example.com region name
525 // http://grid.example.com "region name"
526 // http://grid.example.com
527
528 string[] parts = inputName.Split(new char[] { ' ' });
529
530 if (parts.Length == 0)
531 return false;
532
533 serverURI = parts[0];
534
535 int indx = serverURI.LastIndexOf('/');
536 if(indx > 10)
537 {
538 if(indx + 2 < inputName.Length)
539 regionName = inputName.Substring(indx + 1);
540 serverURI = inputName.Substring(0, indx + 1);
541 }
542 else if (parts.Length >= 2)
543 {
544 regionName = inputName.Substring(serverURI.Length);
545 }
546 }
547
548 // use better code for sanity check
549 Uri uri;
550 try
551 {
552 uri = new Uri(serverURI);
553 }
554 catch
555 {
556 return false;
557 }
558
559 if(!string.IsNullOrEmpty(regionName))
560 regionName = regionName.Trim(new char[] { '"', ' ' });
561 serverURI = uri.AbsoluteUri;
562 if(uri.Port == 80)
563 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/";
564 else if(uri.Port == 443)
565 serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/";
566 return true;
401 } 567 }
402 568
403 public static T Clamp<T>(T x, T min, T max) 569 public static T Clamp<T>(T x, T min, T max)
@@ -505,6 +671,7 @@ namespace OpenSim.Framework
505 public static string GetFormattedXml(string rawXml) 671 public static string GetFormattedXml(string rawXml)
506 { 672 {
507 XmlDocument xd = new XmlDocument(); 673 XmlDocument xd = new XmlDocument();
674 xd.XmlResolver=null;
508 xd.LoadXml(rawXml); 675 xd.LoadXml(rawXml);
509 676
510 StringBuilder sb = new StringBuilder(); 677 StringBuilder sb = new StringBuilder();
@@ -641,19 +808,25 @@ namespace OpenSim.Framework
641 /// </summary> 808 /// </summary>
642 /// <param name="data"></param> 809 /// <param name="data"></param>
643 /// <returns></returns> 810 /// <returns></returns>
811
644 public static string Md5Hash(string data) 812 public static string Md5Hash(string data)
645 { 813 {
646 byte[] dataMd5 = ComputeMD5Hash(data); 814 return Md5Hash(data, Encoding.Default);
815 }
816
817 public static string Md5Hash(string data, Encoding encoding)
818 {
819 byte[] dataMd5 = ComputeMD5Hash(data, encoding);
647 StringBuilder sb = new StringBuilder(); 820 StringBuilder sb = new StringBuilder();
648 for (int i = 0; i < dataMd5.Length; i++) 821 for (int i = 0; i < dataMd5.Length; i++)
649 sb.AppendFormat("{0:x2}", dataMd5[i]); 822 sb.AppendFormat("{0:x2}", dataMd5[i]);
650 return sb.ToString(); 823 return sb.ToString();
651 } 824 }
652 825
653 private static byte[] ComputeMD5Hash(string data) 826 private static byte[] ComputeMD5Hash(string data, Encoding encoding)
654 { 827 {
655 MD5 md5 = MD5.Create(); 828 MD5 md5 = MD5.Create();
656 return md5.ComputeHash(Encoding.Default.GetBytes(data)); 829 return md5.ComputeHash(encoding.GetBytes(data));
657 } 830 }
658 831
659 /// <summary> 832 /// <summary>
@@ -661,6 +834,12 @@ namespace OpenSim.Framework
661 /// </summary> 834 /// </summary>
662 /// <param name="data"></param> 835 /// <param name="data"></param>
663 /// <returns></returns> 836 /// <returns></returns>
837
838 public static string SHA1Hash(string data, Encoding enc)
839 {
840 return SHA1Hash(enc.GetBytes(data));
841 }
842
664 public static string SHA1Hash(string data) 843 public static string SHA1Hash(string data)
665 { 844 {
666 return SHA1Hash(Encoding.Default.GetBytes(data)); 845 return SHA1Hash(Encoding.Default.GetBytes(data));
@@ -679,8 +858,10 @@ namespace OpenSim.Framework
679 858
680 private static byte[] ComputeSHA1Hash(byte[] src) 859 private static byte[] ComputeSHA1Hash(byte[] src)
681 { 860 {
682 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); 861 byte[] ret;
683 return SHA1.ComputeHash(src); 862 using(SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider())
863 ret = SHA1.ComputeHash(src);
864 return ret;
684 } 865 }
685 866
686 public static int fast_distance2d(int x, int y) 867 public static int fast_distance2d(int x, int y)
@@ -713,18 +894,27 @@ namespace OpenSim.Framework
713 /// <param name="newx">New region x-coord</param> 894 /// <param name="newx">New region x-coord</param>
714 /// <param name="oldy">Old region y-coord</param> 895 /// <param name="oldy">Old region y-coord</param>
715 /// <param name="newy">New region y-coord</param> 896 /// <param name="newy">New region y-coord</param>
716 /// <returns></returns> 897 /// <returns></returns>
717 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy) 898 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy,
718 { 899 int oldsizex, int oldsizey, int newsizex, int newsizey)
719 int dd = (int)((drawdist + Constants.RegionSize - 1) / Constants.RegionSize); 900 {
720 901 // we still need to make sure we see new region 1stNeighbors
721 int startX = (int)oldx - dd; 902 drawdist--;
722 int startY = (int)oldy - dd; 903 oldx *= Constants.RegionSize;
904 newx *= Constants.RegionSize;
905 if (oldx + oldsizex + drawdist < newx)
906 return true;
907 if (newx + newsizex + drawdist < oldx)
908 return true;
723 909
724 int endX = (int)oldx + dd; 910 oldy *= Constants.RegionSize;
725 int endY = (int)oldy + dd; 911 newy *= Constants.RegionSize;
912 if (oldy + oldsizey + drawdist < newy)
913 return true;
914 if (newy + newsizey + drawdist < oldy)
915 return true;
726 916
727 return (newx < startX || endX < newx || newy < startY || endY < newy); 917 return false;
728 } 918 }
729 919
730 public static string FieldToString(byte[] bytes) 920 public static string FieldToString(byte[] bytes)
@@ -804,6 +994,18 @@ namespace OpenSim.Framework
804 return output.ToString(); 994 return output.ToString();
805 } 995 }
806 996
997 private static ExpiringCache<string,IPAddress> dnscache = new ExpiringCache<string, IPAddress>();
998
999 /// <summary>
1000 /// Converts a URL to a IPAddress
1001 /// </summary>
1002 /// <param name="url">URL Standard Format</param>
1003 /// <returns>A resolved IP Address</returns>
1004 public static IPAddress GetHostFromURL(string url)
1005 {
1006 return GetHostFromDNS(url.Split(new char[] {'/', ':'})[3]);
1007 }
1008
807 /// <summary> 1009 /// <summary>
808 /// Returns a IP address from a specified DNS, favouring IPv4 addresses. 1010 /// Returns a IP address from a specified DNS, favouring IPv4 addresses.
809 /// </summary> 1011 /// </summary>
@@ -811,38 +1013,128 @@ namespace OpenSim.Framework
811 /// <returns>An IP address, or null</returns> 1013 /// <returns>An IP address, or null</returns>
812 public static IPAddress GetHostFromDNS(string dnsAddress) 1014 public static IPAddress GetHostFromDNS(string dnsAddress)
813 { 1015 {
814 // Is it already a valid IP? No need to look it up. 1016 if(String.IsNullOrWhiteSpace(dnsAddress))
815 IPAddress ipa; 1017 return null;
816 if (IPAddress.TryParse(dnsAddress, out ipa))
817 return ipa;
818 1018
819 IPAddress[] hosts = null; 1019 IPAddress ia = null;
1020 if(dnscache.TryGetValue(dnsAddress, out ia) && ia != null)
1021 {
1022 dnscache.AddOrUpdate(dnsAddress, ia, 300);
1023 return ia;
1024 }
820 1025
821 // Not an IP, lookup required 1026 ia = null;
1027 // If it is already an IP, don't let GetHostEntry see it
1028 if (IPAddress.TryParse(dnsAddress, out ia) && ia != null)
1029 {
1030 if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any))
1031 return null;
1032 dnscache.AddOrUpdate(dnsAddress, ia, 300);
1033 return ia;
1034 }
1035
1036 IPHostEntry IPH;
822 try 1037 try
823 { 1038 {
824 hosts = Dns.GetHostEntry(dnsAddress).AddressList; 1039 IPH = Dns.GetHostEntry(dnsAddress);
825 } 1040 }
826 catch (Exception e) 1041 catch // (SocketException e)
1042 {
1043 return null;
1044 }
1045
1046 if(IPH == null || IPH.AddressList.Length == 0)
1047 return null;
1048
1049 ia = null;
1050 foreach (IPAddress Adr in IPH.AddressList)
827 { 1051 {
828 m_log.WarnFormat("[UTIL]: An error occurred while resolving host name {0}, {1}", dnsAddress, e); 1052 if (ia == null)
1053 ia = Adr;
829 1054
830 // Still going to throw the exception on for now, since this was what was happening in the first place 1055 if (Adr.AddressFamily == AddressFamily.InterNetwork)
831 throw e; 1056 {
1057 ia = Adr;
1058 break;
1059 }
832 } 1060 }
1061 if(ia != null)
1062 dnscache.AddOrUpdate(dnsAddress, ia, 300);
1063 return ia;
1064 }
833 1065
834 foreach (IPAddress host in hosts) 1066 public static IPEndPoint getEndPoint(IPAddress ia, int port)
1067 {
1068 if(ia == null)
1069 return null;
1070
1071 IPEndPoint newEP = null;
1072 try
1073 {
1074 newEP = new IPEndPoint(ia, port);
1075 }
1076 catch
1077 {
1078 newEP = null;
1079 }
1080 return newEP;
1081 }
1082
1083 public static IPEndPoint getEndPoint(string hostname, int port)
1084 {
1085 if(String.IsNullOrWhiteSpace(hostname))
1086 return null;
1087
1088 IPAddress ia = null;
1089 if(dnscache.TryGetValue(hostname, out ia) && ia != null)
1090 {
1091 dnscache.AddOrUpdate(hostname, ia, 300);
1092 return getEndPoint(ia, port);
1093 }
1094
1095 ia = null;
1096
1097 // If it is already an IP, don't let GetHostEntry see it
1098 if (IPAddress.TryParse(hostname, out ia) && ia != null)
1099 {
1100 if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any))
1101 return null;
1102
1103 dnscache.AddOrUpdate(hostname, ia, 300);
1104 return getEndPoint(ia, port);
1105 }
1106
1107
1108 IPHostEntry IPH;
1109 try
1110 {
1111 IPH = Dns.GetHostEntry(hostname);
1112 }
1113 catch // (SocketException e)
1114 {
1115 return null;
1116 }
1117
1118 if(IPH == null || IPH.AddressList.Length == 0)
1119 return null;
1120
1121 ia = null;
1122 foreach (IPAddress Adr in IPH.AddressList)
835 { 1123 {
836 if (host.AddressFamily == AddressFamily.InterNetwork) 1124 if (ia == null)
1125 ia = Adr;
1126
1127 if (Adr.AddressFamily == AddressFamily.InterNetwork)
837 { 1128 {
838 return host; 1129 ia = Adr;
1130 break;
839 } 1131 }
840 } 1132 }
841 1133
842 if (hosts.Length > 0) 1134 if(ia != null)
843 return hosts[0]; 1135 dnscache.AddOrUpdate(hostname, ia, 300);
844 1136
845 return null; 1137 return getEndPoint(ia,port);
846 } 1138 }
847 1139
848 public static Uri GetURI(string protocol, string hostname, int port, string path) 1140 public static Uri GetURI(string protocol, string hostname, int port, string path)
@@ -987,7 +1279,7 @@ namespace OpenSim.Framework
987 1279
988 public static string configDir() 1280 public static string configDir()
989 { 1281 {
990 return "../config"; 1282 return ".";
991 } 1283 }
992 1284
993 public static string dataDir() 1285 public static string dataDir()
@@ -999,13 +1291,26 @@ namespace OpenSim.Framework
999 { 1291 {
1000 foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) 1292 foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
1001 { 1293 {
1002 if (appender is FileAppender) 1294 if (appender is FileAppender && appender.Name == "LogFileAppender")
1003 { 1295 {
1004 return ((FileAppender)appender).File; 1296 return ((FileAppender)appender).File;
1005 } 1297 }
1006 } 1298 }
1007 1299
1008 return "../logs/OpenSim.log"; 1300 return "./OpenSim.log";
1301 }
1302
1303 public static string statsLogFile()
1304 {
1305 foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
1306 {
1307 if (appender is FileAppender && appender.Name == "StatsLogFileAppender")
1308 {
1309 return ((FileAppender)appender).File;
1310 }
1311 }
1312
1313 return "./OpenSimStats.log";
1009 } 1314 }
1010 1315
1011 public static string logDir() 1316 public static string logDir()
@@ -1065,9 +1370,28 @@ namespace OpenSim.Framework
1065 } 1370 }
1066 } 1371 }
1067 1372
1373 public static string GetConfigVarWithDefaultSection(IConfigSource config, string varname, string section)
1374 {
1375 // First, check the Startup section, the default section
1376 IConfig cnf = config.Configs["Startup"];
1377 if (cnf == null)
1378 return string.Empty;
1379 string val = cnf.GetString(varname, string.Empty);
1380
1381 // Then check for an overwrite of the default in the given section
1382 if (!string.IsNullOrEmpty(section))
1383 {
1384 cnf = config.Configs[section];
1385 if (cnf != null)
1386 val = cnf.GetString(varname, val);
1387 }
1388
1389 return val;
1390 }
1391
1068 /// <summary> 1392 /// <summary>
1069 /// Gets the value of a configuration variable by looking into 1393 /// Gets the value of a configuration variable by looking into
1070 /// multiple sections in order. The latter sections overwrite 1394 /// multiple sections in order. The latter sections overwrite
1071 /// any values previously found. 1395 /// any values previously found.
1072 /// </summary> 1396 /// </summary>
1073 /// <typeparam name="T">Type of the variable</typeparam> 1397 /// <typeparam name="T">Type of the variable</typeparam>
@@ -1082,7 +1406,7 @@ namespace OpenSim.Framework
1082 1406
1083 /// <summary> 1407 /// <summary>
1084 /// Gets the value of a configuration variable by looking into 1408 /// Gets the value of a configuration variable by looking into
1085 /// multiple sections in order. The latter sections overwrite 1409 /// multiple sections in order. The latter sections overwrite
1086 /// any values previously found. 1410 /// any values previously found.
1087 /// </summary> 1411 /// </summary>
1088 /// <remarks> 1412 /// <remarks>
@@ -1138,7 +1462,7 @@ namespace OpenSim.Framework
1138 ConfigSource.ExpandKeyValues(); 1462 ConfigSource.ExpandKeyValues();
1139 } 1463 }
1140 } 1464 }
1141 1465
1142 public static T ReadSettingsFromIniFile<T>(IConfig config, T settingsClass) 1466 public static T ReadSettingsFromIniFile<T>(IConfig config, T settingsClass)
1143 { 1467 {
1144 Type settingsType = settingsClass.GetType(); 1468 Type settingsType = settingsClass.GetType();
@@ -1249,7 +1573,7 @@ namespace OpenSim.Framework
1249 1573
1250 if (File.Exists(configFile)) 1574 if (File.Exists(configFile))
1251 { 1575 {
1252 // Merge 1576 // Merge
1253 config.Merge(new IniConfigSource(configFile)); 1577 config.Merge(new IniConfigSource(configFile));
1254 config.ExpandKeyValues(); 1578 config.ExpandKeyValues();
1255 configFilePath = configFile; 1579 configFilePath = configFile;
@@ -1388,6 +1712,46 @@ namespace OpenSim.Framework
1388 return ret; 1712 return ret;
1389 } 1713 }
1390 1714
1715 public static string Compress(string text)
1716 {
1717 byte[] buffer = Util.UTF8.GetBytes(text);
1718 MemoryStream memory = new MemoryStream();
1719 using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true))
1720 {
1721 compressor.Write(buffer, 0, buffer.Length);
1722 }
1723
1724 memory.Position = 0;
1725
1726 byte[] compressed = new byte[memory.Length];
1727 memory.Read(compressed, 0, compressed.Length);
1728
1729 byte[] compressedBuffer = new byte[compressed.Length + 4];
1730 Buffer.BlockCopy(compressed, 0, compressedBuffer, 4, compressed.Length);
1731 Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, compressedBuffer, 0, 4);
1732 return Convert.ToBase64String(compressedBuffer);
1733 }
1734
1735 public static string Decompress(string compressedText)
1736 {
1737 byte[] compressedBuffer = Convert.FromBase64String(compressedText);
1738 using (MemoryStream memory = new MemoryStream())
1739 {
1740 int msgLength = BitConverter.ToInt32(compressedBuffer, 0);
1741 memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4);
1742
1743 byte[] buffer = new byte[msgLength];
1744
1745 memory.Position = 0;
1746 using (GZipStream decompressor = new GZipStream(memory, CompressionMode.Decompress))
1747 {
1748 decompressor.Read(buffer, 0, buffer.Length);
1749 }
1750
1751 return Util.UTF8.GetString(buffer);
1752 }
1753 }
1754
1391 /// <summary> 1755 /// <summary>
1392 /// Copy data from one stream to another, leaving the read position of both streams at the beginning. 1756 /// Copy data from one stream to another, leaving the read position of both streams at the beginning.
1393 /// </summary> 1757 /// </summary>
@@ -1405,7 +1769,7 @@ namespace OpenSim.Framework
1405 const int readSize = 256; 1769 const int readSize = 256;
1406 byte[] buffer = new byte[readSize]; 1770 byte[] buffer = new byte[readSize];
1407 MemoryStream ms = new MemoryStream(); 1771 MemoryStream ms = new MemoryStream();
1408 1772
1409 int count = inputStream.Read(buffer, 0, readSize); 1773 int count = inputStream.Read(buffer, 0, readSize);
1410 1774
1411 while (count > 0) 1775 while (count > 0)
@@ -1485,12 +1849,16 @@ namespace OpenSim.Framework
1485 return new UUID(bytes, 0); 1849 return new UUID(bytes, 0);
1486 } 1850 }
1487 1851
1488 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y) 1852 public static bool ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y)
1489 { 1853 {
1490 byte[] bytes = parcelID.GetBytes(); 1854 byte[] bytes = parcelID.GetBytes();
1491 regionHandle = Utils.BytesToUInt64(bytes); 1855 regionHandle = Utils.BytesToUInt64(bytes);
1492 x = Utils.BytesToUInt(bytes, 8) & 0xffff; 1856 x = Utils.BytesToUInt(bytes, 8) & 0xffff;
1493 y = Utils.BytesToUInt(bytes, 12) & 0xffff; 1857 y = Utils.BytesToUInt(bytes, 12) & 0xffff;
1858 // validation may fail, just reducing the odds of using a real UUID as encoded parcel
1859 return ( bytes[0] == 0 && bytes[4] == 0 && // handler x,y multiples of 256
1860 bytes[9] < 64 && bytes[13] < 64 && // positions < 16km
1861 bytes[14] == 0 && bytes[15] == 0);
1494 } 1862 }
1495 1863
1496 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z) 1864 public static void ParseFakeParcelID(UUID parcelID, out ulong regionHandle, out uint x, out uint y, out uint z)
@@ -1513,7 +1881,7 @@ namespace OpenSim.Framework
1513 x += rx; 1881 x += rx;
1514 y += ry; 1882 y += ry;
1515 } 1883 }
1516 1884
1517 /// <summary> 1885 /// <summary>
1518 /// Get operating system information if available. Returns only the first 45 characters of information 1886 /// Get operating system information if available. Returns only the first 45 characters of information
1519 /// </summary> 1887 /// </summary>
@@ -1524,20 +1892,20 @@ namespace OpenSim.Framework
1524 { 1892 {
1525 string os = String.Empty; 1893 string os = String.Empty;
1526 1894
1527 if (Environment.OSVersion.Platform != PlatformID.Unix) 1895// if (Environment.OSVersion.Platform != PlatformID.Unix)
1528 { 1896// {
1529 os = Environment.OSVersion.ToString(); 1897// os = Environment.OSVersion.ToString();
1530 } 1898// }
1531 else 1899// else
1532 { 1900// {
1533 os = ReadEtcIssue(); 1901// os = ReadEtcIssue();
1534 } 1902// }
1535 1903//
1536 if (os.Length > 45) 1904// if (os.Length > 45)
1537 { 1905// {
1538 os = os.Substring(0, 45); 1906// os = os.Substring(0, 45);
1539 } 1907// }
1540 1908
1541 return os; 1909 return os;
1542 } 1910 }
1543 1911
@@ -1579,6 +1947,8 @@ namespace OpenSim.Framework
1579 1947
1580 // hide the password in the connection string 1948 // hide the password in the connection string
1581 passPosition = connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); 1949 passPosition = connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase);
1950 if (passPosition == -1)
1951 return connectionString;
1582 passPosition = connectionString.IndexOf("=", passPosition); 1952 passPosition = connectionString.IndexOf("=", passPosition);
1583 if (passPosition < connectionString.Length) 1953 if (passPosition < connectionString.Length)
1584 passPosition += 1; 1954 passPosition += 1;
@@ -1645,7 +2015,7 @@ namespace OpenSim.Framework
1645 2015
1646 public static Guid GetHashGuid(string data, string salt) 2016 public static Guid GetHashGuid(string data, string salt)
1647 { 2017 {
1648 byte[] hash = ComputeMD5Hash(data + salt); 2018 byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
1649 2019
1650 //string s = BitConverter.ToString(hash); 2020 //string s = BitConverter.ToString(hash);
1651 2021
@@ -1747,7 +2117,7 @@ namespace OpenSim.Framework
1747 vol = vcomps[0]; 2117 vol = vcomps[0];
1748 } 2118 }
1749 } 2119 }
1750 2120
1751 string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries); 2121 string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries);
1752 2122
1753 // Glob 2123 // Glob
@@ -1792,6 +2162,32 @@ namespace OpenSim.Framework
1792 return found.ToArray(); 2162 return found.ToArray();
1793 } 2163 }
1794 2164
2165 public static string ServerURI(string uri)
2166 {
2167 if (uri == string.Empty)
2168 return string.Empty;
2169
2170 // Get rid of eventual slashes at the end
2171 uri = uri.TrimEnd('/');
2172
2173 IPAddress ipaddr1 = null;
2174 string port1 = "";
2175 try
2176 {
2177 ipaddr1 = Util.GetHostFromURL(uri);
2178 }
2179 catch { }
2180
2181 try
2182 {
2183 port1 = uri.Split(new char[] { ':' })[2];
2184 }
2185 catch { }
2186
2187 // We tried our best to convert the domain names to IP addresses
2188 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
2189 }
2190
1795 /// <summary> 2191 /// <summary>
1796 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. 2192 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary.
1797 /// </summary> 2193 /// </summary>
@@ -1823,14 +2219,14 @@ namespace OpenSim.Framework
1823 2219
1824 if (!str.EndsWith("\0")) 2220 if (!str.EndsWith("\0"))
1825 str += "\0"; 2221 str += "\0";
1826 2222
1827 // Because this is UTF-8 encoding and not ASCII, it's possible we 2223 // Because this is UTF-8 encoding and not ASCII, it's possible we
1828 // might have gotten an oversized array even after the string trim 2224 // might have gotten an oversized array even after the string trim
1829 byte[] data = UTF8.GetBytes(str); 2225 byte[] data = UTF8.GetBytes(str);
1830 2226
1831 if (data.Length > 256) 2227 if (data.Length > 255) //play safe
1832 { 2228 {
1833 int cut = 255; 2229 int cut = 254;
1834 if((data[cut] & 0x80 ) != 0 ) 2230 if((data[cut] & 0x80 ) != 0 )
1835 { 2231 {
1836 while(cut > 0 && (data[cut] & 0xc0) != 0xc0) 2232 while(cut > 0 && (data[cut] & 0xc0) != 0xc0)
@@ -1895,6 +2291,56 @@ namespace OpenSim.Framework
1895 } 2291 }
1896 2292
1897 /// <summary> 2293 /// <summary>
2294 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to MaxLength bytes if necessary.
2295 /// </summary>
2296 /// <param name="str">
2297 /// If null or empty, then an bytes[0] is returned.
2298 /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0]
2299 /// </param>
2300 /// <param name="args">
2301 /// Arguments to substitute into the string via the {} mechanism.
2302 /// </param>
2303 /// <returns></returns>
2304 public static byte[] StringToBytes(string str, int MaxLength, params object[] args)
2305 {
2306 return StringToBytes1024(string.Format(str, args), MaxLength);
2307 }
2308
2309 /// <summary>
2310 /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to MaxLength bytes if necessary.
2311 /// </summary>
2312 /// <param name="str">
2313 /// If null or empty, then an bytes[0] is returned.
2314 /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0]
2315 /// </param>
2316 /// <returns></returns>
2317 public static byte[] StringToBytes(string str, int MaxLength)
2318 {
2319 if (String.IsNullOrEmpty(str))
2320 return Utils.EmptyBytes;
2321
2322 if (!str.EndsWith("\0"))
2323 str += "\0";
2324
2325 // Because this is UTF-8 encoding and not ASCII, it's possible we
2326 // might have gotten an oversized array even after the string trim
2327 byte[] data = UTF8.GetBytes(str);
2328
2329 if (data.Length > MaxLength)
2330 {
2331 int cut = MaxLength - 1 ;
2332 if((data[cut] & 0x80 ) != 0 )
2333 {
2334 while(cut > 0 && (data[cut] & 0xc0) != 0xc0)
2335 cut--;
2336 }
2337 Array.Resize<byte>(ref data, cut + 1);
2338 data[cut] = 0;
2339 }
2340
2341 return data;
2342 }
2343 /// <summary>
1898 /// Pretty format the hashtable contents to a single line. 2344 /// Pretty format the hashtable contents to a single line.
1899 /// </summary> 2345 /// </summary>
1900 /// <remarks> 2346 /// <remarks>
@@ -2004,7 +2450,7 @@ namespace OpenSim.Framework
2004 2450
2005 STPStartInfo startInfo = new STPStartInfo(); 2451 STPStartInfo startInfo = new STPStartInfo();
2006 startInfo.ThreadPoolName = "Util"; 2452 startInfo.ThreadPoolName = "Util";
2007 startInfo.IdleTimeout = 2000; 2453 startInfo.IdleTimeout = 20000;
2008 startInfo.MaxWorkerThreads = maxThreads; 2454 startInfo.MaxWorkerThreads = maxThreads;
2009 startInfo.MinWorkerThreads = minThreads; 2455 startInfo.MinWorkerThreads = minThreads;
2010 2456
@@ -2032,7 +2478,7 @@ namespace OpenSim.Framework
2032 throw new NotImplementedException(); 2478 throw new NotImplementedException();
2033 } 2479 }
2034 } 2480 }
2035 2481
2036 /// <summary> 2482 /// <summary>
2037 /// Additional information about threads in the main thread pool. Used to time how long the 2483 /// Additional information about threads in the main thread pool. Used to time how long the
2038 /// thread has been running, and abort it if it has timed-out. 2484 /// thread has been running, and abort it if it has timed-out.
@@ -2043,14 +2489,15 @@ namespace OpenSim.Framework
2043 public string StackTrace { get; set; } 2489 public string StackTrace { get; set; }
2044 private string context; 2490 private string context;
2045 public bool LogThread { get; set; } 2491 public bool LogThread { get; set; }
2046 2492
2047 public IWorkItemResult WorkItem { get; set; } 2493 public IWorkItemResult WorkItem { get; set; }
2048 public Thread Thread { get; set; } 2494 public Thread Thread { get; set; }
2049 public bool Running { get; set; } 2495 public bool Running { get; set; }
2050 public bool Aborted { get; set; } 2496 public bool Aborted { get; set; }
2051 private int started; 2497 private int started;
2498 public bool DoTimeout;
2052 2499
2053 public ThreadInfo(long threadFuncNum, string context) 2500 public ThreadInfo(long threadFuncNum, string context, bool dotimeout = true)
2054 { 2501 {
2055 ThreadFuncNum = threadFuncNum; 2502 ThreadFuncNum = threadFuncNum;
2056 this.context = context; 2503 this.context = context;
@@ -2058,6 +2505,7 @@ namespace OpenSim.Framework
2058 Thread = null; 2505 Thread = null;
2059 Running = false; 2506 Running = false;
2060 Aborted = false; 2507 Aborted = false;
2508 DoTimeout = dotimeout;
2061 } 2509 }
2062 2510
2063 public void Started() 2511 public void Started()
@@ -2128,7 +2576,7 @@ namespace OpenSim.Framework
2128 foreach (KeyValuePair<long, ThreadInfo> entry in activeThreads) 2576 foreach (KeyValuePair<long, ThreadInfo> entry in activeThreads)
2129 { 2577 {
2130 ThreadInfo t = entry.Value; 2578 ThreadInfo t = entry.Value;
2131 if (t.Running && !t.Aborted && (t.Elapsed() >= THREAD_TIMEOUT)) 2579 if (t.DoTimeout && t.Running && !t.Aborted && (t.Elapsed() >= THREAD_TIMEOUT))
2132 { 2580 {
2133 m_log.WarnFormat("Timeout in threadfunc {0} ({1}) {2}", t.ThreadFuncNum, t.Thread.Name, t.GetStackTrace()); 2581 m_log.WarnFormat("Timeout in threadfunc {0} ({1}) {2}", t.ThreadFuncNum, t.Thread.Name, t.GetStackTrace());
2134 t.Abort(); 2582 t.Abort();
@@ -2138,7 +2586,7 @@ namespace OpenSim.Framework
2138 2586
2139 // It's possible that the thread won't abort. To make sure the thread pool isn't 2587 // It's possible that the thread won't abort. To make sure the thread pool isn't
2140 // depleted, increase the pool size. 2588 // depleted, increase the pool size.
2141 m_ThreadPool.MaxThreads++; 2589// m_ThreadPool.MaxThreads++;
2142 } 2590 }
2143 } 2591 }
2144 } 2592 }
@@ -2148,7 +2596,7 @@ namespace OpenSim.Framework
2148 public static Dictionary<string, int> GetFireAndForgetCallsMade() 2596 public static Dictionary<string, int> GetFireAndForgetCallsMade()
2149 { 2597 {
2150 return new Dictionary<string, int>(m_fireAndForgetCallsMade); 2598 return new Dictionary<string, int>(m_fireAndForgetCallsMade);
2151 } 2599 }
2152 2600
2153 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>(); 2601 private static Dictionary<string, int> m_fireAndForgetCallsMade = new Dictionary<string, int>();
2154 2602
@@ -2168,11 +2616,11 @@ namespace OpenSim.Framework
2168 { 2616 {
2169 FireAndForget(callback, obj, null); 2617 FireAndForget(callback, obj, null);
2170 } 2618 }
2171 2619
2172 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context) 2620 public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context, bool dotimeout = true)
2173 { 2621 {
2174 Interlocked.Increment(ref numTotalThreadFuncsCalled); 2622 Interlocked.Increment(ref numTotalThreadFuncsCalled);
2175 2623/*
2176 if (context != null) 2624 if (context != null)
2177 { 2625 {
2178 if (!m_fireAndForgetCallsMade.ContainsKey(context)) 2626 if (!m_fireAndForgetCallsMade.ContainsKey(context))
@@ -2185,25 +2633,25 @@ namespace OpenSim.Framework
2185 else 2633 else
2186 m_fireAndForgetCallsInProgress[context]++; 2634 m_fireAndForgetCallsInProgress[context]++;
2187 } 2635 }
2188 2636*/
2189 WaitCallback realCallback; 2637 WaitCallback realCallback;
2190 2638
2191 bool loggingEnabled = LogThreadPool > 0; 2639 bool loggingEnabled = LogThreadPool > 0;
2192 2640
2193 long threadFuncNum = Interlocked.Increment(ref nextThreadFuncNum); 2641 long threadFuncNum = Interlocked.Increment(ref nextThreadFuncNum);
2194 ThreadInfo threadInfo = new ThreadInfo(threadFuncNum, context); 2642 ThreadInfo threadInfo = new ThreadInfo(threadFuncNum, context, dotimeout);
2195 2643
2196 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 2644 if (FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
2197 { 2645 {
2198 // If we're running regression tests, then we want any exceptions to rise up to the test code. 2646 // If we're running regression tests, then we want any exceptions to rise up to the test code.
2199 realCallback = 2647 realCallback =
2200 o => 2648 o =>
2201 { 2649 {
2202 Culture.SetCurrentCulture(); 2650 Culture.SetCurrentCulture();
2203 callback(o); 2651 callback(o);
2204 2652
2205 if (context != null) 2653// if (context != null)
2206 m_fireAndForgetCallsInProgress[context]--; 2654// m_fireAndForgetCallsInProgress[context]--;
2207 }; 2655 };
2208 } 2656 }
2209 else 2657 else
@@ -2229,7 +2677,6 @@ namespace OpenSim.Framework
2229 } 2677 }
2230 catch (ThreadAbortException e) 2678 catch (ThreadAbortException e)
2231 { 2679 {
2232 m_log.Error(string.Format("Aborted threadfunc {0} ", threadFuncNum), e);
2233 } 2680 }
2234 catch (Exception e) 2681 catch (Exception e)
2235 { 2682 {
@@ -2244,8 +2691,8 @@ namespace OpenSim.Framework
2244 if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread) 2691 if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread)
2245 m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed())); 2692 m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed()));
2246 2693
2247 if (context != null) 2694// if (context != null)
2248 m_fireAndForgetCallsInProgress[context]--; 2695// m_fireAndForgetCallsInProgress[context]--;
2249 } 2696 }
2250 }; 2697 };
2251 } 2698 }
@@ -2253,6 +2700,7 @@ namespace OpenSim.Framework
2253 long numQueued = Interlocked.Increment(ref numQueuedThreadFuncs); 2700 long numQueued = Interlocked.Increment(ref numQueuedThreadFuncs);
2254 try 2701 try
2255 { 2702 {
2703/*
2256 long numRunning = numRunningThreadFuncs; 2704 long numRunning = numRunningThreadFuncs;
2257 2705
2258 if (m_ThreadPool != null && LogOverloads) 2706 if (m_ThreadPool != null && LogOverloads)
@@ -2285,6 +2733,7 @@ namespace OpenSim.Framework
2285 } 2733 }
2286 } 2734 }
2287 else 2735 else
2736*/
2288 { 2737 {
2289 // Since we didn't log "Queue threadfunc", don't log "Run threadfunc" or "End threadfunc" either. 2738 // Since we didn't log "Queue threadfunc", don't log "Run threadfunc" or "End threadfunc" either.
2290 // Those log lines aren't useful when we don't know which function is running in the thread. 2739 // Those log lines aren't useful when we don't know which function is running in the thread.
@@ -2342,7 +2791,7 @@ namespace OpenSim.Framework
2342 if (stackTrace.Contains("BeginFireQueueEmpty")) 2791 if (stackTrace.Contains("BeginFireQueueEmpty"))
2343 return false; 2792 return false;
2344 } 2793 }
2345 2794
2346 return true; 2795 return true;
2347 } 2796 }
2348 2797
@@ -2355,7 +2804,7 @@ namespace OpenSim.Framework
2355 { 2804 {
2356 string src = Environment.StackTrace; 2805 string src = Environment.StackTrace;
2357 string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 2806 string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
2358 2807
2359 StringBuilder dest = new StringBuilder(src.Length); 2808 StringBuilder dest = new StringBuilder(src.Length);
2360 2809
2361 bool started = false; 2810 bool started = false;
@@ -2400,11 +2849,11 @@ namespace OpenSim.Framework
2400 /// trace. And pausing another thread can cause a deadlock. This method attempts to 2849 /// trace. And pausing another thread can cause a deadlock. This method attempts to
2401 /// avoid deadlock by using a short timeout (200ms), after which it gives up and 2850 /// avoid deadlock by using a short timeout (200ms), after which it gives up and
2402 /// returns 'null' instead of the stack trace. 2851 /// returns 'null' instead of the stack trace.
2403 /// 2852 ///
2404 /// Take from: http://stackoverflow.com/a/14935378 2853 /// Take from: http://stackoverflow.com/a/14935378
2405 /// 2854 ///
2406 /// WARNING: this doesn't work in Mono. See https://bugzilla.novell.com/show_bug.cgi?id=571691 2855 /// WARNING: this doesn't work in Mono. See https://bugzilla.novell.com/show_bug.cgi?id=571691
2407 /// 2856 ///
2408 /// </remarks> 2857 /// </remarks>
2409 /// <returns>The stack trace, or null if failed to get it</returns> 2858 /// <returns>The stack trace, or null if failed to get it</returns>
2410 private static StackTrace GetStackTrace(Thread targetThread) 2859 private static StackTrace GetStackTrace(Thread targetThread)
@@ -2500,12 +2949,22 @@ namespace OpenSim.Framework
2500 return stpi; 2949 return stpi;
2501 } 2950 }
2502 2951
2952 public static void StopThreadPool()
2953 {
2954 if (m_ThreadPool == null)
2955 return;
2956 SmartThreadPool pool = m_ThreadPool;
2957 m_ThreadPool = null;
2958
2959 try { pool.Shutdown(); } catch {}
2960 }
2961
2503 #endregion FireAndForget Threading Pattern 2962 #endregion FireAndForget Threading Pattern
2504 2963
2505 /// <summary> 2964 /// <summary>
2506 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive 2965 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
2507 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap 2966 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
2508 /// for the callers. 2967 /// for the callers.
2509 /// This trims it to a 12 day interval so don't let your frame time get too long. 2968 /// This trims it to a 12 day interval so don't let your frame time get too long.
2510 /// </summary> 2969 /// </summary>
2511 /// <returns></returns> 2970 /// <returns></returns>
@@ -2513,6 +2972,7 @@ namespace OpenSim.Framework
2513 { 2972 {
2514 return Environment.TickCount & EnvironmentTickCountMask; 2973 return Environment.TickCount & EnvironmentTickCountMask;
2515 } 2974 }
2975
2516 const Int32 EnvironmentTickCountMask = 0x3fffffff; 2976 const Int32 EnvironmentTickCountMask = 0x3fffffff;
2517 2977
2518 /// <summary> 2978 /// <summary>
@@ -2557,6 +3017,18 @@ namespace OpenSim.Framework
2557 return tcA - tcB; 3017 return tcA - tcB;
2558 } 3018 }
2559 3019
3020 // returns a timestamp in ms as double
3021 // using the time resolution avaiable to StopWatch
3022 public static double GetTimeStamp()
3023 {
3024 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriod;
3025 }
3026
3027 public static double GetTimeStampMS()
3028 {
3029 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS;
3030 }
3031
2560 /// <summary> 3032 /// <summary>
2561 /// Formats a duration (given in milliseconds). 3033 /// Formats a duration (given in milliseconds).
2562 /// </summary> 3034 /// </summary>
@@ -2855,7 +3327,7 @@ namespace OpenSim.Framework
2855 if (parts.Length == 2) 3327 if (parts.Length == 2)
2856 return CalcUniversalIdentifier(id, agentsURI, parts[0] + " " + parts[1]); 3328 return CalcUniversalIdentifier(id, agentsURI, parts[0] + " " + parts[1]);
2857 } 3329 }
2858 3330
2859 return CalcUniversalIdentifier(id, agentsURI, firstName + " " + lastName); 3331 return CalcUniversalIdentifier(id, agentsURI, firstName + " " + lastName);
2860 } 3332 }
2861 3333
@@ -2940,6 +3412,7 @@ namespace OpenSim.Framework
2940 3412
2941 } 3413 }
2942 3414
3415/* don't like this code
2943 public class DoubleQueue<T> where T:class 3416 public class DoubleQueue<T> where T:class
2944 { 3417 {
2945 private Queue<T> m_lowQueue = new Queue<T>(); 3418 private Queue<T> m_lowQueue = new Queue<T>();
@@ -2954,10 +3427,10 @@ namespace OpenSim.Framework
2954 3427
2955 public virtual int Count 3428 public virtual int Count
2956 { 3429 {
2957 get 3430 get
2958 { 3431 {
2959 lock (m_syncRoot) 3432 lock (m_syncRoot)
2960 return m_highQueue.Count + m_lowQueue.Count; 3433 return m_highQueue.Count + m_lowQueue.Count;
2961 } 3434 }
2962 } 3435 }
2963 3436
@@ -3051,7 +3524,7 @@ namespace OpenSim.Framework
3051 } 3524 }
3052 } 3525 }
3053 } 3526 }
3054 3527*/
3055 public class BetterRandom 3528 public class BetterRandom
3056 { 3529 {
3057 private const int BufferSize = 1024; // must be a multiple of 4 3530 private const int BufferSize = 1024; // must be a multiple of 4
diff --git a/OpenSim/Framework/VersionInfo.cs b/OpenSim/Framework/VersionInfo.cs
index 1b9ec76..fc0fb1a 100644
--- a/OpenSim/Framework/VersionInfo.cs
+++ b/OpenSim/Framework/VersionInfo.cs
@@ -29,9 +29,10 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 public const string VersionNumber = "0.8.2.1"; 32 public const string VersionNumber = "0.9.0.1";
33 private const string IG_BUILD_NUMBER = "1"; 33 public const string AssemblyVersionNumber = "0.9.0.*";
34 private const Flavour VERSION_FLAVOUR = Flavour.IG; 34
35 public const Flavour VERSION_FLAVOUR = Flavour.Release;
35 36
36 public enum Flavour 37 public enum Flavour
37 { 38 {
@@ -42,26 +43,25 @@ namespace OpenSim
42 RC3, 43 RC3,
43 Release, 44 Release,
44 Post_Fixes, 45 Post_Fixes,
45 Extended, 46 Extended
46 IG
47 } 47 }
48 48
49 public static string Version 49 public static string Version
50 { 50 {
51 get { return GetVersionString(VersionNumber, IG_BUILD_NUMBER, VERSION_FLAVOUR); } 51 get { return GetVersionString(VersionNumber, VERSION_FLAVOUR); }
52 } 52 }
53 53
54 public static string GetVersionString(string versionNumber, string buildNumber, Flavour flavour) 54 public static string GetVersionString(string versionNumber, Flavour flavour)
55 { 55 {
56 string versionString = "OpenSim " + versionNumber + " " + flavour + " build " + buildNumber; 56 string versionString = "OpenSim " + versionNumber + " " + flavour;
57 return versionString.PadRight(VERSIONINFO_VERSION_LENGTH); 57 return versionString.PadRight(VERSIONINFO_VERSION_LENGTH);
58 } 58 }
59 59
60 public const int VERSIONINFO_VERSION_LENGTH = 39; 60 public const int VERSIONINFO_VERSION_LENGTH = 27;
61 61
62 /// <value> 62 /// <value>
63 /// This is the external interface version. It is separate from the OpenSimulator project version. 63 /// This is the external interface version. It is separate from the OpenSimulator project version.
64 /// 64 ///
65 /// </value> 65 /// </value>
66 /// Commented because it's not used anymore, see below for new 66 /// Commented because it's not used anymore, see below for new
67 /// versioning method. 67 /// versioning method.
@@ -70,23 +70,23 @@ namespace OpenSim
70 /// <summary> 70 /// <summary>
71 /// This rules versioning regarding teleports, and compatibility between simulators in that regard. 71 /// This rules versioning regarding teleports, and compatibility between simulators in that regard.
72 /// </summary> 72 /// </summary>
73 /// 73 ///
74 /// <remarks> 74 /// <remarks>
75 /// The protocol version that we will use for outgoing transfers 75 /// The protocol version that we will use for outgoing transfers
76 /// Valid values are 76 /// Valid values are
77 /// "SIMULATION/0.3" 77 /// "SIMULATION/0.3"
78 /// - This is the latest, and it supports teleports to variable-sized regions 78 /// - This is the latest, and it supports teleports to variable-sized regions
79 /// - Older versions can teleport to this one, but only if the destination region 79 /// - Older versions can teleport to this one, but only if the destination region
80 /// is 256x256 80 /// is 256x256
81 /// "SIMULATION/0.2" 81 /// "SIMULATION/0.2"
82 /// - A source simulator which only implements "SIMULATION/0.1" can still teleport here 82 /// - A source simulator which only implements "SIMULATION/0.1" can still teleport here
83 /// - this protocol is more efficient than "SIMULATION/0.1" 83 /// - this protocol is more efficient than "SIMULATION/0.1"
84 /// "SIMULATION/0.1" 84 /// "SIMULATION/0.1"
85 /// - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. 85 /// - this is an older teleport protocol used in OpenSimulator 0.7.5 and before.
86 /// </remarks> 86 /// </remarks>
87 public readonly static float SimulationServiceVersionAcceptedMin = 0.3f; 87 public readonly static float SimulationServiceVersionAcceptedMin = 0.3f;
88 public readonly static float SimulationServiceVersionAcceptedMax = 0.5f; 88 public readonly static float SimulationServiceVersionAcceptedMax = 0.6f;
89 public readonly static float SimulationServiceVersionSupportedMin = 0.3f; 89 public readonly static float SimulationServiceVersionSupportedMin = 0.3f;
90 public readonly static float SimulationServiceVersionSupportedMax = 0.5f; 90 public readonly static float SimulationServiceVersionSupportedMax = 0.6f;
91 } 91 }
92} 92}
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 1aecf79..427e149 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -43,13 +43,14 @@ namespace OpenSim.Framework
43 43
44 public static WearableCacheItem[] GetDefaultCacheItem() 44 public static WearableCacheItem[] GetDefaultCacheItem()
45 { 45 {
46 int itemmax = 21; 46 int itemmax = AvatarAppearance.TEXTURE_COUNT;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; 47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++) 48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; 49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i};
50 return retitems; 50 return retitems;
51 } 51 }
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) 52
53 public static WearableCacheItem[] FromOSD(OSD pInput, IAssetCache dataCache)
53 { 54 {
54 List<WearableCacheItem> ret = new List<WearableCacheItem>(); 55 List<WearableCacheItem> ret = new List<WearableCacheItem>();
55 if (pInput.Type == OSDType.Array) 56 if (pInput.Type == OSDType.Array)
@@ -63,7 +64,7 @@ namespace OpenSim.Framework
63 CacheId = item["cacheid"].AsUUID(), 64 CacheId = item["cacheid"].AsUUID(),
64 TextureID = item["textureid"].AsUUID() 65 TextureID = item["textureid"].AsUUID()
65 }); 66 });
66 67
67 if (dataCache != null && item.ContainsKey("assetdata")) 68 if (dataCache != null && item.ContainsKey("assetdata"))
68 { 69 {
69 AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString()); 70 AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString());
@@ -98,7 +99,8 @@ namespace OpenSim.Framework
98 return ret.ToArray(); 99 return ret.ToArray();
99 100
100 } 101 }
101 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) 102
103 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IAssetCache dataCache)
102 { 104 {
103 OSDArray arr = new OSDArray(); 105 OSDArray arr = new OSDArray();
104 foreach (WearableCacheItem item in pcacheItems) 106 foreach (WearableCacheItem item in pcacheItems)
@@ -111,7 +113,8 @@ namespace OpenSim.Framework
111 { 113 {
112 if (dataCache.Check(item.TextureID.ToString())) 114 if (dataCache.Check(item.TextureID.ToString()))
113 { 115 {
114 AssetBase assetItem = dataCache.Get(item.TextureID.ToString()); 116 AssetBase assetItem;
117 dataCache.Get(item.TextureID.ToString(), out assetItem);
115 if (assetItem != null) 118 if (assetItem != null)
116 { 119 {
117 itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data)); 120 itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data));
@@ -124,6 +127,68 @@ namespace OpenSim.Framework
124 } 127 }
125 return arr; 128 return arr;
126 } 129 }
130
131 public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems)
132 {
133 if (pcacheItems.Length < AvatarAppearance.BAKE_INDICES[AvatarAppearance.BAKE_INDICES.Length - 1])
134 return null;
135
136 OSDArray arr = new OSDArray();
137
138 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
139 {
140 int idx = AvatarAppearance.BAKE_INDICES[i];
141
142 WearableCacheItem item = pcacheItems[idx];
143
144 OSDMap itemmap = new OSDMap();
145 itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex));
146 itemmap.Add("cacheid", OSD.FromUUID(item.CacheId));
147 itemmap.Add("textureid", OSD.FromUUID(item.TextureID));
148/*
149 if (item.TextureAsset != null)
150 {
151 itemmap.Add("assetdata", OSD.FromBinary(item.TextureAsset.Data));
152 itemmap.Add("assetcreator", OSD.FromString(item.TextureAsset.CreatorID));
153 itemmap.Add("assetname", OSD.FromString(item.TextureAsset.Name));
154 }
155 */
156 arr.Add(itemmap);
157 }
158 return arr;
159 }
160
161 public static WearableCacheItem[] BakedFromOSD(OSD pInput)
162 {
163 WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
164
165 if (pInput.Type == OSDType.Array)
166 {
167 OSDArray itemarray = (OSDArray)pInput;
168 foreach (OSDMap item in itemarray)
169 {
170 int idx = (int)item["textureindex"].AsUInteger();
171 if (idx < 0 || idx > pcache.Length)
172 continue;
173 pcache[idx].CacheId = item["cacheid"].AsUUID();
174 pcache[idx].TextureID = item["textureid"].AsUUID();
175/*
176 if (item.ContainsKey("assetdata"))
177 {
178 AssetBase asset = new AssetBase(item["textureid"].AsUUID(), "BakedTexture", (sbyte)AssetType.Texture, UUID.Zero.ToString());
179 asset.Temporary = true;
180 asset.Local = true;
181 asset.Data = item["assetdata"].AsBinary();
182 pcache[idx].TextureAsset = asset;
183 }
184 else
185 */
186 pcache[idx].TextureAsset = null;
187 }
188 }
189 return pcache;
190 }
191
127 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) 192 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems)
128 { 193 {
129 for (int i = 0; i < pcacheItems.Length; i++) 194 for (int i = 0; i < pcacheItems.Length; i++)
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index b180c8a..20d30b5 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -72,11 +72,6 @@ namespace OpenSim.Framework
72 public static int RequestNumber { get; set; } 72 public static int RequestNumber { get; set; }
73 73
74 /// <summary> 74 /// <summary>
75 /// Control where OSD requests should be serialized per endpoint.
76 /// </summary>
77 public static bool SerializeOSDRequestsPerEndpoint { get; set; }
78
79 /// <summary>
80 /// this is the header field used to communicate the local request id 75 /// this is the header field used to communicate the local request id
81 /// used for performance and debugging 76 /// used for performance and debugging
82 /// </summary> 77 /// </summary>
@@ -98,31 +93,6 @@ namespace OpenSim.Framework
98 /// </remarks> 93 /// </remarks>
99 public const int MaxRequestDiagLength = 200; 94 public const int MaxRequestDiagLength = 200;
100 95
101 /// <summary>
102 /// Dictionary of end points
103 /// </summary>
104 private static Dictionary<string,object> m_endpointSerializer = new Dictionary<string,object>();
105
106 private static object EndPointLock(string url)
107 {
108 System.Uri uri = new System.Uri(url);
109 string endpoint = string.Format("{0}:{1}",uri.Host,uri.Port);
110
111 lock (m_endpointSerializer)
112 {
113 object eplock = null;
114
115 if (! m_endpointSerializer.TryGetValue(endpoint,out eplock))
116 {
117 eplock = new object();
118 m_endpointSerializer.Add(endpoint,eplock);
119 // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint);
120 }
121
122 return eplock;
123 }
124 }
125
126 #region JSONRequest 96 #region JSONRequest
127 97
128 /// <summary> 98 /// <summary>
@@ -154,21 +124,6 @@ namespace OpenSim.Framework
154 return ServiceOSDRequest(url, null, "GET", timeout, false, false); 124 return ServiceOSDRequest(url, null, "GET", timeout, false, false);
155 } 125 }
156 126
157 public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc)
158 {
159 if (SerializeOSDRequestsPerEndpoint)
160 {
161 lock (EndPointLock(url))
162 {
163 return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc);
164 }
165 }
166 else
167 {
168 return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc);
169 }
170 }
171
172 public static void LogOutgoingDetail(Stream outputStream) 127 public static void LogOutgoingDetail(Stream outputStream)
173 { 128 {
174 LogOutgoingDetail("", outputStream); 129 LogOutgoingDetail("", outputStream);
@@ -222,7 +177,7 @@ namespace OpenSim.Framework
222 LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input); 177 LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input);
223 } 178 }
224 179
225 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) 180 public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc)
226 { 181 {
227 int reqnum = RequestNumber++; 182 int reqnum = RequestNumber++;
228 183
@@ -233,6 +188,9 @@ namespace OpenSim.Framework
233 string errorMessage = "unknown error"; 188 string errorMessage = "unknown error";
234 int tickstart = Util.EnvironmentTickCount(); 189 int tickstart = Util.EnvironmentTickCount();
235 int tickdata = 0; 190 int tickdata = 0;
191 int tickcompressdata = 0;
192 int tickJsondata = 0;
193 int compsize = 0;
236 string strBuffer = null; 194 string strBuffer = null;
237 195
238 try 196 try
@@ -242,21 +200,23 @@ namespace OpenSim.Framework
242 request.Timeout = timeout; 200 request.Timeout = timeout;
243 request.KeepAlive = false; 201 request.KeepAlive = false;
244 request.MaximumAutomaticRedirections = 10; 202 request.MaximumAutomaticRedirections = 10;
245 request.ReadWriteTimeout = timeout / 4; 203 request.ReadWriteTimeout = timeout / 2;
246 request.Headers[OSHeaderRequestID] = reqnum.ToString(); 204 request.Headers[OSHeaderRequestID] = reqnum.ToString();
247 205
248 // If there is some input, write it into the request 206 // If there is some input, write it into the request
249 if (data != null) 207 if (data != null)
250 { 208 {
251 strBuffer = OSDParser.SerializeJsonString(data); 209 strBuffer = OSDParser.SerializeJsonString(data);
252 210
211 tickJsondata = Util.EnvironmentTickCountSubtract(tickstart);
212
253 if (DebugLevel >= 5) 213 if (DebugLevel >= 5)
254 LogOutgoingDetail("SEND", reqnum, strBuffer); 214 LogOutgoingDetail("SEND", reqnum, strBuffer);
255 215
256 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); 216 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
257 217
258 request.ContentType = rpc ? "application/json-rpc" : "application/json"; 218 request.ContentType = rpc ? "application/json-rpc" : "application/json";
259 219
260 if (compressed) 220 if (compressed)
261 { 221 {
262 request.Headers["X-Content-Encoding"] = "gzip"; // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding 222 request.Headers["X-Content-Encoding"] = "gzip"; // can't set "Content-Encoding" because old OpenSims fail if they get an unrecognized Content-Encoding
@@ -271,19 +231,25 @@ namespace OpenSim.Framework
271 // gets written on the stream upon Dispose() 231 // gets written on the stream upon Dispose()
272 } 232 }
273 byte[] buf = ms.ToArray(); 233 byte[] buf = ms.ToArray();
234
235 tickcompressdata = Util.EnvironmentTickCountSubtract(tickstart);
236
274 request.ContentLength = buf.Length; //Count bytes to send 237 request.ContentLength = buf.Length; //Count bytes to send
238 compsize = buf.Length;
275 using (Stream requestStream = request.GetRequestStream()) 239 using (Stream requestStream = request.GetRequestStream())
276 requestStream.Write(buf, 0, (int)buf.Length); 240 requestStream.Write(buf, 0, (int)buf.Length);
277 } 241 }
278 } 242 }
279 else 243 else
280 { 244 {
245 compsize = buffer.Length;
246
281 request.ContentLength = buffer.Length; //Count bytes to send 247 request.ContentLength = buffer.Length; //Count bytes to send
282 using (Stream requestStream = request.GetRequestStream()) 248 using (Stream requestStream = request.GetRequestStream())
283 requestStream.Write(buffer, 0, buffer.Length); //Send it 249 requestStream.Write(buffer, 0, buffer.Length); //Send it
284 } 250 }
285 } 251 }
286 252
287 // capture how much time was spent writing, this may seem silly 253 // capture how much time was spent writing, this may seem silly
288 // but with the number concurrent requests, this often blocks 254 // but with the number concurrent requests, this often blocks
289 tickdata = Util.EnvironmentTickCountSubtract(tickstart); 255 tickdata = Util.EnvironmentTickCountSubtract(tickstart);
@@ -314,6 +280,7 @@ namespace OpenSim.Framework
314 catch (Exception ex) 280 catch (Exception ex)
315 { 281 {
316 errorMessage = ex.Message; 282 errorMessage = ex.Message;
283 m_log.Debug("[WEB UTIL]: Exception making request: " + ex.ToString());
317 } 284 }
318 finally 285 finally
319 { 286 {
@@ -321,8 +288,17 @@ namespace OpenSim.Framework
321 if (tickdiff > LongCallTime) 288 if (tickdiff > LongCallTime)
322 { 289 {
323 m_log.InfoFormat( 290 m_log.InfoFormat(
324 "[LOGHTTP]: Slow JSON-RPC request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 291 "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing({5} at Json; {6} at comp), {7} bytes ({8} uncomp): {9}",
325 reqnum, method, url, tickdiff, tickdata, 292 reqnum,
293 method,
294 url,
295 tickdiff,
296 tickdata,
297 tickJsondata,
298 tickcompressdata,
299 compsize,
300 strBuffer != null ? strBuffer.Length : 0,
301
326 strBuffer != null 302 strBuffer != null
327 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) 303 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
328 : ""); 304 : "");
@@ -333,7 +309,7 @@ namespace OpenSim.Framework
333 reqnum, tickdiff, tickdata); 309 reqnum, tickdiff, tickdata);
334 } 310 }
335 } 311 }
336 312
337 m_log.DebugFormat( 313 m_log.DebugFormat(
338 "[LOGHTTP]: JSON-RPC request {0} {1} to {2} FAILED: {3}", reqnum, method, url, errorMessage); 314 "[LOGHTTP]: JSON-RPC request {0} {1} to {2} FAILED: {3}", reqnum, method, url, errorMessage);
339 315
@@ -357,7 +333,7 @@ namespace OpenSim.Framework
357 result["success"] = OSD.FromBoolean(true); 333 result["success"] = OSD.FromBoolean(true);
358 result["_RawResult"] = OSD.FromString(response); 334 result["_RawResult"] = OSD.FromString(response);
359 result["_Result"] = new OSDMap(); 335 result["_Result"] = new OSDMap();
360 336
361 if (response.Equals("true",System.StringComparison.OrdinalIgnoreCase)) 337 if (response.Equals("true",System.StringComparison.OrdinalIgnoreCase))
362 return result; 338 return result;
363 339
@@ -368,7 +344,7 @@ namespace OpenSim.Framework
368 return result; 344 return result;
369 } 345 }
370 346
371 try 347 try
372 { 348 {
373 OSD responseOSD = OSDParser.Deserialize(response); 349 OSD responseOSD = OSDParser.Deserialize(response);
374 if (responseOSD.Type == OSDType.Map) 350 if (responseOSD.Type == OSDType.Map)
@@ -382,10 +358,10 @@ namespace OpenSim.Framework
382 // don't need to treat this as an error... we're just guessing anyway 358 // don't need to treat this as an error... we're just guessing anyway
383// m_log.DebugFormat("[WEB UTIL] couldn't decode <{0}>: {1}",response,e.Message); 359// m_log.DebugFormat("[WEB UTIL] couldn't decode <{0}>: {1}",response,e.Message);
384 } 360 }
385 361
386 return result; 362 return result;
387 } 363 }
388 364
389 #endregion JSONRequest 365 #endregion JSONRequest
390 366
391 #region FormRequest 367 #region FormRequest
@@ -396,18 +372,10 @@ namespace OpenSim.Framework
396 /// </summary> 372 /// </summary>
397 public static OSDMap PostToService(string url, NameValueCollection data) 373 public static OSDMap PostToService(string url, NameValueCollection data)
398 { 374 {
399 return ServiceFormRequest(url,data,10000); 375 return ServiceFormRequest(url,data, 30000);
400 }
401
402 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout)
403 {
404 lock (EndPointLock(url))
405 {
406 return ServiceFormRequestWorker(url,data,timeout);
407 }
408 } 376 }
409 377
410 private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout) 378 public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout)
411 { 379 {
412 int reqnum = RequestNumber++; 380 int reqnum = RequestNumber++;
413 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; 381 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
@@ -415,7 +383,7 @@ namespace OpenSim.Framework
415 if (DebugLevel >= 3) 383 if (DebugLevel >= 3)
416 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} ServiceForm '{1}' to {2}", 384 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} ServiceForm '{1}' to {2}",
417 reqnum, method, url); 385 reqnum, method, url);
418 386
419 string errorMessage = "unknown error"; 387 string errorMessage = "unknown error";
420 int tickstart = Util.EnvironmentTickCount(); 388 int tickstart = Util.EnvironmentTickCount();
421 int tickdata = 0; 389 int tickdata = 0;
@@ -428,9 +396,9 @@ namespace OpenSim.Framework
428 request.Timeout = timeout; 396 request.Timeout = timeout;
429 request.KeepAlive = false; 397 request.KeepAlive = false;
430 request.MaximumAutomaticRedirections = 10; 398 request.MaximumAutomaticRedirections = 10;
431 request.ReadWriteTimeout = timeout / 4; 399 request.ReadWriteTimeout = timeout / 2;
432 request.Headers[OSHeaderRequestID] = reqnum.ToString(); 400 request.Headers[OSHeaderRequestID] = reqnum.ToString();
433 401
434 if (data != null) 402 if (data != null)
435 { 403 {
436 queryString = BuildQueryString(data); 404 queryString = BuildQueryString(data);
@@ -439,7 +407,7 @@ namespace OpenSim.Framework
439 LogOutgoingDetail("SEND", reqnum, queryString); 407 LogOutgoingDetail("SEND", reqnum, queryString);
440 408
441 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); 409 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
442 410
443 request.ContentLength = buffer.Length; 411 request.ContentLength = buffer.Length;
444 request.ContentType = "application/x-www-form-urlencoded"; 412 request.ContentType = "application/x-www-form-urlencoded";
445 using (Stream requestStream = request.GetRequestStream()) 413 using (Stream requestStream = request.GetRequestStream())
@@ -517,7 +485,7 @@ namespace OpenSim.Framework
517 } 485 }
518 486
519 #endregion FormRequest 487 #endregion FormRequest
520 488
521 #region Uri 489 #region Uri
522 490
523 /// <summary> 491 /// <summary>
@@ -570,7 +538,7 @@ namespace OpenSim.Framework
570 } 538 }
571 539
572 /// <summary> 540 /// <summary>
573 /// Appends a query string to a Uri that may or may not have existing 541 /// Appends a query string to a Uri that may or may not have existing
574 /// query parameters 542 /// query parameters
575 /// </summary> 543 /// </summary>
576 /// <param name="uri">Uri to append the query to</param> 544 /// <param name="uri">Uri to append the query to</param>
@@ -622,7 +590,7 @@ namespace OpenSim.Framework
622 } 590 }
623 591
624 /// <summary> 592 /// <summary>
625 /// 593 ///
626 /// </summary> 594 /// </summary>
627 /// <param name="collection"></param> 595 /// <param name="collection"></param>
628 /// <param name="key"></param> 596 /// <param name="key"></param>
@@ -641,12 +609,12 @@ namespace OpenSim.Framework
641 #region Stream 609 #region Stream
642 610
643 /// <summary> 611 /// <summary>
644 /// Copies the contents of one stream to another, starting at the 612 /// Copies the contents of one stream to another, starting at the
645 /// current position of each stream 613 /// current position of each stream
646 /// </summary> 614 /// </summary>
647 /// <param name="copyFrom">The stream to copy from, at the position 615 /// <param name="copyFrom">The stream to copy from, at the position
648 /// where copying should begin</param> 616 /// where copying should begin</param>
649 /// <param name="copyTo">The stream to copy to, at the position where 617 /// <param name="copyTo">The stream to copy to, at the position where
650 /// bytes should be written</param> 618 /// bytes should be written</param>
651 /// <param name="maximumBytesToCopy">The maximum bytes to copy</param> 619 /// <param name="maximumBytesToCopy">The maximum bytes to copy</param>
652 /// <returns>The total number of bytes copied</returns> 620 /// <returns>The total number of bytes copied</returns>
@@ -779,6 +747,20 @@ namespace OpenSim.Framework
779 MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null); 747 MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null);
780 } 748 }
781 749
750 /// <summary>
751 /// Perform a synchronous REST request.
752 /// </summary>
753 /// <param name="verb"></param>
754 /// <param name="requestUrl"></param>
755 /// <param name="obj"></param>
756 /// <param name="pTimeout">
757 /// Request timeout in seconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds)
758 /// </param>
759 /// <param name="maxConnections"></param>
760 /// <returns>
761 /// The response. If there was an internal exception or the request timed out,
762 /// then the default(TResponse) is returned.
763 /// </returns>
782 public static void MakeRequest<TRequest, TResponse>(string verb, 764 public static void MakeRequest<TRequest, TResponse>(string verb,
783 string requestUrl, TRequest obj, Action<TResponse> action, 765 string requestUrl, TRequest obj, Action<TResponse> action,
784 int maxConnections, IServiceAuth auth) 766 int maxConnections, IServiceAuth auth)
@@ -791,6 +773,7 @@ namespace OpenSim.Framework
791 773
792 int tickstart = Util.EnvironmentTickCount(); 774 int tickstart = Util.EnvironmentTickCount();
793 int tickdata = 0; 775 int tickdata = 0;
776 int tickdiff = 0;
794 777
795 Type type = typeof(TRequest); 778 Type type = typeof(TRequest);
796 779
@@ -873,7 +856,7 @@ namespace OpenSim.Framework
873 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't 856 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't
874 // documented in MSDN 857 // documented in MSDN
875 using (WebResponse response = request.EndGetResponse(res2)) 858 using (WebResponse response = request.EndGetResponse(res2))
876 { 859 {
877 try 860 try
878 { 861 {
879 using (Stream respStream = response.GetResponseStream()) 862 using (Stream respStream = response.GetResponseStream())
@@ -894,7 +877,7 @@ namespace OpenSim.Framework
894 if (e.Response is HttpWebResponse) 877 if (e.Response is HttpWebResponse)
895 { 878 {
896 using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response) 879 using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response)
897 { 880 {
898 if (httpResponse.StatusCode != HttpStatusCode.NotFound) 881 if (httpResponse.StatusCode != HttpStatusCode.NotFound)
899 { 882 {
900 // We don't appear to be handling any other status codes, so log these feailures to that 883 // We don't appear to be handling any other status codes, so log these feailures to that
@@ -919,7 +902,7 @@ namespace OpenSim.Framework
919 "[ASYNC REQUEST]: Request {0} {1} failed with exception {2}{3}", 902 "[ASYNC REQUEST]: Request {0} {1} failed with exception {2}{3}",
920 verb, requestUrl, e.Message, e.StackTrace); 903 verb, requestUrl, e.Message, e.StackTrace);
921 } 904 }
922 905
923 // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); 906 // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString());
924 907
925 try 908 try
@@ -932,11 +915,11 @@ namespace OpenSim.Framework
932 "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}{3}", 915 "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}{3}",
933 verb, requestUrl, e.Message, e.StackTrace); 916 verb, requestUrl, e.Message, e.StackTrace);
934 } 917 }
935 918
936 }, null); 919 }, null);
937 } 920 }
938 921
939 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 922 tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
940 if (tickdiff > WebUtil.LongCallTime) 923 if (tickdiff > WebUtil.LongCallTime)
941 { 924 {
942 string originalRequest = null; 925 string originalRequest = null;
@@ -948,8 +931,7 @@ namespace OpenSim.Framework
948 if (originalRequest.Length > WebUtil.MaxRequestDiagLength) 931 if (originalRequest.Length > WebUtil.MaxRequestDiagLength)
949 originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); 932 originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength);
950 } 933 }
951 934 m_log.InfoFormat(
952 m_log.InfoFormat(
953 "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 935 "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}",
954 reqnum, verb, requestUrl, tickdiff, tickdata, 936 reqnum, verb, requestUrl, tickdiff, tickdata,
955 originalRequest); 937 originalRequest);
@@ -957,11 +939,12 @@ namespace OpenSim.Framework
957 else if (WebUtil.DebugLevel >= 4) 939 else if (WebUtil.DebugLevel >= 4)
958 { 940 {
959 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", 941 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing",
942
960 reqnum, tickdiff, tickdata); 943 reqnum, tickdiff, tickdata);
961 } 944 }
962 } 945 }
963 finally 946 finally
964 { 947 {
965 if (buffer != null) 948 if (buffer != null)
966 buffer.Dispose(); 949 buffer.Dispose();
967 } 950 }
@@ -983,7 +966,8 @@ namespace OpenSim.Framework
983 /// 966 ///
984 /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting 967 /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
985 /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> 968 /// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
986 public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs, IServiceAuth auth) 969 public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs = -1,
970 IServiceAuth auth = null, bool keepalive = true)
987 { 971 {
988 int reqnum = WebUtil.RequestNumber++; 972 int reqnum = WebUtil.RequestNumber++;
989 973
@@ -998,12 +982,16 @@ namespace OpenSim.Framework
998 request.Method = verb; 982 request.Method = verb;
999 if (timeoutsecs > 0) 983 if (timeoutsecs > 0)
1000 request.Timeout = timeoutsecs * 1000; 984 request.Timeout = timeoutsecs * 1000;
985 if(!keepalive && request is HttpWebRequest)
986 ((HttpWebRequest)request).KeepAlive = false;
1001 987
1002 if (auth != null) 988 if (auth != null)
1003 auth.AddAuthorization(request.Headers); 989 auth.AddAuthorization(request.Headers);
1004 990
1005 string respstring = String.Empty; 991 string respstring = String.Empty;
1006 992
993 int tickset = Util.EnvironmentTickCountSubtract(tickstart);
994
1007 using (MemoryStream buffer = new MemoryStream()) 995 using (MemoryStream buffer = new MemoryStream())
1008 { 996 {
1009 if ((verb == "POST") || (verb == "PUT")) 997 if ((verb == "POST") || (verb == "PUT"))
@@ -1024,11 +1012,10 @@ namespace OpenSim.Framework
1024 if (WebUtil.DebugLevel >= 5) 1012 if (WebUtil.DebugLevel >= 5)
1025 WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data)); 1013 WebUtil.LogOutgoingDetail("SEND", reqnum, System.Text.Encoding.UTF8.GetString(data));
1026 1014
1027 Stream requestStream = null;
1028 try 1015 try
1029 { 1016 {
1030 requestStream = request.GetRequestStream(); 1017 using(Stream requestStream = request.GetRequestStream())
1031 requestStream.Write(data, 0, length); 1018 requestStream.Write(data,0,length);
1032 } 1019 }
1033 catch (Exception e) 1020 catch (Exception e)
1034 { 1021 {
@@ -1038,9 +1025,6 @@ namespace OpenSim.Framework
1038 } 1025 }
1039 finally 1026 finally
1040 { 1027 {
1041 if (requestStream != null)
1042 requestStream.Dispose();
1043
1044 // capture how much time was spent writing 1028 // capture how much time was spent writing
1045 tickdata = Util.EnvironmentTickCountSubtract(tickstart); 1029 tickdata = Util.EnvironmentTickCountSubtract(tickstart);
1046 } 1030 }
@@ -1070,8 +1054,13 @@ namespace OpenSim.Framework
1070 if (tickdiff > WebUtil.LongCallTime) 1054 if (tickdiff > WebUtil.LongCallTime)
1071 { 1055 {
1072 m_log.InfoFormat( 1056 m_log.InfoFormat(
1073 "[LOGHTTP]: Slow SynchronousRestForms request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", 1057 "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
1074 reqnum, verb, requestUrl, tickdiff, tickdata, 1058 reqnum,
1059 verb,
1060 requestUrl,
1061 tickdiff,
1062 tickset,
1063 tickdata,
1075 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); 1064 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj);
1076 } 1065 }
1077 else if (WebUtil.DebugLevel >= 4) 1066 else if (WebUtil.DebugLevel >= 4)
@@ -1086,16 +1075,6 @@ namespace OpenSim.Framework
1086 return respstring; 1075 return respstring;
1087 } 1076 }
1088 1077
1089 public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs)
1090 {
1091 return MakeRequest(verb, requestUrl, obj, timeoutsecs, null);
1092 }
1093
1094 public static string MakeRequest(string verb, string requestUrl, string obj)
1095 {
1096 return MakeRequest(verb, requestUrl, obj, -1);
1097 }
1098
1099 public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth) 1078 public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth)
1100 { 1079 {
1101 return MakeRequest(verb, requestUrl, obj, -1, auth); 1080 return MakeRequest(verb, requestUrl, obj, -1, auth);
@@ -1136,7 +1115,7 @@ namespace OpenSim.Framework
1136 /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) 1115 /// Request timeout in milliseconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds)
1137 /// </param> 1116 /// </param>
1138 /// <returns> 1117 /// <returns>
1139 /// The response. If there was an internal exception or the request timed out, 1118 /// The response. If there was an internal exception or the request timed out,
1140 /// then the default(TResponse) is returned. 1119 /// then the default(TResponse) is returned.
1141 /// </returns> 1120 /// </returns>
1142 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout) 1121 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout)
@@ -1159,7 +1138,7 @@ namespace OpenSim.Framework
1159 /// </param> 1138 /// </param>
1160 /// <param name="maxConnections"></param> 1139 /// <param name="maxConnections"></param>
1161 /// <returns> 1140 /// <returns>
1162 /// The response. If there was an internal exception or the request timed out, 1141 /// The response. If there was an internal exception or the request timed out,
1163 /// then the default(TResponse) is returned. 1142 /// then the default(TResponse) is returned.
1164 /// </returns> 1143 /// </returns>
1165 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) 1144 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections)
@@ -1178,7 +1157,7 @@ namespace OpenSim.Framework
1178 /// </param> 1157 /// </param>
1179 /// <param name="maxConnections"></param> 1158 /// <param name="maxConnections"></param>
1180 /// <returns> 1159 /// <returns>
1181 /// The response. If there was an internal exception or the request timed out, 1160 /// The response. If there was an internal exception or the request timed out,
1182 /// then the default(TResponse) is returned. 1161 /// then the default(TResponse) is returned.
1183 /// </returns> 1162 /// </returns>
1184 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections, IServiceAuth auth) 1163 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections, IServiceAuth auth)
@@ -1202,7 +1181,7 @@ namespace OpenSim.Framework
1202 auth.AddAuthorization(ht.Headers); 1181 auth.AddAuthorization(ht.Headers);
1203 1182
1204 if (pTimeout != 0) 1183 if (pTimeout != 0)
1205 ht.Timeout = pTimeout; 1184 request.Timeout = pTimeout;
1206 1185
1207 if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) 1186 if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections)
1208 ht.ServicePoint.ConnectionLimit = maxConnections; 1187 ht.ServicePoint.ConnectionLimit = maxConnections;
@@ -1283,18 +1262,24 @@ namespace OpenSim.Framework
1283 { 1262 {
1284 if (hwr.StatusCode == HttpStatusCode.NotFound) 1263 if (hwr.StatusCode == HttpStatusCode.NotFound)
1285 return deserial; 1264 return deserial;
1265
1286 if (hwr.StatusCode == HttpStatusCode.Unauthorized) 1266 if (hwr.StatusCode == HttpStatusCode.Unauthorized)
1287 { 1267 {
1288 m_log.Error(string.Format( 1268 m_log.ErrorFormat("[SynchronousRestObjectRequester]: Web request {0} requires authentication",
1289 "[SynchronousRestObjectRequester]: Web request {0} requires authentication ", 1269 requestUrl);
1290 requestUrl)); 1270 }
1291 return deserial; 1271 else
1272 {
1273 m_log.WarnFormat("[SynchronousRestObjectRequester]: Web request {0} returned error: {1}",
1274 requestUrl, hwr.StatusCode);
1292 } 1275 }
1293 } 1276 }
1294 else 1277 else
1295 m_log.Error(string.Format( 1278 m_log.ErrorFormat(
1296 "[SynchronousRestObjectRequester]: WebException for {0} {1} {2} ", 1279 "[SynchronousRestObjectRequester]: WebException for {0} {1} {2} {3}",
1297 verb, requestUrl, typeof(TResponse).ToString()), e); 1280 verb, requestUrl, typeof(TResponse).ToString(), e.Message);
1281
1282 return deserial;
1298 } 1283 }
1299 } 1284 }
1300 catch (System.InvalidOperationException) 1285 catch (System.InvalidOperationException)
@@ -1344,7 +1329,6 @@ namespace OpenSim.Framework
1344 return deserial; 1329 return deserial;
1345 } 1330 }
1346 1331
1347
1348 public static class XMLResponseHelper 1332 public static class XMLResponseHelper
1349 { 1333 {
1350 public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength) 1334 public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength)
@@ -1369,7 +1353,7 @@ namespace OpenSim.Framework
1369 } 1353 }
1370 } 1354 }
1371 1355
1372 1356
1373 public static class XMLRPCRequester 1357 public static class XMLRPCRequester
1374 { 1358 {
1375 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 1359 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -1413,7 +1397,7 @@ namespace OpenSim.Framework
1413 { 1397 {
1414 m_log.Error("Error parsing XML-RPC response", e); 1398 m_log.Error("Error parsing XML-RPC response", e);
1415 } 1399 }
1416 1400
1417 if (Resp.IsFault) 1401 if (Resp.IsFault)
1418 { 1402 {
1419 m_log.DebugFormat( 1403 m_log.DebugFormat(