diff options
Diffstat (limited to '')
76 files changed, 2983 insertions, 1839 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 5a9eeb5..ebb00d2 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs | |||
@@ -173,6 +173,7 @@ namespace OpenSim.Framework | |||
173 | /// Position the Agent's Avatar starts in the region | 173 | /// Position the Agent's Avatar starts in the region |
174 | /// </summary> | 174 | /// </summary> |
175 | public Vector3 startpos; | 175 | public Vector3 startpos; |
176 | public float startfar = -1.0f; | ||
176 | 177 | ||
177 | public Dictionary<string, object> ServiceURLs; | 178 | public Dictionary<string, object> ServiceURLs; |
178 | 179 | ||
@@ -219,6 +220,8 @@ namespace OpenSim.Framework | |||
219 | args["channel"] = OSD.FromString(Channel); | 220 | args["channel"] = OSD.FromString(Channel); |
220 | args["mac"] = OSD.FromString(Mac); | 221 | args["mac"] = OSD.FromString(Mac); |
221 | args["id0"] = OSD.FromString(Id0); | 222 | args["id0"] = OSD.FromString(Id0); |
223 | if(startfar > 0) | ||
224 | args["far"] = OSD.FromReal(startfar); | ||
222 | 225 | ||
223 | if (Appearance != null) | 226 | if (Appearance != null) |
224 | { | 227 | { |
@@ -264,16 +267,17 @@ namespace OpenSim.Framework | |||
264 | /// <param name="args"></param> | 267 | /// <param name="args"></param> |
265 | public void UnpackAgentCircuitData(OSDMap args) | 268 | public void UnpackAgentCircuitData(OSDMap args) |
266 | { | 269 | { |
267 | if (args["agent_id"] != null) | 270 | OSD tmpOSD; |
268 | AgentID = args["agent_id"].AsUUID(); | 271 | if (args.TryGetValue("agent_id", out tmpOSD)) |
269 | if (args["base_folder"] != null) | 272 | AgentID = tmpOSD.AsUUID(); |
270 | BaseFolder = args["base_folder"].AsUUID(); | 273 | if (args.TryGetValue("base_folder", out tmpOSD)) |
271 | if (args["caps_path"] != null) | 274 | BaseFolder =tmpOSD.AsUUID(); |
272 | CapsPath = args["caps_path"].AsString(); | 275 | if (args.TryGetValue("caps_path", out tmpOSD)) |
273 | 276 | CapsPath = tmpOSD.AsString(); | |
274 | if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array)) | 277 | |
278 | if ((args.TryGetValue("children_seeds", out tmpOSD) && tmpOSD is OSDArray)) | ||
275 | { | 279 | { |
276 | OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]); | 280 | OSDArray childrenSeeds = (OSDArray)tmpOSD; |
277 | ChildrenCapSeeds = new Dictionary<ulong, string>(); | 281 | ChildrenCapSeeds = new Dictionary<ulong, string>(); |
278 | foreach (OSD o in childrenSeeds) | 282 | foreach (OSD o in childrenSeeds) |
279 | { | 283 | { |
@@ -282,50 +286,59 @@ namespace OpenSim.Framework | |||
282 | ulong handle = 0; | 286 | ulong handle = 0; |
283 | string seed = ""; | 287 | string seed = ""; |
284 | OSDMap pair = (OSDMap)o; | 288 | OSDMap pair = (OSDMap)o; |
285 | if (pair["handle"] != null) | 289 | if (pair.TryGetValue("handle", out tmpOSD)) |
286 | if (!UInt64.TryParse(pair["handle"].AsString(), out handle)) | 290 | { |
291 | if (!UInt64.TryParse(tmpOSD.AsString(), out handle)) | ||
287 | continue; | 292 | continue; |
288 | if (pair["seed"] != null) | 293 | } |
289 | seed = pair["seed"].AsString(); | ||
290 | if (!ChildrenCapSeeds.ContainsKey(handle)) | 294 | if (!ChildrenCapSeeds.ContainsKey(handle)) |
291 | ChildrenCapSeeds.Add(handle, seed); | 295 | { |
296 | if (pair.TryGetValue("seed", out tmpOSD)) | ||
297 | { | ||
298 | seed = tmpOSD.AsString(); | ||
299 | ChildrenCapSeeds.Add(handle, seed); | ||
300 | } | ||
301 | } | ||
292 | } | 302 | } |
293 | } | 303 | } |
294 | } | 304 | } |
295 | else | 305 | else |
296 | ChildrenCapSeeds = new Dictionary<ulong, string>(); | 306 | ChildrenCapSeeds = new Dictionary<ulong, string>(); |
297 | 307 | ||
298 | if (args["child"] != null) | 308 | if (args.TryGetValue("child", out tmpOSD)) |
299 | child = args["child"].AsBoolean(); | 309 | child = tmpOSD.AsBoolean(); |
300 | if (args["circuit_code"] != null) | 310 | if (args.TryGetValue("circuit_code", out tmpOSD)) |
301 | UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode); | 311 | UInt32.TryParse(tmpOSD.AsString(), out circuitcode); |
302 | if (args["first_name"] != null) | 312 | if (args.TryGetValue("first_name", out tmpOSD)) |
303 | firstname = args["first_name"].AsString(); | 313 | firstname = tmpOSD.AsString(); |
304 | if (args["last_name"] != null) | 314 | if (args.TryGetValue("last_name", out tmpOSD)) |
305 | lastname = args["last_name"].AsString(); | 315 | lastname = tmpOSD.AsString(); |
306 | if (args["inventory_folder"] != null) | 316 | if (args.TryGetValue("inventory_folder", out tmpOSD)) |
307 | InventoryFolder = args["inventory_folder"].AsUUID(); | 317 | InventoryFolder = tmpOSD.AsUUID(); |
308 | if (args["secure_session_id"] != null) | 318 | if (args.TryGetValue("secure_session_id", out tmpOSD)) |
309 | SecureSessionID = args["secure_session_id"].AsUUID(); | 319 | SecureSessionID = tmpOSD.AsUUID(); |
310 | if (args["session_id"] != null) | 320 | if (args.TryGetValue("session_id", out tmpOSD)) |
311 | SessionID = args["session_id"].AsUUID(); | 321 | SessionID = tmpOSD.AsUUID(); |
312 | if (args["service_session_id"] != null) | 322 | if (args.TryGetValue("service_session_id", out tmpOSD)) |
313 | ServiceSessionID = args["service_session_id"].AsString(); | 323 | ServiceSessionID = tmpOSD.AsString(); |
314 | if (args["client_ip"] != null) | 324 | if (args.TryGetValue("client_ip", out tmpOSD)) |
315 | IPAddress = args["client_ip"].AsString(); | 325 | IPAddress = tmpOSD.AsString(); |
316 | if (args["viewer"] != null) | 326 | if (args.TryGetValue("viewer", out tmpOSD)) |
317 | Viewer = args["viewer"].AsString(); | 327 | Viewer = tmpOSD.AsString(); |
318 | if (args["channel"] != null) | 328 | if (args.TryGetValue("channel", out tmpOSD)) |
319 | Channel = args["channel"].AsString(); | 329 | Channel = tmpOSD.AsString(); |
320 | if (args["mac"] != null) | 330 | if (args.TryGetValue("mac", out tmpOSD)) |
321 | Mac = args["mac"].AsString(); | 331 | Mac = tmpOSD.AsString(); |
322 | if (args["id0"] != null) | 332 | if (args.TryGetValue("id0", out tmpOSD)) |
323 | Id0 = args["id0"].AsString(); | 333 | Id0 = tmpOSD.AsString(); |
324 | if (args["teleport_flags"] != null) | 334 | if (args.TryGetValue("teleport_flags", out tmpOSD)) |
325 | teleportFlags = args["teleport_flags"].AsUInteger(); | 335 | teleportFlags = tmpOSD.AsUInteger(); |
326 | 336 | ||
327 | if (args["start_pos"] != null) | 337 | if (args.TryGetValue("start_pos", out tmpOSD)) |
328 | Vector3.TryParse(args["start_pos"].AsString(), out startpos); | 338 | Vector3.TryParse(tmpOSD.AsString(), out startpos); |
339 | |||
340 | if(args.TryGetValue("far", out tmpOSD)) | ||
341 | startfar = (float)tmpOSD.AsReal(); | ||
329 | 342 | ||
330 | //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos); | 343 | //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos); |
331 | 344 | ||
@@ -336,12 +349,12 @@ namespace OpenSim.Framework | |||
336 | 349 | ||
337 | // Eventually this code should be deprecated, use full appearance | 350 | // Eventually this code should be deprecated, use full appearance |
338 | // packing in packed_appearance | 351 | // packing in packed_appearance |
339 | if (args["appearance_serial"] != null) | 352 | if (args.TryGetValue("appearance_serial", out tmpOSD)) |
340 | Appearance.Serial = args["appearance_serial"].AsInteger(); | 353 | Appearance.Serial = tmpOSD.AsInteger(); |
341 | 354 | ||
342 | if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map)) | 355 | if (args.TryGetValue("packed_appearance", out tmpOSD) && (tmpOSD is OSDMap)) |
343 | { | 356 | { |
344 | Appearance.Unpack((OSDMap)args["packed_appearance"]); | 357 | Appearance.Unpack((OSDMap)tmpOSD); |
345 | // m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance"); | 358 | // m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance"); |
346 | } | 359 | } |
347 | else | 360 | else |
@@ -356,31 +369,29 @@ namespace OpenSim.Framework | |||
356 | 369 | ||
357 | ServiceURLs = new Dictionary<string, object>(); | 370 | ServiceURLs = new Dictionary<string, object>(); |
358 | // Try parse the new way, OSDMap | 371 | // Try parse the new way, OSDMap |
359 | if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map) | 372 | if (args.TryGetValue("serviceurls", out tmpOSD) && (tmpOSD is OSDMap)) |
360 | { | 373 | { |
361 | OSDMap urls = (OSDMap)(args["serviceurls"]); | 374 | OSDMap urls = (OSDMap)tmpOSD; |
362 | foreach (KeyValuePair<String, OSD> kvp in urls) | 375 | foreach (KeyValuePair<String, OSD> kvp in urls) |
363 | { | 376 | { |
364 | ServiceURLs[kvp.Key] = kvp.Value.AsString(); | 377 | ServiceURLs[kvp.Key] = kvp.Value; |
365 | //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]); | 378 | //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]); |
366 | |||
367 | } | 379 | } |
368 | } | 380 | } |
369 | // else try the old way, OSDArray | 381 | // else try the old way, OSDArray |
370 | // OBSOLETE -- soon to be deleted | 382 | // OBSOLETE -- soon to be deleted |
371 | else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) | 383 | else if (args.TryGetValue("service_urls", out tmpOSD) && (tmpOSD is OSDArray)) |
372 | { | 384 | { |
373 | OSDArray urls = (OSDArray)(args["service_urls"]); | 385 | OSDArray urls = (OSDArray)tmpOSD; |
374 | for (int i = 0; i < urls.Count / 2; i++) | 386 | OSD tmpOSDb; |
387 | for (int i = 0; i < urls.Count - 1; i += 2) | ||
375 | { | 388 | { |
376 | ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString(); | 389 | tmpOSD = urls[i]; |
390 | tmpOSDb = urls[i + 1]; | ||
391 | ServiceURLs[tmpOSD.AsString()] = tmpOSDb.AsString(); | ||
377 | //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString()); | 392 | //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString()); |
378 | |||
379 | } | 393 | } |
380 | } | 394 | } |
381 | } | 395 | } |
382 | |||
383 | } | 396 | } |
384 | |||
385 | |||
386 | } | 397 | } |
diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs index b6e48b4..2cd11ff 100644 --- a/OpenSim/Framework/AgentCircuitManager.cs +++ b/OpenSim/Framework/AgentCircuitManager.cs | |||
@@ -79,6 +79,7 @@ namespace OpenSim.Framework | |||
79 | user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder; | 79 | user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder; |
80 | user.LoginInfo.BaseFolder = validcircuit.BaseFolder; | 80 | user.LoginInfo.BaseFolder = validcircuit.BaseFolder; |
81 | user.LoginInfo.StartPos = validcircuit.startpos; | 81 | user.LoginInfo.StartPos = validcircuit.startpos; |
82 | user.LoginInfo.StartFar = (float)validcircuit.startfar; | ||
82 | } | 83 | } |
83 | else | 84 | else |
84 | { | 85 | { |
@@ -175,7 +176,8 @@ namespace OpenSim.Framework | |||
175 | { | 176 | { |
176 | m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; | 177 | m_agentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; |
177 | m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; | 178 | m_agentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; |
178 | m_agentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; | 179 | m_agentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos; |
180 | m_agentCircuits[(uint)agentData.circuitcode].startfar = agentData.startfar; | ||
179 | 181 | ||
180 | // Updated for when we don't know them before calling Scene.NewUserConnection | 182 | // Updated for when we don't know them before calling Scene.NewUserConnection |
181 | m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; | 183 | m_agentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID; |
diff --git a/OpenSim/Framework/AgentUpdateArgs.cs b/OpenSim/Framework/AgentUpdateArgs.cs index f04d692..cd1c3a0 100644 --- a/OpenSim/Framework/AgentUpdateArgs.cs +++ b/OpenSim/Framework/AgentUpdateArgs.cs | |||
@@ -83,6 +83,7 @@ namespace OpenSim.Framework | |||
83 | public bool UseClientAgentPosition; | 83 | public bool UseClientAgentPosition; |
84 | public bool NeedsCameraCollision; | 84 | public bool NeedsCameraCollision; |
85 | public uint lastpacketSequence; | 85 | public uint lastpacketSequence; |
86 | public double lastUpdateTS; | ||
86 | 87 | ||
87 | public AgentUpdateArgs() | 88 | public AgentUpdateArgs() |
88 | { | 89 | { |
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 097ad7d..efccc35 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs | |||
@@ -42,11 +42,13 @@ namespace OpenSim.Framework.AssetLoader.Filesystem | |||
42 | public class AssetLoaderFileSystem : IAssetLoader | 42 | public class AssetLoaderFileSystem : IAssetLoader |
43 | { | 43 | { |
44 | private static readonly UUID LIBRARY_OWNER_ID = new UUID("11111111-1111-0000-0000-000100bba000"); | 44 | private static readonly UUID LIBRARY_OWNER_ID = new UUID("11111111-1111-0000-0000-000100bba000"); |
45 | private static readonly string LIBRARY_OWNER_IDstr = "11111111-1111-0000-0000-000100bba000"; | ||
46 | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 48 | ||
47 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) | 49 | protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) |
48 | { | 50 | { |
49 | AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type, LIBRARY_OWNER_ID.ToString()); | 51 | AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type, LIBRARY_OWNER_IDstr); |
50 | 52 | ||
51 | if (!String.IsNullOrEmpty(path)) | 53 | if (!String.IsNullOrEmpty(path)) |
52 | { | 54 | { |
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 77a7621..3973d36 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -51,27 +51,28 @@ namespace OpenSim.Framework | |||
51 | 51 | ||
52 | // this is viewer capabilities and weared things dependent | 52 | // this is viewer capabilities and weared things dependent |
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 const int VISUALPARAM_COUNT = 218; |
55 | 55 | ||
56 | // public readonly static int TEXTURE_COUNT = 21 | 56 | // regions and viewer compatibility |
57 | // 21 bad, make it be updated as libovm gets update | 57 | public readonly static int TEXTURE_COUNT = 45; |
58 | // also keeping in sync with it | 58 | public const int TEXTURE_COUNT_PV7 = 29; |
59 | public readonly static int TEXTURE_COUNT = Primitive.TextureEntry.MAX_FACES; | 59 | public const int BAKES_COUNT_PV7 = 6; |
60 | public const int MAXWEARABLE_PV7 = 16; | ||
61 | public const int MAXWEARABLE_LEGACY = 15; | ||
60 | 62 | ||
61 | public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 63 | public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20, 40, 41, 42, 43, 44 }; |
62 | 64 | ||
63 | protected int m_serial = 0; | 65 | protected int m_serial = 0; |
64 | protected byte[] m_visualparams; | 66 | protected byte[] m_visualparams; |
65 | protected Primitive.TextureEntry m_texture; | 67 | protected Primitive.TextureEntry m_texture; |
66 | protected AvatarWearable[] m_wearables; | 68 | protected AvatarWearable[] m_wearables; |
67 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; | 69 | protected Dictionary<int, List<AvatarAttachment>> m_attachments; |
68 | protected float m_avatarHeight = 0; | 70 | protected WearableCacheItem[] m_cacheitems; |
69 | protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value | 71 | protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value |
70 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); | 72 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); |
73 | protected float m_avatarHeight = 0; | ||
71 | protected float m_avatarFeetOffset = 0; | 74 | protected float m_avatarFeetOffset = 0; |
72 | protected float m_avatarAnimOffset = 0; | 75 | protected float m_avatarAnimOffset = 0; |
73 | protected WearableCacheItem[] m_cacheitems; | ||
74 | protected bool m_cacheItemsDirty = true; | ||
75 | 76 | ||
76 | public virtual int Serial | 77 | public virtual int Serial |
77 | { | 78 | { |
@@ -128,11 +129,7 @@ namespace OpenSim.Framework | |||
128 | set { m_cacheitems = value; } | 129 | set { m_cacheitems = value; } |
129 | } | 130 | } |
130 | 131 | ||
131 | public virtual bool WearableCacheItemsDirty | 132 | public virtual float AvatarPreferencesHoverZ { get; set; } |
132 | { | ||
133 | get { return m_cacheItemsDirty; } | ||
134 | set { m_cacheItemsDirty = value; } | ||
135 | } | ||
136 | 133 | ||
137 | public AvatarAppearance() | 134 | public AvatarAppearance() |
138 | { | 135 | { |
@@ -204,12 +201,14 @@ namespace OpenSim.Framework | |||
204 | SetDefaultParams(); | 201 | SetDefaultParams(); |
205 | // SetHeight(); | 202 | // SetHeight(); |
206 | SetSize(new Vector3(0.45f, 0.6f, 1.9f)); | 203 | SetSize(new Vector3(0.45f, 0.6f, 1.9f)); |
204 | AvatarPreferencesHoverZ = 0; | ||
207 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 205 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
208 | 206 | ||
209 | return; | 207 | return; |
210 | } | 208 | } |
211 | 209 | ||
212 | m_serial = appearance.Serial; | 210 | m_serial = appearance.Serial; |
211 | AvatarPreferencesHoverZ = appearance.AvatarPreferencesHoverZ; | ||
213 | 212 | ||
214 | if (copyWearables && (appearance.Wearables != null)) | 213 | if (copyWearables && (appearance.Wearables != null)) |
215 | { | 214 | { |
@@ -228,7 +227,7 @@ namespace OpenSim.Framework | |||
228 | m_texture = null; | 227 | m_texture = null; |
229 | if (appearance.Texture != null) | 228 | if (appearance.Texture != null) |
230 | { | 229 | { |
231 | byte[] tbytes = appearance.Texture.GetBytes(); | 230 | byte[] tbytes = appearance.Texture.GetBakesBytes(); |
232 | m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); | 231 | m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); |
233 | if (copyBaked && appearance.m_cacheitems != null) | 232 | if (copyBaked && appearance.m_cacheitems != null) |
234 | m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone(); | 233 | m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone(); |
@@ -295,6 +294,7 @@ namespace OpenSim.Framework | |||
295 | m_serial = 0; | 294 | m_serial = 0; |
296 | 295 | ||
297 | SetDefaultTexture(); | 296 | SetDefaultTexture(); |
297 | AvatarPreferencesHoverZ = 0; | ||
298 | 298 | ||
299 | //for (int i = 0; i < BAKE_INDICES.Length; i++) | 299 | //for (int i = 0; i < BAKE_INDICES.Length; i++) |
300 | // { | 300 | // { |
@@ -330,9 +330,6 @@ namespace OpenSim.Framework | |||
330 | protected virtual void SetDefaultTexture() | 330 | protected virtual void SetDefaultTexture() |
331 | { | 331 | { |
332 | m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); | 332 | m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); |
333 | |||
334 | // for (uint i = 0; i < TEXTURE_COUNT; i++) | ||
335 | // m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE); | ||
336 | } | 333 | } |
337 | 334 | ||
338 | /// <summary> | 335 | /// <summary> |
@@ -347,31 +344,31 @@ namespace OpenSim.Framework | |||
347 | if (textureEntry == null) | 344 | if (textureEntry == null) |
348 | return false; | 345 | return false; |
349 | 346 | ||
350 | // There are much simpler versions of this copy that could be | ||
351 | // made. We determine if any of the textures actually | ||
352 | // changed to know if the appearance should be saved later | ||
353 | bool changed = false; | 347 | bool changed = false; |
354 | for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | 348 | Primitive.TextureEntryFace newface; |
355 | { | 349 | Primitive.TextureEntryFace tmpFace; |
356 | Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i]; | ||
357 | Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i]; | ||
358 | 350 | ||
359 | if (newface == null) | 351 | //make sure textureEntry.DefaultTexture is the unused one(DEFAULT_AVATAR_TEXTURE). |
352 | Primitive.TextureEntry converted = new Primitive.TextureEntry(AppearanceManager.DEFAULT_AVATAR_TEXTURE); | ||
353 | for (uint i = 0; i < TEXTURE_COUNT; ++i) | ||
354 | { | ||
355 | newface = textureEntry.GetFace(i); | ||
356 | if (newface.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | ||
360 | { | 357 | { |
361 | if (oldface == null) | 358 | tmpFace = converted.GetFace(i); |
362 | continue; | 359 | tmpFace.TextureID = newface.TextureID; // we need a full high level copy, assuming all other parameters are the same. |
360 | if (m_texture.FaceTextures[i] == null || newface.TextureID != m_texture.FaceTextures[i].TextureID) | ||
361 | changed = true; | ||
363 | } | 362 | } |
364 | else | 363 | else |
365 | { | 364 | { if (m_texture.FaceTextures[i] == null) |
366 | if (oldface != null && oldface.TextureID == newface.TextureID) | ||
367 | continue; | 365 | continue; |
366 | if(m_texture.FaceTextures[i].TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | ||
367 | changed = true; | ||
368 | } | 368 | } |
369 | |||
370 | changed = true; | ||
371 | } | 369 | } |
372 | 370 | if(changed) | |
373 | m_texture = textureEntry; | 371 | m_texture = converted; |
374 | |||
375 | return changed; | 372 | return changed; |
376 | } | 373 | } |
377 | 374 | ||
@@ -736,42 +733,130 @@ namespace OpenSim.Framework | |||
736 | 733 | ||
737 | data["serial"] = OSD.FromInteger(m_serial); | 734 | data["serial"] = OSD.FromInteger(m_serial); |
738 | data["height"] = OSD.FromReal(m_avatarHeight); | 735 | data["height"] = OSD.FromReal(m_avatarHeight); |
736 | data["aphz"] = OSD.FromReal(AvatarPreferencesHoverZ); | ||
737 | |||
738 | if (m_texture == null) | ||
739 | return data; | ||
740 | |||
741 | bool sendPV8 = false; | ||
739 | 742 | ||
740 | // Wearables | 743 | // Wearables |
741 | // | 744 | OSDArray wears; |
742 | // This will send as many or as few wearables as we have, unless a count | 745 | int count; |
743 | // is given. Used for legacy (pre 0.4) versions. | 746 | if (ctx == null) |
744 | int count = ctx.WearablesCount; | 747 | count = MAXWEARABLE_LEGACY; |
745 | if (ctx.WearablesCount == -1) | 748 | else |
746 | count = m_wearables.Length; | ||
747 | OSDArray wears = new OSDArray(count); | ||
748 | for (int i = 0; i < count; i++) | ||
749 | { | 749 | { |
750 | AvatarWearable dummyWearable = new AvatarWearable(); | 750 | if(ctx.OutboundVersion >= 0.8) |
751 | 751 | { | |
752 | if (i < m_wearables.Length) | 752 | sendPV8 = true; |
753 | wears.Add(m_wearables[i].Pack()); | 753 | count = m_wearables.Length; |
754 | } | ||
755 | else if (ctx.OutboundVersion >= 0.6) | ||
756 | count = MAXWEARABLE_PV7; | ||
754 | else | 757 | else |
755 | wears.Add(dummyWearable.Pack()); | 758 | count = MAXWEARABLE_LEGACY; |
759 | |||
760 | if (sendPV8 && count > MAXWEARABLE_PV7) | ||
761 | { | ||
762 | wears = new OSDArray(count - MAXWEARABLE_PV7); | ||
763 | for (int i = MAXWEARABLE_PV7; i < count; ++i) | ||
764 | wears.Add(m_wearables[i].Pack()); | ||
765 | |||
766 | data["wrbls8"] = wears; | ||
767 | count = MAXWEARABLE_PV7; | ||
768 | } | ||
756 | } | 769 | } |
770 | |||
771 | if(count > m_wearables.Length) | ||
772 | count = m_wearables.Length; | ||
773 | |||
774 | wears = new OSDArray(count); | ||
775 | for (int i = 0; i < count; ++i) | ||
776 | wears.Add(m_wearables[i].Pack()); | ||
757 | data["wearables"] = wears; | 777 | data["wearables"] = wears; |
758 | 778 | ||
759 | // Avatar Textures | 779 | // Avatar Textures |
760 | OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT); | 780 | OSDArray textures; |
761 | for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) | 781 | if (sendPV8) |
762 | { | 782 | { |
763 | if (m_texture.FaceTextures[i] != null) | 783 | byte[] te = m_texture.GetBakesBytes(); |
764 | textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID)); | 784 | data["te8"] = OSD.FromBinary(te); |
765 | else | 785 | } |
766 | textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); | 786 | else |
787 | { | ||
788 | textures = new OSDArray(TEXTURE_COUNT_PV7); | ||
789 | for (uint i = 0; i < TEXTURE_COUNT_PV7; ++i) | ||
790 | textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID)); | ||
791 | data["textures"] = textures; | ||
767 | } | 792 | } |
768 | data["textures"] = textures; | ||
769 | 793 | ||
770 | if (m_cacheitems != null) | 794 | if (m_cacheitems != null) |
771 | { | 795 | { |
772 | OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems); | 796 | OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems, 0, BAKES_COUNT_PV7); |
773 | if (baked != null) | 797 | if (baked != null && baked.Count > 0) |
774 | data["bakedcache"] = baked; | 798 | data["bakedcache"] = baked; |
799 | baked = WearableCacheItem.BakedToOSD(m_cacheitems, BAKES_COUNT_PV7, -1); | ||
800 | if (baked != null && baked.Count > 0) | ||
801 | data["bc8"] = baked; | ||
802 | } | ||
803 | |||
804 | // Visual Parameters | ||
805 | OSDBinary visualparams = new OSDBinary(m_visualparams); | ||
806 | data["visualparams"] = visualparams; | ||
807 | |||
808 | lock (m_attachments) | ||
809 | { | ||
810 | // Attachments | ||
811 | OSDArray attachs = new OSDArray(m_attachments.Count); | ||
812 | foreach (AvatarAttachment attach in GetAttachments()) | ||
813 | attachs.Add(attach.Pack()); | ||
814 | data["attachments"] = attachs; | ||
815 | } | ||
816 | |||
817 | return data; | ||
818 | } | ||
819 | |||
820 | public OSDMap PackForNotecard() | ||
821 | { | ||
822 | OSDMap data = new OSDMap(); | ||
823 | |||
824 | data["serial"] = OSD.FromInteger(m_serial); | ||
825 | data["height"] = OSD.FromReal(m_avatarHeight); | ||
826 | data["aphz"] = OSD.FromReal(AvatarPreferencesHoverZ); | ||
827 | |||
828 | // old regions may not like missing/empty wears | ||
829 | OSDArray wears = new OSDArray(MAXWEARABLE_LEGACY); | ||
830 | for (int i = 0; i< MAXWEARABLE_LEGACY; ++i) | ||
831 | wears.Add(new OSDArray()); | ||
832 | data["wearables"] = wears; | ||
833 | |||
834 | // Avatar Textures | ||
835 | OSDArray textures; | ||
836 | |||
837 | // allow old regions to still see something | ||
838 | textures = new OSDArray(TEXTURE_COUNT_PV7); | ||
839 | textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); | ||
840 | for (uint i = 1; i < TEXTURE_COUNT_PV7; ++i) | ||
841 | textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID)); | ||
842 | data["textures"] = textures; | ||
843 | |||
844 | bool needExtra = false; | ||
845 | for (int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; ++i) | ||
846 | { | ||
847 | int idx = BAKE_INDICES[i]; | ||
848 | if (m_texture.FaceTextures[idx] == null) | ||
849 | continue; | ||
850 | if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE || | ||
851 | m_texture.FaceTextures[idx].TextureID == UUID.Zero) | ||
852 | continue; | ||
853 | needExtra = true; | ||
854 | } | ||
855 | |||
856 | if (needExtra) | ||
857 | { | ||
858 | byte[] te = m_texture.GetBakesBytes(); | ||
859 | data["te8"] = OSD.FromBinary(te); | ||
775 | } | 860 | } |
776 | 861 | ||
777 | // Visual Parameters | 862 | // Visual Parameters |
@@ -796,62 +881,108 @@ namespace OpenSim.Framework | |||
796 | /// </summary> | 881 | /// </summary> |
797 | public void Unpack(OSDMap data) | 882 | public void Unpack(OSDMap data) |
798 | { | 883 | { |
799 | if ((data != null) && (data["serial"] != null)) | 884 | SetDefaultWearables(); |
800 | m_serial = data["serial"].AsInteger(); | 885 | SetDefaultTexture(); |
801 | if ((data != null) && (data["height"] != null)) | 886 | SetDefaultParams(); |
802 | // m_avatarHeight = (float)data["height"].AsReal(); | 887 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); |
803 | SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); | ||
804 | 888 | ||
805 | try | 889 | if(data == null) |
806 | { | 890 | { |
807 | // Wearables | 891 | m_log.Warn("[AVATAR APPEARANCE]: data to unpack is null"); |
808 | SetDefaultWearables(); | 892 | return; |
809 | if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) | 893 | } |
810 | { | ||
811 | OSDArray wears = (OSDArray)(data["wearables"]); | ||
812 | 894 | ||
813 | int count = wears.Count; | 895 | OSD tmpOSD; |
896 | if (data.TryGetValue("serial", out tmpOSD)) | ||
897 | m_serial = tmpOSD.AsInteger(); | ||
898 | if(data.TryGetValue("aphz", out tmpOSD)) | ||
899 | AvatarPreferencesHoverZ = (float)tmpOSD.AsReal(); | ||
900 | if (data.TryGetValue("height", out tmpOSD)) | ||
901 | SetSize(new Vector3(0.45f, 0.6f, (float)tmpOSD.AsReal())); | ||
814 | 902 | ||
815 | m_wearables = new AvatarWearable[count]; | 903 | try |
904 | { | ||
905 | // Wearables | ||
906 | OSD tmpOSD8; | ||
907 | OSDArray wears8 = null; | ||
908 | int wears8Count = 0; | ||
816 | 909 | ||
817 | for (int i = 0; i < count; i++) | 910 | if (data.TryGetValue("wrbls8", out tmpOSD8) && (tmpOSD8 is OSDArray)) |
818 | m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); | ||
819 | } | ||
820 | else | ||
821 | { | 911 | { |
822 | m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); | 912 | wears8 = (OSDArray)tmpOSD8; |
913 | wears8Count = wears8.Count; | ||
823 | } | 914 | } |
824 | 915 | ||
825 | // Avatar Textures | 916 | if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray)) |
826 | SetDefaultTexture(); | ||
827 | if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array) | ||
828 | { | 917 | { |
829 | OSDArray textures = (OSDArray)(data["textures"]); | 918 | OSDArray wears = (OSDArray)tmpOSD; |
830 | for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) | 919 | if(wears.Count + wears8Count > 0) |
831 | { | 920 | { |
832 | UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; | 921 | m_wearables = new AvatarWearable[wears.Count + wears8Count]; |
833 | if (textures[i] != null) | 922 | |
834 | textureID = textures[i].AsUUID(); | 923 | for (int i = 0; i < wears.Count; ++i) |
835 | m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); | 924 | m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); |
925 | if (wears8Count > 0) | ||
926 | { | ||
927 | for (int i = 0; i < wears8Count; ++i) | ||
928 | m_wearables[i + wears.Count] = new AvatarWearable((OSDArray)wears8[i]); | ||
929 | } | ||
836 | } | 930 | } |
837 | } | 931 | } |
838 | else | 932 | |
933 | if (data.TryGetValue("te8", out tmpOSD)) | ||
839 | { | 934 | { |
840 | m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); | 935 | byte[] teb = tmpOSD.AsBinary(); |
936 | Primitive.TextureEntry te = new Primitive.TextureEntry(teb, 0, teb.Length); | ||
937 | m_texture = te; | ||
938 | } | ||
939 | else if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray)) | ||
940 | { | ||
941 | OSDArray textures = (OSDArray)tmpOSD; | ||
942 | for (int i = 0; i < textures.Count && i < TEXTURE_COUNT_PV7; ++i) | ||
943 | { | ||
944 | tmpOSD = textures[i]; | ||
945 | if (tmpOSD != null) | ||
946 | m_texture.CreateFace((uint)i).TextureID = tmpOSD.AsUUID(); | ||
947 | } | ||
841 | } | 948 | } |
842 | 949 | ||
843 | if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array) | 950 | if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray)) |
844 | { | 951 | { |
845 | OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]); | 952 | OSDArray bakedOSDArray = (OSDArray)tmpOSD; |
846 | m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray); | 953 | m_cacheitems = WearableCacheItem.GetDefaultCacheItem(); |
954 | |||
955 | bakedOSDArray = (OSDArray)tmpOSD; | ||
956 | foreach (OSDMap item in bakedOSDArray) | ||
957 | { | ||
958 | int idx = item["textureindex"].AsInteger(); | ||
959 | if (idx < 0 || idx >= m_cacheitems.Length) | ||
960 | continue; | ||
961 | m_cacheitems[idx].CacheId = item["cacheid"].AsUUID(); | ||
962 | m_cacheitems[idx].TextureID = item["textureid"].AsUUID(); | ||
963 | m_cacheitems[idx].TextureAsset = null; | ||
964 | } | ||
965 | |||
966 | if (data.TryGetValue("bc8", out tmpOSD) && (tmpOSD is OSDArray)) | ||
967 | { | ||
968 | bakedOSDArray = (OSDArray)tmpOSD; | ||
969 | foreach (OSDMap item in bakedOSDArray) | ||
970 | { | ||
971 | int idx = item["textureindex"].AsInteger(); | ||
972 | if (idx < 0 || idx >= m_cacheitems.Length) | ||
973 | continue; | ||
974 | m_cacheitems[idx].CacheId = item["cacheid"].AsUUID(); | ||
975 | m_cacheitems[idx].TextureID = item["textureid"].AsUUID(); | ||
976 | m_cacheitems[idx].TextureAsset = null; | ||
977 | } | ||
978 | } | ||
847 | } | 979 | } |
848 | 980 | ||
849 | // Visual Parameters | 981 | // Visual Parameters |
850 | SetDefaultParams(); | 982 | if (data.TryGetValue("visualparams", out tmpOSD)) |
851 | if ((data != null) && (data["visualparams"] != null)) | ||
852 | { | 983 | { |
853 | if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array)) | 984 | if (tmpOSD is OSDBinary || tmpOSD is OSDArray) |
854 | m_visualparams = data["visualparams"].AsBinary(); | 985 | m_visualparams = tmpOSD.AsBinary(); |
855 | } | 986 | } |
856 | else | 987 | else |
857 | { | 988 | { |
@@ -859,10 +990,9 @@ namespace OpenSim.Framework | |||
859 | } | 990 | } |
860 | 991 | ||
861 | // Attachments | 992 | // Attachments |
862 | m_attachments = new Dictionary<int, List<AvatarAttachment>>(); | 993 | if (data.TryGetValue("attachments", out tmpOSD) && tmpOSD is OSDArray) |
863 | if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array) | ||
864 | { | 994 | { |
865 | OSDArray attachs = (OSDArray)(data["attachments"]); | 995 | OSDArray attachs = (OSDArray)tmpOSD; |
866 | for (int i = 0; i < attachs.Count; i++) | 996 | for (int i = 0; i < attachs.Count; i++) |
867 | { | 997 | { |
868 | AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); | 998 | AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]); |
@@ -882,6 +1012,32 @@ namespace OpenSim.Framework | |||
882 | 1012 | ||
883 | #endregion | 1013 | #endregion |
884 | 1014 | ||
1015 | public bool CanTeleport(float version) | ||
1016 | { | ||
1017 | if (version >= 0.8) | ||
1018 | return true; | ||
1019 | if (m_wearables.Length <= MAXWEARABLE_PV7) | ||
1020 | return true; | ||
1021 | for(int i = MAXWEARABLE_PV7; i < m_wearables.Length; ++i) | ||
1022 | { | ||
1023 | if(m_wearables[i].Count > 0) | ||
1024 | return false; | ||
1025 | } | ||
1026 | |||
1027 | // also check baked | ||
1028 | for (int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; i++) | ||
1029 | { | ||
1030 | int idx = BAKE_INDICES[i]; | ||
1031 | if (m_texture.FaceTextures[idx] == null) | ||
1032 | continue; | ||
1033 | if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE || | ||
1034 | m_texture.FaceTextures[idx].TextureID == UUID.Zero) | ||
1035 | continue; | ||
1036 | return false; | ||
1037 | } | ||
1038 | return true; | ||
1039 | } | ||
1040 | |||
885 | #region VPElement | 1041 | #region VPElement |
886 | 1042 | ||
887 | /// <summary> | 1043 | /// <summary> |
diff --git a/OpenSim/Framework/AvatarAttachment.cs b/OpenSim/Framework/AvatarAttachment.cs index 07dd385..d8a0ffc 100644 --- a/OpenSim/Framework/AvatarAttachment.cs +++ b/OpenSim/Framework/AvatarAttachment.cs | |||
@@ -68,11 +68,18 @@ namespace OpenSim.Framework | |||
68 | 68 | ||
69 | public void Unpack(OSDMap args) | 69 | public void Unpack(OSDMap args) |
70 | { | 70 | { |
71 | if (args["point"] != null) | 71 | OSD tmpOSD; |
72 | AttachPoint = args["point"].AsInteger(); | 72 | if (args.TryGetValue("point", out tmpOSD)) |
73 | AttachPoint = tmpOSD.AsInteger(); | ||
74 | if (args.TryGetValue("item", out tmpOSD)) | ||
75 | ItemID = tmpOSD.AsUUID(); | ||
76 | else | ||
77 | ItemID = UUID.Zero; | ||
73 | 78 | ||
74 | ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero; | 79 | if (args.TryGetValue("asset", out tmpOSD)) |
75 | AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero; | 80 | AssetID = tmpOSD.AsUUID(); |
81 | else | ||
82 | AssetID = UUID.Zero; | ||
76 | } | 83 | } |
77 | } | 84 | } |
78 | } | 85 | } |
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs index 0e8f960..1733559 100644 --- a/OpenSim/Framework/AvatarWearable.cs +++ b/OpenSim/Framework/AvatarWearable.cs | |||
@@ -67,10 +67,14 @@ namespace OpenSim.Framework | |||
67 | 67 | ||
68 | public static readonly int ALPHA = 13; | 68 | public static readonly int ALPHA = 13; |
69 | public static readonly int TATTOO = 14; | 69 | public static readonly int TATTOO = 14; |
70 | |||
71 | public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15; | 70 | public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15; |
72 | // public static readonly int PHYSICS = 15; | 71 | |
73 | // public static int MAX_WEARABLES = 16; | 72 | public static readonly int PHYSICS = 15; |
73 | |||
74 | public static int MAX_WEARABLES_PV7 = 16; | ||
75 | |||
76 | public static readonly int UNIVERSAL = 16; | ||
77 | public static int MAX_WEARABLES = 17; | ||
74 | 78 | ||
75 | 79 | ||
76 | public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); | 80 | public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); |
@@ -91,11 +95,11 @@ namespace OpenSim.Framework | |||
91 | public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111"); | 95 | public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111"); |
92 | public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120"); | 96 | public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120"); |
93 | 97 | ||
94 | // public static readonly UUID DEFAULT_ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8"); | 98 | public static readonly UUID DEFAULT_ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8"); |
95 | // public static readonly UUID DEFAULT_ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594"); | 99 | public static readonly UUID DEFAULT_ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594"); |
96 | 100 | ||
97 | // public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1"); | 101 | public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1"); |
98 | // public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007"); | 102 | public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007"); |
99 | 103 | ||
100 | protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); | 104 | protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); |
101 | protected List<UUID> m_ids = new List<UUID>(); | 105 | protected List<UUID> m_ids = new List<UUID>(); |
@@ -132,10 +136,12 @@ namespace OpenSim.Framework | |||
132 | public void Unpack(OSDArray args) | 136 | public void Unpack(OSDArray args) |
133 | { | 137 | { |
134 | Clear(); | 138 | Clear(); |
135 | 139 | OSD tmpOSDA, tmpOSDB; | |
136 | foreach (OSDMap weardata in args) | 140 | foreach (OSDMap weardata in args) |
137 | { | 141 | { |
138 | Add(weardata["item"].AsUUID(), weardata["asset"].AsUUID()); | 142 | tmpOSDA = weardata["item"]; |
143 | tmpOSDB = weardata["asset"]; | ||
144 | Add(tmpOSDA.AsUUID(), tmpOSDB.AsUUID()); | ||
139 | } | 145 | } |
140 | } | 146 | } |
141 | 147 | ||
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs deleted file mode 100644 index 2461049..0000000 --- a/OpenSim/Framework/BlockingQueue.cs +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Threading; | ||
30 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | public class BlockingQueue<T> | ||
34 | { | ||
35 | private readonly Queue<T> m_pqueue = new Queue<T>(); | ||
36 | private readonly Queue<T> m_queue = new Queue<T>(); | ||
37 | private readonly object m_queueSync = new object(); | ||
38 | |||
39 | public void PriorityEnqueue(T value) | ||
40 | { | ||
41 | lock (m_queueSync) | ||
42 | { | ||
43 | m_pqueue.Enqueue(value); | ||
44 | Monitor.Pulse(m_queueSync); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public void Enqueue(T value) | ||
49 | { | ||
50 | lock (m_queueSync) | ||
51 | { | ||
52 | m_queue.Enqueue(value); | ||
53 | Monitor.Pulse(m_queueSync); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | public T Dequeue() | ||
58 | { | ||
59 | lock (m_queueSync) | ||
60 | { | ||
61 | while (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
62 | { | ||
63 | Monitor.Wait(m_queueSync); | ||
64 | } | ||
65 | |||
66 | if (m_pqueue.Count > 0) | ||
67 | return m_pqueue.Dequeue(); | ||
68 | |||
69 | if (m_queue.Count > 0) | ||
70 | return m_queue.Dequeue(); | ||
71 | return default(T); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public T Dequeue(int msTimeout) | ||
76 | { | ||
77 | lock (m_queueSync) | ||
78 | { | ||
79 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
80 | { | ||
81 | if(!Monitor.Wait(m_queueSync, msTimeout)) | ||
82 | return default(T); | ||
83 | } | ||
84 | |||
85 | if (m_pqueue.Count > 0) | ||
86 | return m_pqueue.Dequeue(); | ||
87 | if (m_queue.Count > 0) | ||
88 | return m_queue.Dequeue(); | ||
89 | return default(T); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
94 | /// Indicate whether this queue contains the given item. | ||
95 | /// </summary> | ||
96 | /// <remarks> | ||
97 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
98 | /// </remarks> | ||
99 | public bool Contains(T item) | ||
100 | { | ||
101 | lock (m_queueSync) | ||
102 | { | ||
103 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
104 | return false; | ||
105 | |||
106 | if (m_pqueue.Contains(item)) | ||
107 | return true; | ||
108 | return m_queue.Contains(item); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Return a count of the number of requests on this queue. | ||
114 | /// </summary> | ||
115 | public int Count() | ||
116 | { | ||
117 | lock (m_queueSync) | ||
118 | return m_queue.Count + m_pqueue.Count; | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Return the array of items on this queue. | ||
123 | /// </summary> | ||
124 | /// <remarks> | ||
125 | /// This method is not thread-safe. Do not rely on the result without consistent external locking. | ||
126 | /// </remarks> | ||
127 | public T[] GetQueueArray() | ||
128 | { | ||
129 | lock (m_queueSync) | ||
130 | { | ||
131 | if (m_queue.Count < 1 && m_pqueue.Count < 1) | ||
132 | return new T[0]; | ||
133 | |||
134 | return m_queue.ToArray(); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public void Clear() | ||
139 | { | ||
140 | lock (m_queueSync) | ||
141 | { | ||
142 | m_pqueue.Clear(); | ||
143 | m_queue.Clear(); | ||
144 | Monitor.Pulse(m_queueSync); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | } | ||
diff --git a/OpenSim/Framework/ChatTypeEnum.cs b/OpenSim/Framework/ChatTypeEnum.cs index b7e4e7c..f281f5c 100644 --- a/OpenSim/Framework/ChatTypeEnum.cs +++ b/OpenSim/Framework/ChatTypeEnum.cs | |||
@@ -38,6 +38,7 @@ namespace OpenSim.Framework | |||
38 | DebugChannel = 6, | 38 | DebugChannel = 6, |
39 | Region = 7, | 39 | Region = 7, |
40 | Owner = 8, | 40 | Owner = 8, |
41 | Direct = 9, //llRegionSayTo | ||
41 | Broadcast = 0xFF | 42 | Broadcast = 0xFF |
42 | } | 43 | } |
43 | } \ No newline at end of file | 44 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index ee5007a..2d00296 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -398,7 +398,8 @@ namespace OpenSim.Framework | |||
398 | // Scripted | 398 | // Scripted |
399 | public ControllerData[] Controllers; | 399 | public ControllerData[] Controllers; |
400 | 400 | ||
401 | public string CallbackURI; | 401 | public string CallbackURI; // to remove |
402 | public string NewCallbackURI; | ||
402 | 403 | ||
403 | // These two must have the same Count | 404 | // These two must have the same Count |
404 | public List<ISceneObject> AttachmentObjects; | 405 | public List<ISceneObject> AttachmentObjects; |
@@ -528,6 +529,9 @@ namespace OpenSim.Framework | |||
528 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) | 529 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) |
529 | args["callback_uri"] = OSD.FromString(CallbackURI); | 530 | args["callback_uri"] = OSD.FromString(CallbackURI); |
530 | 531 | ||
532 | if ((NewCallbackURI != null) && (!NewCallbackURI.Equals(""))) | ||
533 | args["cb_uri"] = OSD.FromString(NewCallbackURI); | ||
534 | |||
531 | // Attachment objects for fatpack messages | 535 | // Attachment objects for fatpack messages |
532 | if (AttachmentObjects != null) | 536 | if (AttachmentObjects != null) |
533 | { | 537 | { |
@@ -811,12 +815,7 @@ namespace OpenSim.Framework | |||
811 | } | 815 | } |
812 | // end of code to remove | 816 | // end of code to remove |
813 | } | 817 | } |
814 | /* moved above | 818 | |
815 | if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) | ||
816 | Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); | ||
817 | else | ||
818 | m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); | ||
819 | */ | ||
820 | if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) | 819 | if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) |
821 | { | 820 | { |
822 | OSDArray controls = (OSDArray)(args["controllers"]); | 821 | OSDArray controls = (OSDArray)(args["controllers"]); |
@@ -834,6 +833,9 @@ namespace OpenSim.Framework | |||
834 | if (args["callback_uri"] != null) | 833 | if (args["callback_uri"] != null) |
835 | CallbackURI = args["callback_uri"].AsString(); | 834 | CallbackURI = args["callback_uri"].AsString(); |
836 | 835 | ||
836 | if (args["cb_uri"] != null) | ||
837 | NewCallbackURI = args["cb_uri"].AsString(); | ||
838 | |||
837 | // Attachment objects | 839 | // Attachment objects |
838 | if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) | 840 | if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) |
839 | { | 841 | { |
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index 45c54e4..1508c7f 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs | |||
@@ -51,7 +51,14 @@ namespace OpenSim.Framework | |||
51 | private object m_syncRoot = new object(); | 51 | private object m_syncRoot = new object(); |
52 | 52 | ||
53 | /// <summary>Number of clients in the collection</summary> | 53 | /// <summary>Number of clients in the collection</summary> |
54 | public int Count { get { return m_dict1.Count; } } | 54 | public int Count |
55 | { | ||
56 | get | ||
57 | { | ||
58 | lock (m_syncRoot) | ||
59 | return m_dict1.Count; | ||
60 | } | ||
61 | } | ||
55 | 62 | ||
56 | /// <summary> | 63 | /// <summary> |
57 | /// Default constructor | 64 | /// Default constructor |
@@ -60,7 +67,7 @@ namespace OpenSim.Framework | |||
60 | { | 67 | { |
61 | m_dict1 = new Dictionary<UUID, IClientAPI>(); | 68 | m_dict1 = new Dictionary<UUID, IClientAPI>(); |
62 | m_dict2 = new Dictionary<IPEndPoint, IClientAPI>(); | 69 | m_dict2 = new Dictionary<IPEndPoint, IClientAPI>(); |
63 | m_array = new IClientAPI[0]; | 70 | m_array = null; |
64 | } | 71 | } |
65 | 72 | ||
66 | /// <summary> | 73 | /// <summary> |
@@ -74,17 +81,9 @@ namespace OpenSim.Framework | |||
74 | { | 81 | { |
75 | lock (m_syncRoot) | 82 | lock (m_syncRoot) |
76 | { | 83 | { |
77 | // allow self healing | ||
78 | // if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint)) | ||
79 | // return false; | ||
80 | |||
81 | m_dict1[value.AgentId] = value; | 84 | m_dict1[value.AgentId] = value; |
82 | m_dict2[value.RemoteEndPoint] = value; | 85 | m_dict2[value.RemoteEndPoint] = value; |
83 | 86 | m_array = null; | |
84 | // dict1 is the master | ||
85 | IClientAPI[] newArray = new IClientAPI[m_dict1.Count]; | ||
86 | m_dict1.Values.CopyTo(newArray, 0); | ||
87 | m_array = newArray; | ||
88 | } | 87 | } |
89 | 88 | ||
90 | return true; | 89 | return true; |
@@ -105,10 +104,7 @@ namespace OpenSim.Framework | |||
105 | { | 104 | { |
106 | m_dict1.Remove(key); | 105 | m_dict1.Remove(key); |
107 | m_dict2.Remove(value.RemoteEndPoint); | 106 | m_dict2.Remove(value.RemoteEndPoint); |
108 | 107 | m_array = null; | |
109 | IClientAPI[] newArray = new IClientAPI[m_dict1.Count]; | ||
110 | m_dict1.Values.CopyTo(newArray, 0); | ||
111 | m_array = newArray; | ||
112 | return true; | 108 | return true; |
113 | } | 109 | } |
114 | } | 110 | } |
@@ -124,7 +120,7 @@ namespace OpenSim.Framework | |||
124 | { | 120 | { |
125 | m_dict1.Clear(); | 121 | m_dict1.Clear(); |
126 | m_dict2.Clear(); | 122 | m_dict2.Clear(); |
127 | m_array = new IClientAPI[0]; | 123 | m_array = null; |
128 | } | 124 | } |
129 | } | 125 | } |
130 | 126 | ||
@@ -135,7 +131,8 @@ namespace OpenSim.Framework | |||
135 | /// <returns>True if the UUID was found in the collection, otherwise false</returns> | 131 | /// <returns>True if the UUID was found in the collection, otherwise false</returns> |
136 | public bool ContainsKey(UUID key) | 132 | public bool ContainsKey(UUID key) |
137 | { | 133 | { |
138 | return m_dict1.ContainsKey(key); | 134 | lock (m_syncRoot) |
135 | return m_dict1.ContainsKey(key); | ||
139 | } | 136 | } |
140 | 137 | ||
141 | /// <summary> | 138 | /// <summary> |
@@ -145,7 +142,8 @@ namespace OpenSim.Framework | |||
145 | /// <returns>True if the endpoint was found in the collection, otherwise false</returns> | 142 | /// <returns>True if the endpoint was found in the collection, otherwise false</returns> |
146 | public bool ContainsKey(IPEndPoint key) | 143 | public bool ContainsKey(IPEndPoint key) |
147 | { | 144 | { |
148 | return m_dict2.ContainsKey(key); | 145 | lock (m_syncRoot) |
146 | return m_dict2.ContainsKey(key); | ||
149 | } | 147 | } |
150 | 148 | ||
151 | /// <summary> | 149 | /// <summary> |
@@ -156,8 +154,12 @@ namespace OpenSim.Framework | |||
156 | /// <returns>True if the lookup succeeded, otherwise false</returns> | 154 | /// <returns>True if the lookup succeeded, otherwise false</returns> |
157 | public bool TryGetValue(UUID key, out IClientAPI value) | 155 | public bool TryGetValue(UUID key, out IClientAPI value) |
158 | { | 156 | { |
159 | try { return m_dict1.TryGetValue(key, out value); } | 157 | try |
160 | catch (Exception) | 158 | { |
159 | lock (m_syncRoot) | ||
160 | return m_dict1.TryGetValue(key, out value); | ||
161 | } | ||
162 | catch | ||
161 | { | 163 | { |
162 | value = null; | 164 | value = null; |
163 | return false; | 165 | return false; |
@@ -172,8 +174,12 @@ namespace OpenSim.Framework | |||
172 | /// <returns>True if the lookup succeeded, otherwise false</returns> | 174 | /// <returns>True if the lookup succeeded, otherwise false</returns> |
173 | public bool TryGetValue(IPEndPoint key, out IClientAPI value) | 175 | public bool TryGetValue(IPEndPoint key, out IClientAPI value) |
174 | { | 176 | { |
175 | try { return m_dict2.TryGetValue(key, out value); } | 177 | try |
176 | catch (Exception) | 178 | { |
179 | lock (m_syncRoot) | ||
180 | return m_dict2.TryGetValue(key, out value); | ||
181 | } | ||
182 | catch | ||
177 | { | 183 | { |
178 | value = null; | 184 | value = null; |
179 | return false; | 185 | return false; |
@@ -187,7 +193,20 @@ namespace OpenSim.Framework | |||
187 | /// <param name="action">Action to perform on each element</param> | 193 | /// <param name="action">Action to perform on each element</param> |
188 | public void ForEach(Action<IClientAPI> action) | 194 | public void ForEach(Action<IClientAPI> action) |
189 | { | 195 | { |
190 | IClientAPI[] localArray = m_array; | 196 | IClientAPI[] localArray; |
197 | lock (m_syncRoot) | ||
198 | { | ||
199 | if (m_array == null) | ||
200 | { | ||
201 | if (m_dict1.Count == 0) | ||
202 | return; | ||
203 | |||
204 | m_array = new IClientAPI[m_dict1.Count]; | ||
205 | m_dict1.Values.CopyTo(m_array, 0); | ||
206 | } | ||
207 | localArray = m_array; | ||
208 | } | ||
209 | |||
191 | for (int i = 0; i < localArray.Length; i++) | 210 | for (int i = 0; i < localArray.Length; i++) |
192 | action(localArray[i]); | 211 | action(localArray[i]); |
193 | } | 212 | } |
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs index 7afa68a..32c6a3e 100644 --- a/OpenSim/Framework/ConfigurationMember.cs +++ b/OpenSim/Framework/ConfigurationMember.cs | |||
@@ -262,14 +262,14 @@ namespace OpenSim.Framework | |||
262 | if (configurationDescription.Trim() != String.Empty) | 262 | if (configurationDescription.Trim() != String.Empty) |
263 | { | 263 | { |
264 | console_result = | 264 | console_result = |
265 | MainConsole.Instance.CmdPrompt( | 265 | MainConsole.Instance.Prompt( |
266 | configurationDescription + ": " + configOption.configurationQuestion, | 266 | configurationDescription + ": " + configOption.configurationQuestion, |
267 | configOption.configurationDefault); | 267 | configOption.configurationDefault); |
268 | } | 268 | } |
269 | else | 269 | else |
270 | { | 270 | { |
271 | console_result = | 271 | console_result = |
272 | MainConsole.Instance.CmdPrompt(configOption.configurationQuestion, | 272 | MainConsole.Instance.Prompt(configOption.configurationQuestion, |
273 | configOption.configurationDefault); | 273 | configOption.configurationDefault); |
274 | } | 274 | } |
275 | } | 275 | } |
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 52360b4..d2b6618 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -36,6 +36,7 @@ using System.Text.RegularExpressions; | |||
36 | using System.Threading; | 36 | using System.Threading; |
37 | using log4net; | 37 | using log4net; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using Nini.Config; | ||
39 | 40 | ||
40 | namespace OpenSim.Framework.Console | 41 | namespace OpenSim.Framework.Console |
41 | { | 42 | { |
@@ -789,5 +790,9 @@ namespace OpenSim.Framework.Console | |||
789 | } | 790 | } |
790 | return cmdinput; | 791 | return cmdinput; |
791 | } | 792 | } |
793 | |||
794 | public virtual void ReadConfig(IConfigSource configSource) | ||
795 | { | ||
796 | } | ||
792 | } | 797 | } |
793 | } | 798 | } |
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 64cddea..8748b25 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -35,13 +35,39 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework.Console | 36 | namespace OpenSim.Framework.Console |
37 | { | 37 | { |
38 | public class ConsoleBase | 38 | public class ConsoleLevel |
39 | { | ||
40 | public string m_string; | ||
41 | |||
42 | ConsoleLevel(string v) | ||
43 | { | ||
44 | m_string = v; | ||
45 | } | ||
46 | |||
47 | static public implicit operator ConsoleLevel(string s) | ||
48 | { | ||
49 | return new ConsoleLevel(s); | ||
50 | } | ||
51 | |||
52 | public static string ToString(ConsoleLevel s) | ||
53 | { | ||
54 | return s.m_string; | ||
55 | } | ||
56 | |||
57 | public override string ToString() | ||
58 | { | ||
59 | return m_string; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | public class ConsoleBase : IConsole | ||
39 | { | 65 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 67 | ||
42 | protected string prompt = "# "; | 68 | protected string prompt = "# "; |
43 | 69 | ||
44 | public object ConsoleScene { get; set; } | 70 | public IScene ConsoleScene { get; set; } |
45 | 71 | ||
46 | public string DefaultPrompt { get; set; } | 72 | public string DefaultPrompt { get; set; } |
47 | 73 | ||
@@ -58,27 +84,47 @@ namespace OpenSim.Framework.Console | |||
58 | { | 84 | { |
59 | } | 85 | } |
60 | 86 | ||
61 | public virtual void Output(string text, string level) | 87 | public void Output(string format) |
62 | { | 88 | { |
63 | Output(text); | 89 | System.Console.WriteLine(format); |
64 | } | 90 | } |
65 | 91 | ||
66 | public virtual void Output(string text) | 92 | public virtual void Output(string format, params object[] components) |
67 | { | 93 | { |
68 | System.Console.WriteLine(text); | 94 | string level = null; |
69 | } | 95 | if (components != null && components.Length > 0) |
96 | { | ||
97 | if (components[0] == null || components[0] is ConsoleLevel) | ||
98 | { | ||
99 | if (components[0] is ConsoleLevel) | ||
100 | level = ((ConsoleLevel)components[0]).ToString(); | ||
70 | 101 | ||
71 | public virtual void OutputFormat(string format, params object[] components) | 102 | if (components.Length > 1) |
72 | { | 103 | { |
73 | Output(string.Format(format, components)); | 104 | object[] tmp = new object[components.Length - 1]; |
105 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
106 | components = tmp; | ||
107 | } | ||
108 | else | ||
109 | components = null; | ||
110 | } | ||
111 | |||
112 | } | ||
113 | string text; | ||
114 | if (components == null || components.Length == 0) | ||
115 | text = format; | ||
116 | else | ||
117 | text = String.Format(format, components); | ||
118 | |||
119 | System.Console.WriteLine(text); | ||
74 | } | 120 | } |
75 | 121 | ||
76 | public string CmdPrompt(string p) | 122 | public string Prompt(string p) |
77 | { | 123 | { |
78 | return ReadLine(String.Format("{0}: ", p), false, true); | 124 | return ReadLine(String.Format("{0}: ", p), false, true); |
79 | } | 125 | } |
80 | 126 | ||
81 | public string CmdPrompt(string p, string def) | 127 | public string Prompt(string p, string def) |
82 | { | 128 | { |
83 | string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); | 129 | string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); |
84 | if (ret == String.Empty) | 130 | if (ret == String.Empty) |
@@ -87,14 +133,14 @@ namespace OpenSim.Framework.Console | |||
87 | return ret; | 133 | return ret; |
88 | } | 134 | } |
89 | 135 | ||
90 | public string CmdPrompt(string p, List<char> excludedCharacters) | 136 | public string Prompt(string p, List<char> excludedCharacters) |
91 | { | 137 | { |
92 | bool itisdone = false; | 138 | bool itisdone = false; |
93 | string ret = String.Empty; | 139 | string ret = String.Empty; |
94 | while (!itisdone) | 140 | while (!itisdone) |
95 | { | 141 | { |
96 | itisdone = true; | 142 | itisdone = true; |
97 | ret = CmdPrompt(p); | 143 | ret = Prompt(p); |
98 | 144 | ||
99 | foreach (char c in excludedCharacters) | 145 | foreach (char c in excludedCharacters) |
100 | { | 146 | { |
@@ -109,27 +155,34 @@ namespace OpenSim.Framework.Console | |||
109 | return ret; | 155 | return ret; |
110 | } | 156 | } |
111 | 157 | ||
112 | public string CmdPrompt(string p, string def, List<char> excludedCharacters) | 158 | public virtual string Prompt(string p, string def, List<char> excludedCharacters, bool echo = true) |
113 | { | 159 | { |
114 | bool itisdone = false; | 160 | bool itisdone = false; |
115 | string ret = String.Empty; | 161 | string ret = String.Empty; |
116 | while (!itisdone) | 162 | while (!itisdone) |
117 | { | 163 | { |
118 | itisdone = true; | 164 | itisdone = true; |
119 | ret = CmdPrompt(p, def); | ||
120 | 165 | ||
121 | if (ret == String.Empty) | 166 | if (def == null) |
167 | ret = ReadLine(String.Format("{0}: ", p), false, echo); | ||
168 | else | ||
169 | ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, echo); | ||
170 | |||
171 | if (ret == String.Empty && def != null) | ||
122 | { | 172 | { |
123 | ret = def; | 173 | ret = def; |
124 | } | 174 | } |
125 | else | 175 | else |
126 | { | 176 | { |
127 | foreach (char c in excludedCharacters) | 177 | if (excludedCharacters != null) |
128 | { | 178 | { |
129 | if (ret.Contains(c.ToString())) | 179 | foreach (char c in excludedCharacters) |
130 | { | 180 | { |
131 | System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); | 181 | if (ret.Contains(c.ToString())) |
132 | itisdone = false; | 182 | { |
183 | System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); | ||
184 | itisdone = false; | ||
185 | } | ||
133 | } | 186 | } |
134 | } | 187 | } |
135 | } | 188 | } |
@@ -139,14 +192,14 @@ namespace OpenSim.Framework.Console | |||
139 | } | 192 | } |
140 | 193 | ||
141 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | 194 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options |
142 | public string CmdPrompt(string prompt, string defaultresponse, List<string> options) | 195 | public virtual string Prompt(string prompt, string defaultresponse, List<string> options) |
143 | { | 196 | { |
144 | bool itisdone = false; | 197 | bool itisdone = false; |
145 | string optstr = String.Empty; | 198 | string optstr = String.Empty; |
146 | foreach (string s in options) | 199 | foreach (string s in options) |
147 | optstr += " " + s; | 200 | optstr += " " + s; |
148 | 201 | ||
149 | string temp = CmdPrompt(prompt, defaultresponse); | 202 | string temp = Prompt(prompt, defaultresponse); |
150 | while (itisdone == false) | 203 | while (itisdone == false) |
151 | { | 204 | { |
152 | if (options.Contains(temp)) | 205 | if (options.Contains(temp)) |
@@ -156,19 +209,12 @@ namespace OpenSim.Framework.Console | |||
156 | else | 209 | else |
157 | { | 210 | { |
158 | System.Console.WriteLine("Valid options are" + optstr); | 211 | System.Console.WriteLine("Valid options are" + optstr); |
159 | temp = CmdPrompt(prompt, defaultresponse); | 212 | temp = Prompt(prompt, defaultresponse); |
160 | } | 213 | } |
161 | } | 214 | } |
162 | return temp; | 215 | return temp; |
163 | } | 216 | } |
164 | 217 | ||
165 | // Displays a prompt and waits for the user to enter a string, then returns that string | ||
166 | // (Done with no echo and suitable for passwords) | ||
167 | public string PasswdPrompt(string p) | ||
168 | { | ||
169 | return ReadLine(String.Format("{0}: ", p), false, false); | ||
170 | } | ||
171 | |||
172 | public virtual string ReadLine(string p, bool isCommand, bool e) | 218 | public virtual string ReadLine(string p, bool isCommand, bool e) |
173 | { | 219 | { |
174 | System.Console.Write("{0}", p); | 220 | System.Console.Write("{0}", p); |
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index bfa05a2..2f73a8d 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Console | |||
75 | { | 75 | { |
76 | if (File.Exists(path)) | 76 | if (File.Exists(path)) |
77 | { | 77 | { |
78 | console.OutputFormat("File {0} already exists. Please move or remove it.", path); | 78 | console.Output("File {0} already exists. Please move or remove it.", path); |
79 | return false; | 79 | return false; |
80 | } | 80 | } |
81 | 81 | ||
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console | |||
97 | if (!UUID.TryParse(rawUuid, out uuid)) | 97 | if (!UUID.TryParse(rawUuid, out uuid)) |
98 | { | 98 | { |
99 | if (console != null) | 99 | if (console != null) |
100 | console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); | 100 | console.Output("ERROR: {0} is not a valid uuid", rawUuid); |
101 | 101 | ||
102 | return false; | 102 | return false; |
103 | } | 103 | } |
@@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console | |||
110 | if (!uint.TryParse(rawLocalId, out localId)) | 110 | if (!uint.TryParse(rawLocalId, out localId)) |
111 | { | 111 | { |
112 | if (console != null) | 112 | if (console != null) |
113 | console.OutputFormat("ERROR: {0} is not a valid local id", localId); | 113 | console.Output("ERROR: {0} is not a valid local id", localId); |
114 | 114 | ||
115 | return false; | 115 | return false; |
116 | } | 116 | } |
@@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console | |||
118 | if (localId == 0) | 118 | if (localId == 0) |
119 | { | 119 | { |
120 | if (console != null) | 120 | if (console != null) |
121 | console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); | 121 | console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", localId); |
122 | 122 | ||
123 | return false; | 123 | return false; |
124 | } | 124 | } |
@@ -150,7 +150,7 @@ namespace OpenSim.Framework.Console | |||
150 | } | 150 | } |
151 | 151 | ||
152 | if (console != null) | 152 | if (console != null) |
153 | console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); | 153 | console.Output("ERROR: {0} is not a valid UUID or local id", rawId); |
154 | 154 | ||
155 | return false; | 155 | return false; |
156 | } | 156 | } |
@@ -167,7 +167,7 @@ namespace OpenSim.Framework.Console | |||
167 | if (!bool.TryParse(rawConsoleString, out b)) | 167 | if (!bool.TryParse(rawConsoleString, out b)) |
168 | { | 168 | { |
169 | if (console != null) | 169 | if (console != null) |
170 | console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); | 170 | console.Output("ERROR: {0} is not a true or false value", rawConsoleString); |
171 | 171 | ||
172 | return false; | 172 | return false; |
173 | } | 173 | } |
@@ -187,7 +187,7 @@ namespace OpenSim.Framework.Console | |||
187 | if (!int.TryParse(rawConsoleInt, out i)) | 187 | if (!int.TryParse(rawConsoleInt, out i)) |
188 | { | 188 | { |
189 | if (console != null) | 189 | if (console != null) |
190 | console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); | 190 | console.Output("ERROR: {0} is not a valid integer", rawConsoleInt); |
191 | 191 | ||
192 | return false; | 192 | return false; |
193 | } | 193 | } |
@@ -207,7 +207,7 @@ namespace OpenSim.Framework.Console | |||
207 | if (!float.TryParse(rawConsoleInput, out i)) | 207 | if (!float.TryParse(rawConsoleInput, out i)) |
208 | { | 208 | { |
209 | if (console != null) | 209 | if (console != null) |
210 | console.OutputFormat("ERROR: {0} is not a valid float", rawConsoleInput); | 210 | console.Output("ERROR: {0} is not a valid float", rawConsoleInput); |
211 | 211 | ||
212 | return false; | 212 | return false; |
213 | } | 213 | } |
@@ -227,7 +227,7 @@ namespace OpenSim.Framework.Console | |||
227 | if (!double.TryParse(rawConsoleInput, out i)) | 227 | if (!double.TryParse(rawConsoleInput, out i)) |
228 | { | 228 | { |
229 | if (console != null) | 229 | if (console != null) |
230 | console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); | 230 | console.Output("ERROR: {0} is not a valid double", rawConsoleInput); |
231 | 231 | ||
232 | return false; | 232 | return false; |
233 | } | 233 | } |
@@ -249,7 +249,7 @@ namespace OpenSim.Framework.Console | |||
249 | if (i < 0) | 249 | if (i < 0) |
250 | { | 250 | { |
251 | if (console != null) | 251 | if (console != null) |
252 | console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); | 252 | console.Output("ERROR: {0} is not a positive integer", rawConsoleInt); |
253 | 253 | ||
254 | return false; | 254 | return false; |
255 | } | 255 | } |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 476fc15..39351e1 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Framework.Console | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private string m_historyPath; | 47 | private string m_historyPath; |
48 | private bool m_historyEnable; | 48 | private bool m_historyEnable; |
49 | private bool m_historytimestamps; | ||
49 | 50 | ||
50 | // private readonly object m_syncRoot = new object(); | 51 | // private readonly object m_syncRoot = new object(); |
51 | private const string LOGLEVEL_NONE = "(none)"; | 52 | private const string LOGLEVEL_NONE = "(none)"; |
@@ -98,15 +99,30 @@ namespace OpenSim.Framework.Console | |||
98 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", Path.Combine(Util.logsDir(), "OpenSimConsoleHistory.txt")); | 99 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", Path.Combine(Util.logsDir(), "OpenSimConsoleHistory.txt")); |
99 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); | 100 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); |
100 | m_historyPath = Path.GetFullPath(m_historyFile); | 101 | m_historyPath = Path.GetFullPath(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); | 102 | m_historytimestamps = startupConfig.GetBoolean("ConsoleHistoryTimeStamp", false); |
103 | m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1} {2} timestamps", | ||
104 | m_historySize, m_historyPath, m_historytimestamps?"with":"without"); | ||
102 | 105 | ||
103 | if (File.Exists(m_historyPath)) | 106 | if (File.Exists(m_historyPath)) |
104 | { | 107 | { |
108 | List<string> originallines = new List<string>(); | ||
105 | using (StreamReader history_file = new StreamReader(m_historyPath)) | 109 | using (StreamReader history_file = new StreamReader(m_historyPath)) |
106 | { | 110 | { |
107 | string line; | 111 | string line; |
108 | while ((line = history_file.ReadLine()) != null) | 112 | while ((line = history_file.ReadLine()) != null) |
109 | { | 113 | { |
114 | originallines.Add(line); | ||
115 | if(line.StartsWith("[")) | ||
116 | { | ||
117 | int indx = line.IndexOf("]:> "); | ||
118 | if(indx > 0) | ||
119 | { | ||
120 | if(indx + 4 >= line.Length) | ||
121 | line = String.Empty; | ||
122 | else | ||
123 | line = line.Substring(indx + 4); | ||
124 | } | ||
125 | } | ||
110 | m_history.Add(line); | 126 | m_history.Add(line); |
111 | } | 127 | } |
112 | } | 128 | } |
@@ -114,11 +130,14 @@ namespace OpenSim.Framework.Console | |||
114 | if (m_history.Count > m_historySize) | 130 | if (m_history.Count > m_historySize) |
115 | { | 131 | { |
116 | while (m_history.Count > m_historySize) | 132 | while (m_history.Count > m_historySize) |
133 | { | ||
117 | m_history.RemoveAt(0); | 134 | m_history.RemoveAt(0); |
135 | originallines.RemoveAt(0); | ||
136 | } | ||
118 | 137 | ||
119 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) | 138 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) |
120 | { | 139 | { |
121 | foreach (string line in m_history) | 140 | foreach (string line in originallines) |
122 | { | 141 | { |
123 | history_file.WriteLine(line); | 142 | history_file.WriteLine(line); |
124 | } | 143 | } |
@@ -141,6 +160,8 @@ namespace OpenSim.Framework.Console | |||
141 | m_history.Add(text); | 160 | m_history.Add(text); |
142 | if (m_historyEnable) | 161 | if (m_historyEnable) |
143 | { | 162 | { |
163 | if (m_historytimestamps) | ||
164 | text = String.Format("[{0} {1}]:> {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), text); | ||
144 | File.AppendAllText(m_historyPath, text + Environment.NewLine); | 165 | File.AppendAllText(m_historyPath, text + Environment.NewLine); |
145 | } | 166 | } |
146 | } | 167 | } |
@@ -338,7 +359,7 @@ namespace OpenSim.Framework.Console | |||
338 | { | 359 | { |
339 | string outText = text; | 360 | string outText = text; |
340 | 361 | ||
341 | if (level != LOGLEVEL_NONE) | 362 | if (level != null) |
342 | { | 363 | { |
343 | MatchCollection matches = m_categoryRegex.Matches(text); | 364 | MatchCollection matches = m_categoryRegex.Matches(text); |
344 | 365 | ||
@@ -368,13 +389,33 @@ namespace OpenSim.Framework.Console | |||
368 | System.Console.WriteLine(); | 389 | System.Console.WriteLine(); |
369 | } | 390 | } |
370 | 391 | ||
371 | public override void Output(string text) | 392 | public override void Output(string format, params object[] components) |
372 | { | 393 | { |
373 | Output(text, LOGLEVEL_NONE); | 394 | string level = null; |
374 | } | 395 | if(components != null && components.Length > 0) |
396 | { | ||
397 | if(components[0] == null || components[0] is ConsoleLevel) | ||
398 | { | ||
399 | if(components[0] is ConsoleLevel) | ||
400 | level = ((ConsoleLevel)components[0]).ToString(); | ||
401 | |||
402 | if (components.Length > 1) | ||
403 | { | ||
404 | object[] tmp = new object[components.Length - 1]; | ||
405 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
406 | components = tmp; | ||
407 | } | ||
408 | else | ||
409 | components = null; | ||
410 | } | ||
411 | |||
412 | } | ||
413 | string text; | ||
414 | if (components == null || components.Length == 0) | ||
415 | text = format; | ||
416 | else | ||
417 | text = String.Format(format, components); | ||
375 | 418 | ||
376 | public override void Output(string text, string level) | ||
377 | { | ||
378 | FireOnOutput(text); | 419 | FireOnOutput(text); |
379 | 420 | ||
380 | lock (m_commandLine) | 421 | lock (m_commandLine) |
@@ -382,7 +423,6 @@ namespace OpenSim.Framework.Console | |||
382 | if (m_cursorYPosition == -1) | 423 | if (m_cursorYPosition == -1) |
383 | { | 424 | { |
384 | WriteLocalText(text, level); | 425 | WriteLocalText(text, level); |
385 | |||
386 | return; | 426 | return; |
387 | } | 427 | } |
388 | 428 | ||
diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index e1ff720..d314047 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs | |||
@@ -30,6 +30,7 @@ using System.Threading; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | using Nini.Config; | ||
33 | 34 | ||
34 | namespace OpenSim.Framework.Console | 35 | namespace OpenSim.Framework.Console |
35 | { | 36 | { |
@@ -56,23 +57,24 @@ namespace OpenSim.Framework.Console | |||
56 | 57 | ||
57 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } | 58 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } |
58 | 59 | ||
59 | public object ConsoleScene { | 60 | public IScene ConsoleScene { |
60 | get { return null; } | 61 | get { return null; } |
61 | set {} | 62 | set {} |
62 | } | 63 | } |
63 | 64 | ||
64 | public void Output(string text, string level) {} | 65 | public void Output(string format) { } |
65 | public void Output(string text) {} | 66 | public void Output(string format, params object[] components) { } |
66 | public void OutputFormat(string format, params object[] components) {} | ||
67 | 67 | ||
68 | public string CmdPrompt(string p) { return ""; } | 68 | public string Prompt(string p) { return ""; } |
69 | public string CmdPrompt(string p, string def) { return ""; } | 69 | public string Prompt(string p, string def) { return ""; } |
70 | public string CmdPrompt(string p, List<char> excludedCharacters) { return ""; } | 70 | public string Prompt(string p, List<char> excludedCharacters) { return ""; } |
71 | public string CmdPrompt(string p, string def, List<char> excludedCharacters) { return ""; } | 71 | public string Prompt(string p, string def, List<char> excludedCharacters, bool echo) { return ""; } |
72 | 72 | ||
73 | public string CmdPrompt(string prompt, string defaultresponse, List<string> options) { return ""; } | 73 | public string Prompt(string prompt, string defaultresponse, List<string> options) { return ""; } |
74 | 74 | ||
75 | public string PasswdPrompt(string p) { return ""; } | 75 | public string PasswdPrompt(string p) { return ""; } |
76 | |||
77 | public void ReadConfig(IConfigSource configSource) { } | ||
76 | } | 78 | } |
77 | 79 | ||
78 | public class MockCommands : ICommands | 80 | public class MockCommands : ICommands |
diff --git a/OpenSim/Framework/Console/OpenSimAppender.cs b/OpenSim/Framework/Console/OpenSimAppender.cs index 72a251e..39a550b 100644 --- a/OpenSim/Framework/Console/OpenSimAppender.cs +++ b/OpenSim/Framework/Console/OpenSimAppender.cs | |||
@@ -55,12 +55,14 @@ namespace OpenSim.Framework.Console | |||
55 | { | 55 | { |
56 | if (m_console != null) | 56 | if (m_console != null) |
57 | { | 57 | { |
58 | string level = "normal"; | 58 | ConsoleLevel level; |
59 | 59 | ||
60 | if (le.Level == Level.Error) | 60 | if (le.Level == Level.Error) |
61 | level = "error"; | 61 | level = "error"; |
62 | else if (le.Level == Level.Warn) | 62 | else if (le.Level == Level.Warn) |
63 | level = "warn"; | 63 | level = "warn"; |
64 | else | ||
65 | level = "normal"; | ||
64 | 66 | ||
65 | m_console.Output(loggingMessage, level); | 67 | m_console.Output(loggingMessage, level); |
66 | } | 68 | } |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index f59c902..889df36 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -46,6 +46,8 @@ namespace OpenSim.Framework.Console | |||
46 | // | 46 | // |
47 | public class RemoteConsole : CommandConsole | 47 | public class RemoteConsole : CommandConsole |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
49 | // Connection specific data, indexed by a session ID | 51 | // Connection specific data, indexed by a session ID |
50 | // we create when a client connects. | 52 | // we create when a client connects. |
51 | protected class ConsoleConnection | 53 | protected class ConsoleConnection |
@@ -153,7 +155,7 @@ namespace OpenSim.Framework.Console | |||
153 | m_expireTimer.Start(); | 155 | m_expireTimer.Start(); |
154 | } | 156 | } |
155 | 157 | ||
156 | public void ReadConfig(IConfigSource config) | 158 | public override void ReadConfig(IConfigSource config) |
157 | { | 159 | { |
158 | m_Config = config; | 160 | m_Config = config; |
159 | 161 | ||
@@ -188,13 +190,41 @@ namespace OpenSim.Framework.Console | |||
188 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); | 190 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); |
189 | } | 191 | } |
190 | 192 | ||
191 | public override void Output(string text, string level) | 193 | public override void Output(string format, params object[] components) |
192 | { | 194 | { |
195 | string level = null; | ||
196 | if (components != null && components.Length > 0) | ||
197 | { | ||
198 | if (components[0] == null || components[0] is ConsoleLevel) | ||
199 | { | ||
200 | if (components[0] is ConsoleLevel) | ||
201 | level = ((ConsoleLevel)components[0]).ToString(); | ||
202 | |||
203 | if (components.Length > 1) | ||
204 | { | ||
205 | object[] tmp = new object[components.Length - 1]; | ||
206 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
207 | components = tmp; | ||
208 | } | ||
209 | else | ||
210 | components = null; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | string text; | ||
215 | if (components == null || components.Length == 0) | ||
216 | text = format; | ||
217 | else | ||
218 | text = String.Format(format, components); | ||
219 | |||
193 | Output(text, level, false, false, false); | 220 | Output(text, level, false, false, false); |
194 | } | 221 | } |
195 | 222 | ||
196 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) | 223 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) |
197 | { | 224 | { |
225 | if (level == null) | ||
226 | level = String.Empty; | ||
227 | |||
198 | // Increment the line number. It was 0 and they start at 1 | 228 | // Increment the line number. It was 0 and they start at 1 |
199 | // so we need to pre-increment. | 229 | // so we need to pre-increment. |
200 | m_lineNumber++; | 230 | m_lineNumber++; |
@@ -228,12 +258,6 @@ namespace OpenSim.Framework.Console | |||
228 | System.Console.WriteLine(text.Trim()); | 258 | System.Console.WriteLine(text.Trim()); |
229 | } | 259 | } |
230 | 260 | ||
231 | public override void Output(string text) | ||
232 | { | ||
233 | // Output plain (non-logging style) text. | ||
234 | Output(text, String.Empty, false, false, false); | ||
235 | } | ||
236 | |||
237 | public override string ReadLine(string p, bool isCommand, bool e) | 261 | public override string ReadLine(string p, bool isCommand, bool e) |
238 | { | 262 | { |
239 | // Output the prompt an prepare to wait. This | 263 | // Output the prompt an prepare to wait. This |
@@ -403,7 +427,7 @@ namespace OpenSim.Framework.Console | |||
403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 427 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
404 | 428 | ||
405 | m_Server.AddPollServiceHTTPHandler( | 429 | m_Server.AddPollServiceHTTPHandler( |
406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 430 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout |
407 | 431 | ||
408 | // Our reply is an XML document. | 432 | // Our reply is an XML document. |
409 | // TODO: Change this to Linq.Xml | 433 | // TODO: Change this to Linq.Xml |
@@ -687,7 +711,6 @@ namespace OpenSim.Framework.Console | |||
687 | result["int_response_code"] = 200; | 711 | result["int_response_code"] = 200; |
688 | result["content_type"] = "application/xml"; | 712 | result["content_type"] = "application/xml"; |
689 | result["keepalive"] = false; | 713 | result["keepalive"] = false; |
690 | result["reusecontext"] = false; | ||
691 | result = CheckOrigin(result); | 714 | result = CheckOrigin(result); |
692 | 715 | ||
693 | return result; | 716 | return result; |
@@ -713,7 +736,6 @@ namespace OpenSim.Framework.Console | |||
713 | result["int_response_code"] = 200; | 736 | result["int_response_code"] = 200; |
714 | result["content_type"] = "text/xml"; | 737 | result["content_type"] = "text/xml"; |
715 | result["keepalive"] = false; | 738 | result["keepalive"] = false; |
716 | result["reusecontext"] = false; | ||
717 | result = CheckOrigin(result); | 739 | result = CheckOrigin(result); |
718 | 740 | ||
719 | return result; | 741 | return result; |
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index 28055b8..e399e27 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs | |||
@@ -30,13 +30,16 @@ namespace OpenSim.Framework | |||
30 | { | 30 | { |
31 | public class Constants | 31 | public class Constants |
32 | { | 32 | { |
33 | public const int MaxAgentAttachments = 38; | ||
34 | public const int MaxAgentGroups = 60; | ||
35 | |||
33 | // 'RegionSize' is the legacy region size. | 36 | // 'RegionSize' is the legacy region size. |
34 | // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not | 37 | // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not |
35 | // be the legacy region size. | 38 | // be the legacy region size. |
36 | public const uint RegionSize = 256; | 39 | public const uint RegionSize = 256; |
37 | public const uint RegionHeight = 16384; | 40 | public const uint RegionHeight = 16384; |
38 | // This could be a parameters but, really, a region of greater than this is pretty unmanageable | 41 | |
39 | public const uint MaximumRegionSize = 8192; | 42 | public const uint MaximumRegionSize = 4096; |
40 | 43 | ||
41 | // Since terrain is stored in 16x16 heights, regions must be a multiple of this number and that is the minimum | 44 | // Since terrain is stored in 16x16 heights, regions must be a multiple of this number and that is the minimum |
42 | public const int MinRegionSize = 16; | 45 | public const int MinRegionSize = 16; |
@@ -83,7 +86,7 @@ namespace OpenSim.Framework | |||
83 | ViaLogin = 1 << 7, | 86 | ViaLogin = 1 << 7, |
84 | /// <summary>Linden Summoned</summary> | 87 | /// <summary>Linden Summoned</summary> |
85 | ViaGodlikeLure = 1 << 8, | 88 | ViaGodlikeLure = 1 << 8, |
86 | /// <summary>"Linden Forced me" it used to say, but the code says "This user will be a God in the destination scene, too", but then is ignored.</summary> | 89 | /// <summary>Linden Forced me</summary> |
87 | Godlike = 1 << 9, | 90 | Godlike = 1 << 9, |
88 | /// <summary></summary> | 91 | /// <summary></summary> |
89 | NineOneOne = 1 << 10, | 92 | NineOneOne = 1 << 10, |
@@ -97,8 +100,8 @@ namespace OpenSim.Framework | |||
97 | ResetHome = 1 << 14, | 100 | ResetHome = 1 << 14, |
98 | /// <summary>forced to new location for example when avatar is banned or ejected</summary> | 101 | /// <summary>forced to new location for example when avatar is banned or ejected</summary> |
99 | ForceRedirect = 1 << 15, | 102 | ForceRedirect = 1 << 15, |
100 | /// <summary>Via script.</summary> | 103 | /// <summary>Via script.</summary> |
101 | ViaScript = 1 << 16, | 104 | ViaScript = 1 << 16, |
102 | /// <summary>Via map, though this is a guess.</summary> | 105 | /// <summary>Via map, though this is a guess.</summary> |
103 | ViaMap = 1 << 17, | 106 | ViaMap = 1 << 17, |
104 | /// <summary>Teleport Finished via a Lure</summary> | 107 | /// <summary>Teleport Finished via a Lure</summary> |
@@ -108,8 +111,8 @@ namespace OpenSim.Framework | |||
108 | /// <summary>Finished, Same Sim</summary> | 111 | /// <summary>Finished, Same Sim</summary> |
109 | FinishedViaSameSim = 1 << 29, | 112 | FinishedViaSameSim = 1 << 29, |
110 | /// <summary>Agent coming into the grid from another grid</summary> | 113 | /// <summary>Agent coming into the grid from another grid</summary> |
111 | ViaHGLogin = 1 << 30 | 114 | ViaHGLogin = 1 << 30, |
115 | notViaHGLogin = 0xbffffff | ||
112 | } | 116 | } |
113 | |||
114 | } | 117 | } |
115 | } | 118 | } |
diff --git a/OpenSim/Framework/Culture.cs b/OpenSim/Framework/Culture.cs index 3d78fac..483f735 100644 --- a/OpenSim/Framework/Culture.cs +++ b/OpenSim/Framework/Culture.cs | |||
@@ -1,56 +1 @@ | |||
1 | /* | /* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OpenSimulator Project nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; using System.Globalization; using System.Threading; namespace OpenSim.Framework { public class Culture { private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", false); public static NumberFormatInfo NumberFormatInfo { get { return m_cultureInfo.NumberFormat; } } public static IFormatProvider FormatProvider { get { return m_cultureInfo; } } /// <summary> /// Set Culture to en-US to make string processing of numbers simpler. /// </summary> public static void SetCurrentCulture() { Thread.CurrentThread.CurrentCulture = m_cultureInfo; } public static void SetDefaultCurrentCulture() { CultureInfo.DefaultThreadCurrentCulture = m_cultureInfo; } public static CultureInfo GetDefaultCurrentCulture() { return CultureInfo.DefaultThreadCurrentCulture; } } } \ No newline at end of file | |
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 | |||
28 | using System; | ||
29 | using System.Globalization; | ||
30 | using System.Threading; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public class Culture | ||
35 | { | ||
36 | private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", false); | ||
37 | |||
38 | public static NumberFormatInfo NumberFormatInfo | ||
39 | { | ||
40 | get { return m_cultureInfo.NumberFormat; } | ||
41 | } | ||
42 | |||
43 | public static IFormatProvider FormatProvider | ||
44 | { | ||
45 | get { return m_cultureInfo; } | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Set Culture to en-US to make string processing of numbers simpler. | ||
50 | /// </summary> | ||
51 | public static void SetCurrentCulture() | ||
52 | { | ||
53 | Thread.CurrentThread.CurrentCulture = m_cultureInfo; | ||
54 | } | ||
55 | } | ||
56 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index 816523b..ec26b43 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs | |||
@@ -41,23 +41,28 @@ namespace OpenSim.Framework | |||
41 | { | 41 | { |
42 | Dictionary<TKey1, TValue> Dictionary1; | 42 | Dictionary<TKey1, TValue> Dictionary1; |
43 | Dictionary<TKey2, TValue> Dictionary2; | 43 | Dictionary<TKey2, TValue> Dictionary2; |
44 | private TValue[] m_array; | ||
45 | |||
44 | ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(); | 46 | ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(); |
45 | 47 | ||
46 | public DoubleDictionaryThreadAbortSafe() | 48 | public DoubleDictionaryThreadAbortSafe() |
47 | { | 49 | { |
48 | Dictionary1 = new Dictionary<TKey1,TValue>(); | 50 | Dictionary1 = new Dictionary<TKey1,TValue>(); |
49 | Dictionary2 = new Dictionary<TKey2,TValue>(); | 51 | Dictionary2 = new Dictionary<TKey2,TValue>(); |
52 | m_array = null; | ||
50 | } | 53 | } |
51 | 54 | ||
52 | public DoubleDictionaryThreadAbortSafe(int capacity) | 55 | public DoubleDictionaryThreadAbortSafe(int capacity) |
53 | { | 56 | { |
54 | Dictionary1 = new Dictionary<TKey1, TValue>(capacity); | 57 | Dictionary1 = new Dictionary<TKey1, TValue>(capacity); |
55 | Dictionary2 = new Dictionary<TKey2, TValue>(capacity); | 58 | Dictionary2 = new Dictionary<TKey2, TValue>(capacity); |
59 | m_array = null; | ||
56 | } | 60 | } |
57 | 61 | ||
58 | ~DoubleDictionaryThreadAbortSafe() | 62 | ~DoubleDictionaryThreadAbortSafe() |
59 | { | 63 | { |
60 | rwLock.Dispose(); | 64 | if(rwLock != null) |
65 | rwLock.Dispose(); | ||
61 | } | 66 | } |
62 | 67 | ||
63 | public void Add(TKey1 key1, TKey2 key2, TValue value) | 68 | public void Add(TKey1 key1, TKey2 key2, TValue value) |
@@ -74,6 +79,8 @@ namespace OpenSim.Framework | |||
74 | { | 79 | { |
75 | rwLock.EnterWriteLock(); | 80 | rwLock.EnterWriteLock(); |
76 | gotLock = true; | 81 | gotLock = true; |
82 | } | ||
83 | /* | ||
77 | if (Dictionary1.ContainsKey(key1)) | 84 | if (Dictionary1.ContainsKey(key1)) |
78 | { | 85 | { |
79 | if (!Dictionary2.ContainsKey(key2)) | 86 | if (!Dictionary2.ContainsKey(key2)) |
@@ -84,9 +91,10 @@ namespace OpenSim.Framework | |||
84 | if (!Dictionary1.ContainsKey(key1)) | 91 | if (!Dictionary1.ContainsKey(key1)) |
85 | throw new ArgumentException("key2 exists in the dictionary but not key1"); | 92 | throw new ArgumentException("key2 exists in the dictionary but not key1"); |
86 | } | 93 | } |
94 | */ | ||
87 | Dictionary1[key1] = value; | 95 | Dictionary1[key1] = value; |
88 | Dictionary2[key2] = value; | 96 | Dictionary2[key2] = value; |
89 | } | 97 | m_array = null; |
90 | } | 98 | } |
91 | finally | 99 | finally |
92 | { | 100 | { |
@@ -110,9 +118,10 @@ namespace OpenSim.Framework | |||
110 | { | 118 | { |
111 | rwLock.EnterWriteLock(); | 119 | rwLock.EnterWriteLock(); |
112 | gotLock = true; | 120 | gotLock = true; |
113 | Dictionary1.Remove(key1); | ||
114 | success = Dictionary2.Remove(key2); | ||
115 | } | 121 | } |
122 | success = Dictionary1.Remove(key1); | ||
123 | success &= Dictionary2.Remove(key2); | ||
124 | m_array = null; | ||
116 | } | 125 | } |
117 | finally | 126 | finally |
118 | { | 127 | { |
@@ -153,6 +162,7 @@ namespace OpenSim.Framework | |||
153 | { | 162 | { |
154 | Dictionary1.Remove(key1); | 163 | Dictionary1.Remove(key1); |
155 | Dictionary2.Remove(kvp.Key); | 164 | Dictionary2.Remove(kvp.Key); |
165 | m_array = null; | ||
156 | } | 166 | } |
157 | found = true; | 167 | found = true; |
158 | break; | 168 | break; |
@@ -199,6 +209,7 @@ namespace OpenSim.Framework | |||
199 | { | 209 | { |
200 | Dictionary2.Remove(key2); | 210 | Dictionary2.Remove(key2); |
201 | Dictionary1.Remove(kvp.Key); | 211 | Dictionary1.Remove(kvp.Key); |
212 | m_array = null; | ||
202 | } | 213 | } |
203 | found = true; | 214 | found = true; |
204 | break; | 215 | break; |
@@ -231,6 +242,7 @@ namespace OpenSim.Framework | |||
231 | gotLock = true; | 242 | gotLock = true; |
232 | Dictionary1.Clear(); | 243 | Dictionary1.Clear(); |
233 | Dictionary2.Clear(); | 244 | Dictionary2.Clear(); |
245 | m_array = null; | ||
234 | } | 246 | } |
235 | } | 247 | } |
236 | finally | 248 | finally |
@@ -313,28 +325,12 @@ namespace OpenSim.Framework | |||
313 | 325 | ||
314 | public void ForEach(Action<TValue> action) | 326 | public void ForEach(Action<TValue> action) |
315 | { | 327 | { |
316 | bool gotLock = false; | 328 | TValue[] values = GetArray(); |
329 | if(values == null || values.Length == 0) | ||
330 | return; | ||
317 | 331 | ||
318 | try | 332 | foreach (TValue value in values) |
319 | { | 333 | action(value); |
320 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
321 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
322 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
323 | try {} | ||
324 | finally | ||
325 | { | ||
326 | rwLock.EnterReadLock(); | ||
327 | gotLock = true; | ||
328 | } | ||
329 | |||
330 | foreach (TValue value in Dictionary1.Values) | ||
331 | action(value); | ||
332 | } | ||
333 | finally | ||
334 | { | ||
335 | if (gotLock) | ||
336 | rwLock.ExitReadLock(); | ||
337 | } | ||
338 | } | 334 | } |
339 | 335 | ||
340 | public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) | 336 | public void ForEach(Action<KeyValuePair<TKey1, TValue>> action) |
@@ -391,30 +387,12 @@ namespace OpenSim.Framework | |||
391 | 387 | ||
392 | public TValue FindValue(Predicate<TValue> predicate) | 388 | public TValue FindValue(Predicate<TValue> predicate) |
393 | { | 389 | { |
394 | bool gotLock = false; | 390 | TValue[] values = GetArray(); |
395 | 391 | int len = values.Length; | |
396 | try | 392 | for (int i = 0; i < len; ++i) |
397 | { | ||
398 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
399 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
400 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
401 | try {} | ||
402 | finally | ||
403 | { | ||
404 | rwLock.EnterReadLock(); | ||
405 | gotLock = true; | ||
406 | } | ||
407 | |||
408 | foreach (TValue value in Dictionary1.Values) | ||
409 | { | ||
410 | if (predicate(value)) | ||
411 | return value; | ||
412 | } | ||
413 | } | ||
414 | finally | ||
415 | { | 393 | { |
416 | if (gotLock) | 394 | if (predicate(values[i])) |
417 | rwLock.ExitReadLock(); | 395 | return values[i]; |
418 | } | 396 | } |
419 | 397 | ||
420 | return default(TValue); | 398 | return default(TValue); |
@@ -423,32 +401,14 @@ namespace OpenSim.Framework | |||
423 | public IList<TValue> FindAll(Predicate<TValue> predicate) | 401 | public IList<TValue> FindAll(Predicate<TValue> predicate) |
424 | { | 402 | { |
425 | IList<TValue> list = new List<TValue>(); | 403 | IList<TValue> list = new List<TValue>(); |
426 | bool gotLock = false; | 404 | TValue[] values = GetArray(); |
427 | |||
428 | try | ||
429 | { | ||
430 | // Avoid an asynchronous Thread.Abort() from possibly never existing an acquired lock by placing | ||
431 | // the acquision inside the main try. The inner finally block is needed because thread aborts cannot | ||
432 | // interrupt code in these blocks (hence gotLock is guaranteed to be set correctly). | ||
433 | try {} | ||
434 | finally | ||
435 | { | ||
436 | rwLock.EnterReadLock(); | ||
437 | gotLock = true; | ||
438 | } | ||
439 | 405 | ||
440 | foreach (TValue value in Dictionary1.Values) | 406 | int len = values.Length; |
441 | { | 407 | for (int i = 0; i < len; ++i) |
442 | if (predicate(value)) | ||
443 | list.Add(value); | ||
444 | } | ||
445 | } | ||
446 | finally | ||
447 | { | 408 | { |
448 | if (gotLock) | 409 | if (predicate(values[i])) |
449 | rwLock.ExitReadLock(); | 410 | list.Add(values[i]); |
450 | } | 411 | } |
451 | |||
452 | return list; | 412 | return list; |
453 | } | 413 | } |
454 | 414 | ||
@@ -497,6 +457,7 @@ namespace OpenSim.Framework | |||
497 | 457 | ||
498 | for (int i = 0; i < list2.Count; i++) | 458 | for (int i = 0; i < list2.Count; i++) |
499 | Dictionary2.Remove(list2[i]); | 459 | Dictionary2.Remove(list2[i]); |
460 | m_array = null; | ||
500 | } | 461 | } |
501 | } | 462 | } |
502 | finally | 463 | finally |
@@ -513,5 +474,51 @@ namespace OpenSim.Framework | |||
513 | 474 | ||
514 | return list.Count; | 475 | return list.Count; |
515 | } | 476 | } |
477 | |||
478 | public TValue[] GetArray() | ||
479 | { | ||
480 | bool gotupLock = false; | ||
481 | try | ||
482 | { | ||
483 | try { } | ||
484 | finally | ||
485 | { | ||
486 | rwLock.EnterUpgradeableReadLock(); | ||
487 | gotupLock = true; | ||
488 | } | ||
489 | |||
490 | if (m_array == null) | ||
491 | { | ||
492 | bool gotwritelock = false; | ||
493 | try | ||
494 | { | ||
495 | try { } | ||
496 | finally | ||
497 | { | ||
498 | rwLock.EnterWriteLock(); | ||
499 | gotwritelock = true; | ||
500 | } | ||
501 | |||
502 | m_array = new TValue[Dictionary1.Count]; | ||
503 | Dictionary1.Values.CopyTo(m_array, 0); | ||
504 | } | ||
505 | finally | ||
506 | { | ||
507 | if (gotwritelock) | ||
508 | rwLock.ExitWriteLock(); | ||
509 | } | ||
510 | } | ||
511 | return m_array; | ||
512 | } | ||
513 | catch | ||
514 | { | ||
515 | return new TValue[0]; | ||
516 | } | ||
517 | finally | ||
518 | { | ||
519 | if (gotupLock) | ||
520 | rwLock.ExitUpgradeableReadLock(); | ||
521 | } | ||
522 | } | ||
516 | } | 523 | } |
517 | } \ No newline at end of file | 524 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/EntityTransferContext.cs b/OpenSim/Framework/EntityTransferContext.cs index 860414e..257c6d1 100644 --- a/OpenSim/Framework/EntityTransferContext.cs +++ b/OpenSim/Framework/EntityTransferContext.cs | |||
@@ -58,13 +58,13 @@ namespace OpenSim.Framework | |||
58 | public void Unpack(OSD data) | 58 | public void Unpack(OSD data) |
59 | { | 59 | { |
60 | OSDMap map = (OSDMap)data; | 60 | OSDMap map = (OSDMap)data; |
61 | 61 | OSD tmpOSD; | |
62 | if (map.ContainsKey("InboundVersion")) | 62 | if (map.TryGetValue("InboundVersion", out tmpOSD)) |
63 | InboundVersion = (float)map["InboundVersion"].AsReal(); | 63 | InboundVersion = (float)tmpOSD.AsReal(); |
64 | if (map.ContainsKey("OutboundVersion")) | 64 | if (map.TryGetValue("OutboundVersion", out tmpOSD)) |
65 | OutboundVersion = (float)map["OutboundVersion"].AsReal(); | 65 | OutboundVersion = (float)tmpOSD.AsReal(); |
66 | if (map.ContainsKey("WearablesCount")) | 66 | if (map.TryGetValue("WearablesCount", out tmpOSD)) |
67 | WearablesCount = map["WearablesCount"].AsInteger(); | 67 | WearablesCount = tmpOSD.AsInteger(); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs index 12a92bb..beb7bc9 100644 --- a/OpenSim/Framework/EstateBan.cs +++ b/OpenSim/Framework/EstateBan.cs | |||
@@ -67,6 +67,9 @@ namespace OpenSim.Framework | |||
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | public UUID BanningUserID { get; set; } | ||
71 | public int BanTime { get; set; } | ||
72 | |||
70 | private string m_bannedHostAddress = string.Empty; | 73 | private string m_bannedHostAddress = string.Empty; |
71 | /// <summary> | 74 | /// <summary> |
72 | /// IP address or domain name of the banned client. | 75 | /// IP address or domain name of the banned client. |
@@ -137,6 +140,8 @@ namespace OpenSim.Framework | |||
137 | object value = p.GetValue(this, null); | 140 | object value = p.GetValue(this, null); |
138 | if (value is String) | 141 | if (value is String) |
139 | p.SetValue(this, map[p.Name], null); | 142 | p.SetValue(this, map[p.Name], null); |
143 | else if (value is Int32) | ||
144 | p.SetValue(this, Int32.Parse((string)map[p.Name]), null); | ||
140 | else if (value is UInt32) | 145 | else if (value is UInt32) |
141 | p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); | 146 | p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); |
142 | else if (value is Boolean) | 147 | else if (value is Boolean) |
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 8c8270a..1c0b97a 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -44,7 +44,6 @@ namespace OpenSim.Framework | |||
44 | // Only the client uses these | 44 | // Only the client uses these |
45 | // | 45 | // |
46 | private uint m_EstateID = 0; | 46 | private uint m_EstateID = 0; |
47 | |||
48 | public uint EstateID | 47 | public uint EstateID |
49 | { | 48 | { |
50 | get { return m_EstateID; } | 49 | get { return m_EstateID; } |
@@ -52,7 +51,6 @@ namespace OpenSim.Framework | |||
52 | } | 51 | } |
53 | 52 | ||
54 | private string m_EstateName = "My Estate"; | 53 | private string m_EstateName = "My Estate"; |
55 | |||
56 | public string EstateName | 54 | public string EstateName |
57 | { | 55 | { |
58 | get { return m_EstateName; } | 56 | get { return m_EstateName; } |
@@ -60,7 +58,6 @@ namespace OpenSim.Framework | |||
60 | } | 58 | } |
61 | 59 | ||
62 | private bool m_AllowLandmark = true; | 60 | private bool m_AllowLandmark = true; |
63 | |||
64 | public bool AllowLandmark | 61 | public bool AllowLandmark |
65 | { | 62 | { |
66 | get { return m_AllowLandmark; } | 63 | get { return m_AllowLandmark; } |
@@ -68,7 +65,6 @@ namespace OpenSim.Framework | |||
68 | } | 65 | } |
69 | 66 | ||
70 | private bool m_AllowParcelChanges = true; | 67 | private bool m_AllowParcelChanges = true; |
71 | |||
72 | public bool AllowParcelChanges | 68 | public bool AllowParcelChanges |
73 | { | 69 | { |
74 | get { return m_AllowParcelChanges; } | 70 | get { return m_AllowParcelChanges; } |
@@ -76,7 +72,6 @@ namespace OpenSim.Framework | |||
76 | } | 72 | } |
77 | 73 | ||
78 | private bool m_AllowSetHome = true; | 74 | private bool m_AllowSetHome = true; |
79 | |||
80 | public bool AllowSetHome | 75 | public bool AllowSetHome |
81 | { | 76 | { |
82 | get { return m_AllowSetHome; } | 77 | get { return m_AllowSetHome; } |
@@ -84,7 +79,6 @@ namespace OpenSim.Framework | |||
84 | } | 79 | } |
85 | 80 | ||
86 | private uint m_ParentEstateID = 1; | 81 | private uint m_ParentEstateID = 1; |
87 | |||
88 | public uint ParentEstateID | 82 | public uint ParentEstateID |
89 | { | 83 | { |
90 | get { return m_ParentEstateID; } | 84 | get { return m_ParentEstateID; } |
@@ -92,7 +86,6 @@ namespace OpenSim.Framework | |||
92 | } | 86 | } |
93 | 87 | ||
94 | private float m_BillableFactor = 0.0f; | 88 | private float m_BillableFactor = 0.0f; |
95 | |||
96 | public float BillableFactor | 89 | public float BillableFactor |
97 | { | 90 | { |
98 | get { return m_BillableFactor; } | 91 | get { return m_BillableFactor; } |
@@ -100,7 +93,6 @@ namespace OpenSim.Framework | |||
100 | } | 93 | } |
101 | 94 | ||
102 | private int m_PricePerMeter = 1; | 95 | private int m_PricePerMeter = 1; |
103 | |||
104 | public int PricePerMeter | 96 | public int PricePerMeter |
105 | { | 97 | { |
106 | get { return m_PricePerMeter; } | 98 | get { return m_PricePerMeter; } |
@@ -108,7 +100,6 @@ namespace OpenSim.Framework | |||
108 | } | 100 | } |
109 | 101 | ||
110 | private int m_RedirectGridX = 0; | 102 | private int m_RedirectGridX = 0; |
111 | |||
112 | public int RedirectGridX | 103 | public int RedirectGridX |
113 | { | 104 | { |
114 | get { return m_RedirectGridX; } | 105 | get { return m_RedirectGridX; } |
@@ -116,7 +107,6 @@ namespace OpenSim.Framework | |||
116 | } | 107 | } |
117 | 108 | ||
118 | private int m_RedirectGridY = 0; | 109 | private int m_RedirectGridY = 0; |
119 | |||
120 | public int RedirectGridY | 110 | public int RedirectGridY |
121 | { | 111 | { |
122 | get { return m_RedirectGridY; } | 112 | get { return m_RedirectGridY; } |
@@ -126,7 +116,6 @@ namespace OpenSim.Framework | |||
126 | // Used by the sim | 116 | // Used by the sim |
127 | // | 117 | // |
128 | private bool m_UseGlobalTime = true; | 118 | private bool m_UseGlobalTime = true; |
129 | |||
130 | public bool UseGlobalTime | 119 | public bool UseGlobalTime |
131 | { | 120 | { |
132 | get { return m_UseGlobalTime; } | 121 | get { return m_UseGlobalTime; } |
@@ -134,7 +123,6 @@ namespace OpenSim.Framework | |||
134 | } | 123 | } |
135 | 124 | ||
136 | private bool m_FixedSun = false; | 125 | private bool m_FixedSun = false; |
137 | |||
138 | public bool FixedSun | 126 | public bool FixedSun |
139 | { | 127 | { |
140 | get { return m_FixedSun; } | 128 | get { return m_FixedSun; } |
@@ -142,7 +130,6 @@ namespace OpenSim.Framework | |||
142 | } | 130 | } |
143 | 131 | ||
144 | private double m_SunPosition = 0.0; | 132 | private double m_SunPosition = 0.0; |
145 | |||
146 | public double SunPosition | 133 | public double SunPosition |
147 | { | 134 | { |
148 | get { return m_SunPosition; } | 135 | get { return m_SunPosition; } |
@@ -150,7 +137,6 @@ namespace OpenSim.Framework | |||
150 | } | 137 | } |
151 | 138 | ||
152 | private bool m_AllowVoice = true; | 139 | private bool m_AllowVoice = true; |
153 | |||
154 | public bool AllowVoice | 140 | public bool AllowVoice |
155 | { | 141 | { |
156 | get { return m_AllowVoice; } | 142 | get { return m_AllowVoice; } |
@@ -158,7 +144,6 @@ namespace OpenSim.Framework | |||
158 | } | 144 | } |
159 | 145 | ||
160 | private bool m_AllowDirectTeleport = true; | 146 | private bool m_AllowDirectTeleport = true; |
161 | |||
162 | public bool AllowDirectTeleport | 147 | public bool AllowDirectTeleport |
163 | { | 148 | { |
164 | get { return m_AllowDirectTeleport; } | 149 | get { return m_AllowDirectTeleport; } |
@@ -166,23 +151,22 @@ namespace OpenSim.Framework | |||
166 | } | 151 | } |
167 | 152 | ||
168 | private bool m_DenyAnonymous = false; | 153 | private bool m_DenyAnonymous = false; |
169 | |||
170 | public bool DenyAnonymous | 154 | public bool DenyAnonymous |
171 | { | 155 | { |
172 | get { return m_DenyAnonymous; } | 156 | get { return (DoDenyAnonymous && m_DenyAnonymous); } |
173 | set { m_DenyAnonymous = value; } | 157 | set { m_DenyAnonymous = value; } |
174 | } | 158 | } |
175 | 159 | ||
160 | // no longer in used, may be reassigned | ||
176 | private bool m_DenyIdentified = false; | 161 | private bool m_DenyIdentified = false; |
177 | |||
178 | public bool DenyIdentified | 162 | public bool DenyIdentified |
179 | { | 163 | { |
180 | get { return m_DenyIdentified; } | 164 | get { return m_DenyIdentified; } |
181 | set { m_DenyIdentified = value; } | 165 | set { m_DenyIdentified = value; } |
182 | } | 166 | } |
183 | 167 | ||
168 | // no longer in used, may be reassigned | ||
184 | private bool m_DenyTransacted = false; | 169 | private bool m_DenyTransacted = false; |
185 | |||
186 | public bool DenyTransacted | 170 | public bool DenyTransacted |
187 | { | 171 | { |
188 | get { return m_DenyTransacted; } | 172 | get { return m_DenyTransacted; } |
@@ -190,7 +174,6 @@ namespace OpenSim.Framework | |||
190 | } | 174 | } |
191 | 175 | ||
192 | private bool m_AbuseEmailToEstateOwner = false; | 176 | private bool m_AbuseEmailToEstateOwner = false; |
193 | |||
194 | public bool AbuseEmailToEstateOwner | 177 | public bool AbuseEmailToEstateOwner |
195 | { | 178 | { |
196 | get { return m_AbuseEmailToEstateOwner; } | 179 | get { return m_AbuseEmailToEstateOwner; } |
@@ -198,7 +181,6 @@ namespace OpenSim.Framework | |||
198 | } | 181 | } |
199 | 182 | ||
200 | private bool m_BlockDwell = false; | 183 | private bool m_BlockDwell = false; |
201 | |||
202 | public bool BlockDwell | 184 | public bool BlockDwell |
203 | { | 185 | { |
204 | get { return m_BlockDwell; } | 186 | get { return m_BlockDwell; } |
@@ -206,7 +188,6 @@ namespace OpenSim.Framework | |||
206 | } | 188 | } |
207 | 189 | ||
208 | private bool m_EstateSkipScripts = false; | 190 | private bool m_EstateSkipScripts = false; |
209 | |||
210 | public bool EstateSkipScripts | 191 | public bool EstateSkipScripts |
211 | { | 192 | { |
212 | get { return m_EstateSkipScripts; } | 193 | get { return m_EstateSkipScripts; } |
@@ -214,7 +195,6 @@ namespace OpenSim.Framework | |||
214 | } | 195 | } |
215 | 196 | ||
216 | private bool m_ResetHomeOnTeleport = false; | 197 | private bool m_ResetHomeOnTeleport = false; |
217 | |||
218 | public bool ResetHomeOnTeleport | 198 | public bool ResetHomeOnTeleport |
219 | { | 199 | { |
220 | get { return m_ResetHomeOnTeleport; } | 200 | get { return m_ResetHomeOnTeleport; } |
@@ -222,15 +202,13 @@ namespace OpenSim.Framework | |||
222 | } | 202 | } |
223 | 203 | ||
224 | private bool m_TaxFree = false; | 204 | private bool m_TaxFree = false; |
225 | 205 | public bool TaxFree // this is now AllowAccessOverride, keeping same name to reuse DB entries | |
226 | public bool TaxFree | ||
227 | { | 206 | { |
228 | get { return m_TaxFree; } | 207 | get { return m_TaxFree; } |
229 | set { m_TaxFree = value; } | 208 | set { m_TaxFree = value; } |
230 | } | 209 | } |
231 | 210 | ||
232 | private bool m_PublicAccess = true; | 211 | private bool m_PublicAccess = true; |
233 | |||
234 | public bool PublicAccess | 212 | public bool PublicAccess |
235 | { | 213 | { |
236 | get { return m_PublicAccess; } | 214 | get { return m_PublicAccess; } |
@@ -246,7 +224,6 @@ namespace OpenSim.Framework | |||
246 | } | 224 | } |
247 | 225 | ||
248 | private UUID m_EstateOwner = UUID.Zero; | 226 | private UUID m_EstateOwner = UUID.Zero; |
249 | |||
250 | public UUID EstateOwner | 227 | public UUID EstateOwner |
251 | { | 228 | { |
252 | get { return m_EstateOwner; } | 229 | get { return m_EstateOwner; } |
@@ -254,10 +231,9 @@ namespace OpenSim.Framework | |||
254 | } | 231 | } |
255 | 232 | ||
256 | private bool m_DenyMinors = false; | 233 | private bool m_DenyMinors = false; |
257 | |||
258 | public bool DenyMinors | 234 | public bool DenyMinors |
259 | { | 235 | { |
260 | get { return m_DenyMinors; } | 236 | get { return (DoDenyMinors && m_DenyMinors); } |
261 | set { m_DenyMinors = value; } | 237 | set { m_DenyMinors = value; } |
262 | } | 238 | } |
263 | 239 | ||
@@ -280,7 +256,6 @@ namespace OpenSim.Framework | |||
280 | } | 256 | } |
281 | 257 | ||
282 | private List<UUID> l_EstateAccess = new List<UUID>(); | 258 | private List<UUID> l_EstateAccess = new List<UUID>(); |
283 | |||
284 | public UUID[] EstateAccess | 259 | public UUID[] EstateAccess |
285 | { | 260 | { |
286 | get { return l_EstateAccess.ToArray(); } | 261 | get { return l_EstateAccess.ToArray(); } |
@@ -288,13 +263,15 @@ namespace OpenSim.Framework | |||
288 | } | 263 | } |
289 | 264 | ||
290 | private List<UUID> l_EstateGroups = new List<UUID>(); | 265 | private List<UUID> l_EstateGroups = new List<UUID>(); |
291 | |||
292 | public UUID[] EstateGroups | 266 | public UUID[] EstateGroups |
293 | { | 267 | { |
294 | get { return l_EstateGroups.ToArray(); } | 268 | get { return l_EstateGroups.ToArray(); } |
295 | set { l_EstateGroups = new List<UUID>(value); } | 269 | set { l_EstateGroups = new List<UUID>(value); } |
296 | } | 270 | } |
297 | 271 | ||
272 | public bool DoDenyMinors = true; | ||
273 | public bool DoDenyAnonymous = true; | ||
274 | |||
298 | public EstateSettings() | 275 | public EstateSettings() |
299 | { | 276 | { |
300 | } | 277 | } |
diff --git a/OpenSim/Framework/GcNotify.cs b/OpenSim/Framework/GcNotify.cs deleted file mode 100644 index 14a22a6..0000000 --- a/OpenSim/Framework/GcNotify.cs +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | |||
32 | public class GcNotify | ||
33 | { | ||
34 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
35 | |||
36 | public static bool Enabled | ||
37 | { | ||
38 | get { return s_initialized; } | ||
39 | set | ||
40 | { | ||
41 | if (!s_initialized && value) | ||
42 | new GcNotify(); | ||
43 | |||
44 | s_initialized = value; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | private static bool s_initialized = false; | ||
49 | |||
50 | private GcNotify() {} | ||
51 | |||
52 | ~GcNotify() | ||
53 | { | ||
54 | if (!Environment.HasShutdownStarted && !AppDomain.CurrentDomain.IsFinalizingForUnload()) | ||
55 | { | ||
56 | m_log.DebugFormat("[GC NOTIFY]: Garbage collection triggered."); | ||
57 | |||
58 | if (Enabled) | ||
59 | new GcNotify(); | ||
60 | } | ||
61 | } | ||
62 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a9044d5..662e470 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -60,9 +60,8 @@ namespace OpenSim.Framework | |||
60 | public delegate void ObjectAttach( | 60 | public delegate void ObjectAttach( |
61 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); | 61 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); |
62 | 62 | ||
63 | public delegate void ModifyTerrain(UUID user, | 63 | public delegate void ModifyTerrain(UUID user, float height, float seconds, float brushSize, |
64 | float height, float seconds, byte size, byte action, float north, float west, float south, float east, | 64 | byte action, float north, float west, float south, float east, int parcelLocalID); |
65 | UUID agentId); | ||
66 | 65 | ||
67 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); | 66 | public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); |
68 | 67 | ||
@@ -182,10 +181,8 @@ namespace OpenSim.Framework | |||
182 | public delegate void ParcelAccessListRequest( | 181 | public delegate void ParcelAccessListRequest( |
183 | UUID agentID, UUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); | 182 | UUID agentID, UUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); |
184 | 183 | ||
185 | public delegate void ParcelAccessListUpdateRequest(UUID agentID, uint flags, | 184 | public delegate void ParcelAccessListUpdateRequest(UUID agentID, uint flags, UUID transactionID, |
186 | int landLocalID, UUID transactionID, int sequenceID, | 185 | int landLocalID, List<LandAccessEntry> entries, IClientAPI remote_client); |
187 | int sections, List<LandAccessEntry> entries, | ||
188 | IClientAPI remote_client); | ||
189 | 186 | ||
190 | public delegate void ParcelPropertiesRequest( | 187 | public delegate void ParcelPropertiesRequest( |
191 | int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); | 188 | int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); |
@@ -392,7 +389,7 @@ namespace OpenSim.Framework | |||
392 | IClientAPI remoteClient, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics); | 389 | IClientAPI remoteClient, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics); |
393 | 390 | ||
394 | public delegate void EstateTeleportOneUserHomeRequest( | 391 | public delegate void EstateTeleportOneUserHomeRequest( |
395 | IClientAPI remoteClient, UUID invoice, UUID senderID, UUID prey); | 392 | IClientAPI remoteClient, UUID invoice, UUID senderID, UUID prey, bool kill); |
396 | 393 | ||
397 | public delegate void EstateTeleportAllUsersHomeRequest(IClientAPI remoteClient, UUID invoice, UUID senderID); | 394 | public delegate void EstateTeleportAllUsersHomeRequest(IClientAPI remoteClient, UUID invoice, UUID senderID); |
398 | 395 | ||
@@ -443,7 +440,7 @@ namespace OpenSim.Framework | |||
443 | public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID); | 440 | public delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID); |
444 | 441 | ||
445 | public delegate void SoundTrigger( | 442 | public delegate void SoundTrigger( |
446 | UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle, float radius); | 443 | UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle); |
447 | 444 | ||
448 | public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client); | 445 | public delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client); |
449 | public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client); | 446 | public delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client); |
@@ -589,7 +586,6 @@ namespace OpenSim.Framework | |||
589 | { | 586 | { |
590 | private ISceneEntity m_entity; | 587 | private ISceneEntity m_entity; |
591 | private PrimUpdateFlags m_flags; | 588 | private PrimUpdateFlags m_flags; |
592 | private int m_updateTime; | ||
593 | 589 | ||
594 | public ISceneEntity Entity | 590 | public ISceneEntity Entity |
595 | { | 591 | { |
@@ -599,41 +595,42 @@ namespace OpenSim.Framework | |||
599 | public PrimUpdateFlags Flags | 595 | public PrimUpdateFlags Flags |
600 | { | 596 | { |
601 | get { return m_flags; } | 597 | get { return m_flags; } |
598 | set { m_flags = value; } | ||
602 | } | 599 | } |
603 | 600 | ||
604 | public int UpdateTime | 601 | public virtual void Update() |
605 | { | 602 | { |
606 | get { return m_updateTime; } | 603 | // we are on the new one |
604 | if (m_flags.HasFlag(PrimUpdateFlags.CancelKill)) | ||
605 | { | ||
606 | if (m_flags.HasFlag(PrimUpdateFlags.UpdateProbe)) | ||
607 | m_flags = PrimUpdateFlags.UpdateProbe; | ||
608 | else | ||
609 | m_flags = PrimUpdateFlags.FullUpdatewithAnim; | ||
610 | } | ||
607 | } | 611 | } |
608 | 612 | ||
609 | public virtual void Update(EntityUpdate oldupdate) | 613 | public virtual void Update(EntityUpdate oldupdate) |
610 | { | 614 | { |
611 | // we are on the new one | 615 | // we are on the new one |
612 | PrimUpdateFlags updateFlags = oldupdate.Flags; | 616 | PrimUpdateFlags updateFlags = oldupdate.Flags; |
613 | if(m_flags.HasFlag(PrimUpdateFlags.CancelKill)) | 617 | if (updateFlags.HasFlag(PrimUpdateFlags.UpdateProbe)) |
614 | m_flags = PrimUpdateFlags.FullUpdate; | 618 | updateFlags &= ~PrimUpdateFlags.UpdateProbe; |
615 | else if(updateFlags.HasFlag(PrimUpdateFlags.Kill)) | 619 | if (m_flags.HasFlag(PrimUpdateFlags.CancelKill)) |
616 | return; | 620 | { |
617 | else // kill case will just merge in | 621 | if(m_flags.HasFlag(PrimUpdateFlags.UpdateProbe)) |
622 | m_flags = PrimUpdateFlags.UpdateProbe; | ||
623 | else | ||
624 | m_flags = PrimUpdateFlags.FullUpdatewithAnim; | ||
625 | } | ||
626 | else | ||
618 | m_flags |= updateFlags; | 627 | m_flags |= updateFlags; |
619 | |||
620 | // Use the older of the updates as the updateTime | ||
621 | if (Util.EnvironmentTickCountCompare(UpdateTime, oldupdate.UpdateTime) > 0) | ||
622 | m_updateTime = oldupdate.UpdateTime; | ||
623 | } | 628 | } |
624 | 629 | ||
625 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags) | 630 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags) |
626 | { | 631 | { |
627 | m_entity = entity; | 632 | m_entity = entity; |
628 | m_flags = flags; | 633 | m_flags = flags; |
629 | m_updateTime = Util.EnvironmentTickCount(); | ||
630 | } | ||
631 | |||
632 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, Int32 updateTime) | ||
633 | { | ||
634 | m_entity = entity; | ||
635 | m_flags = flags; | ||
636 | m_updateTime = updateTime; | ||
637 | } | 634 | } |
638 | } | 635 | } |
639 | 636 | ||
@@ -684,10 +681,17 @@ namespace OpenSim.Framework | |||
684 | Particles = 1 << 19, | 681 | Particles = 1 << 19, |
685 | ExtraData = 1 << 20, | 682 | ExtraData = 1 << 20, |
686 | Sound = 1 << 21, | 683 | Sound = 1 << 21, |
687 | Joint = 1 << 22, | 684 | |
688 | FullUpdate = 0x0fffffff, | 685 | TerseUpdate = Position | Rotation | Velocity | Acceleration | AngularVelocity, |
689 | SendInTransit = 0x20000000, | 686 | FullUpdate = 0x00ffffff, |
690 | CancelKill = 0x4fffffff, // 1 << 30 | 687 | |
688 | Animations = 1 << 24, | ||
689 | |||
690 | FullUpdatewithAnim = FullUpdate | Animations, | ||
691 | |||
692 | UpdateProbe = 0x10000000, // 1 << 28 | ||
693 | SendInTransit = 0x20000000, // 1 << 29 | ||
694 | CancelKill = 0x40000000, // 1 << 30 | ||
691 | Kill = 0x80000000 // 1 << 31 | 695 | Kill = 0x80000000 // 1 << 31 |
692 | } | 696 | } |
693 | 697 | ||
@@ -703,9 +707,11 @@ namespace OpenSim.Framework | |||
703 | public interface IClientAPI | 707 | public interface IClientAPI |
704 | { | 708 | { |
705 | Vector3 StartPos { get; set; } | 709 | Vector3 StartPos { get; set; } |
710 | float StartFar { get; set; } | ||
706 | 711 | ||
707 | UUID AgentId { get; } | 712 | UUID AgentId { get; } |
708 | 713 | ||
714 | UUID ScopeId { get; } | ||
709 | /// <summary> | 715 | /// <summary> |
710 | /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it | 716 | /// The scene agent for this client. This will only be set if the client has an agent in a scene (i.e. if it |
711 | /// is connected). | 717 | /// is connected). |
@@ -738,9 +744,6 @@ namespace OpenSim.Framework | |||
738 | 744 | ||
739 | List<uint> SelectedObjects { get; } | 745 | List<uint> SelectedObjects { get; } |
740 | 746 | ||
741 | // [Obsolete("LLClientView Specific - Replace with ???")] | ||
742 | int NextAnimationSequenceNumber { get; } | ||
743 | |||
744 | /// <summary> | 747 | /// <summary> |
745 | /// Returns the full name of the agent/avatar represented by this client | 748 | /// Returns the full name of the agent/avatar represented by this client |
746 | /// </summary> | 749 | /// </summary> |
@@ -767,6 +770,8 @@ namespace OpenSim.Framework | |||
767 | 770 | ||
768 | bool SendLogoutPacketWhenClosing { set; } | 771 | bool SendLogoutPacketWhenClosing { set; } |
769 | 772 | ||
773 | int NextAnimationSequenceNumber {get; set;} | ||
774 | |||
770 | // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] | 775 | // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] |
771 | uint CircuitCode { get; } | 776 | uint CircuitCode { get; } |
772 | 777 | ||
@@ -1101,12 +1106,10 @@ namespace OpenSim.Framework | |||
1101 | /// <param name="agentID">The id of the agent associated with the appearance</param> | 1106 | /// <param name="agentID">The id of the agent associated with the appearance</param> |
1102 | /// <param name="visualParams"></param> | 1107 | /// <param name="visualParams"></param> |
1103 | /// <param name="textureEntry"></param> | 1108 | /// <param name="textureEntry"></param> |
1104 | void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry); | 1109 | void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry, float hoverheight); |
1105 | 1110 | ||
1106 | void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures); | 1111 | void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures); |
1107 | 1112 | ||
1108 | void SendStartPingCheck(byte seq); | ||
1109 | |||
1110 | /// <summary> | 1113 | /// <summary> |
1111 | /// Tell the client that an object has been deleted | 1114 | /// Tell the client that an object has been deleted |
1112 | /// </summary> | 1115 | /// </summary> |
@@ -1116,7 +1119,7 @@ namespace OpenSim.Framework | |||
1116 | // void SendPartFullUpdate(ISceneEntity ent, uint? parentID); | 1119 | // void SendPartFullUpdate(ISceneEntity ent, uint? parentID); |
1117 | 1120 | ||
1118 | void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); | 1121 | void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); |
1119 | void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); | 1122 | void SendRegionHandshake(); |
1120 | 1123 | ||
1121 | /// <summary> | 1124 | /// <summary> |
1122 | /// Send chat to the viewer. | 1125 | /// Send chat to the viewer. |
@@ -1140,8 +1143,8 @@ namespace OpenSim.Framework | |||
1140 | 1143 | ||
1141 | bool CanSendLayerData(); | 1144 | bool CanSendLayerData(); |
1142 | 1145 | ||
1143 | void SendLayerData(float[] map); | 1146 | void SendLayerData(); |
1144 | void SendLayerData(int px, int py, float[] map); | 1147 | void SendLayerData(int[] map); |
1145 | 1148 | ||
1146 | void SendWindData(int version, Vector2[] windSpeeds); | 1149 | void SendWindData(int version, Vector2[] windSpeeds); |
1147 | void SendCloudData(int version, float[] cloudCover); | 1150 | void SendCloudData(int version, float[] cloudCover); |
@@ -1232,7 +1235,8 @@ namespace OpenSim.Framework | |||
1232 | /// <param name="node"></param> | 1235 | /// <param name="node"></param> |
1233 | void SendBulkUpdateInventory(InventoryNodeBase node); | 1236 | void SendBulkUpdateInventory(InventoryNodeBase node); |
1234 | 1237 | ||
1235 | void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory); | 1238 | void SendXferPacket(ulong xferID, uint packet, |
1239 | byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory); | ||
1236 | 1240 | ||
1237 | void SendAbortXferPacket(ulong xferID); | 1241 | void SendAbortXferPacket(ulong xferID); |
1238 | 1242 | ||
@@ -1510,5 +1514,6 @@ namespace OpenSim.Framework | |||
1510 | void SendAgentTerseUpdate(ISceneEntity presence); | 1514 | void SendAgentTerseUpdate(ISceneEntity presence); |
1511 | 1515 | ||
1512 | void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data); | 1516 | void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data); |
1517 | uint GetViewerCaps(); | ||
1513 | } | 1518 | } |
1514 | } | 1519 | } |
diff --git a/OpenSim/Framework/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs index 3db2765..043056f 100644 --- a/OpenSim/Framework/ICommandConsole.cs +++ b/OpenSim/Framework/ICommandConsole.cs | |||
@@ -25,6 +25,7 @@ | |||
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 | ||
28 | using Nini.Config; | ||
28 | using System; | 29 | using System; |
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Xml; | 31 | using System.Xml; |
@@ -102,5 +103,7 @@ namespace OpenSim.Framework | |||
102 | void RunCommand(string cmd); | 103 | void RunCommand(string cmd); |
103 | 104 | ||
104 | string ReadLine(string p, bool isCommand, bool e); | 105 | string ReadLine(string p, bool isCommand, bool e); |
106 | |||
107 | void ReadConfig(IConfigSource configSource); | ||
105 | } | 108 | } |
106 | } | 109 | } |
diff --git a/OpenSim/Framework/IConsole.cs b/OpenSim/Framework/IConsole.cs index 79560d8..ef23cdc 100644 --- a/OpenSim/Framework/IConsole.cs +++ b/OpenSim/Framework/IConsole.cs | |||
@@ -32,22 +32,19 @@ namespace OpenSim.Framework | |||
32 | { | 32 | { |
33 | public interface IConsole | 33 | public interface IConsole |
34 | { | 34 | { |
35 | object ConsoleScene { get; set; } | ||
36 | 35 | ||
37 | void Output(string text, string level); | ||
38 | void Output(string text); | ||
39 | void OutputFormat(string format, params object[] components); | ||
40 | 36 | ||
41 | string CmdPrompt(string p); | 37 | IScene ConsoleScene { get; set; } |
42 | string CmdPrompt(string p, string def); | ||
43 | string CmdPrompt(string p, List<char> excludedCharacters); | ||
44 | string CmdPrompt(string p, string def, List<char> excludedCharacters); | ||
45 | 38 | ||
46 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | 39 | void Output(string format); |
47 | string CmdPrompt(string prompt, string defaultresponse, List<string> options); | 40 | void Output(string format, params object[] components); |
41 | |||
42 | string Prompt(string p); | ||
43 | string Prompt(string p, string def); | ||
44 | string Prompt(string p, List<char> excludedCharacters); | ||
45 | string Prompt(string p, string def, List<char> excludedCharacters, bool echo = true); | ||
48 | 46 | ||
49 | // Displays a prompt and waits for the user to enter a string, then returns that string | 47 | // Displays a prompt and returns a default value, user may only enter 1 of 2 options |
50 | // (Done with no echo and suitable for passwords) | 48 | string Prompt(string prompt, string defaultresponse, List<string> options); |
51 | string PasswdPrompt(string p); | ||
52 | } | 49 | } |
53 | } \ No newline at end of file | 50 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/ILandChannel.cs b/OpenSim/Framework/ILandChannel.cs index 8667837..6f4a07a 100644 --- a/OpenSim/Framework/ILandChannel.cs +++ b/OpenSim/Framework/ILandChannel.cs | |||
@@ -33,6 +33,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
33 | { | 33 | { |
34 | public interface ILandChannel | 34 | public interface ILandChannel |
35 | { | 35 | { |
36 | |||
37 | float BanLineSafeHeight {get;} | ||
36 | /// <summary> | 38 | /// <summary> |
37 | /// Get all parcels | 39 | /// Get all parcels |
38 | /// </summary> | 40 | /// </summary> |
@@ -96,7 +98,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
96 | 98 | ||
97 | void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); | 99 | void Join(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); | 100 | void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id); |
99 | void sendClientInitialLandInfo(IClientAPI remoteClient); | 101 | void sendClientInitialLandInfo(IClientAPI remoteClient, bool overlay); |
100 | |||
101 | } | 102 | } |
102 | } | 103 | } |
diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index a783256..1f39482 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Framework | |||
85 | void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); | 85 | void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); |
86 | List<LandAccessEntry> CreateAccessListArrayByFlag(AccessList flag); | 86 | List<LandAccessEntry> CreateAccessListArrayByFlag(AccessList flag); |
87 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); | 87 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); |
88 | void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List<LandAccessEntry> entries, IClientAPI remote_client); | 88 | void UpdateAccessList(uint flags, UUID transationID, List<LandAccessEntry> entries); |
89 | void UpdateLandBitmapByteArray(); | 89 | void UpdateLandBitmapByteArray(); |
90 | void SetLandBitmapFromByteArray(); | 90 | void SetLandBitmapFromByteArray(); |
91 | bool[,] GetLandBitmap(); | 91 | bool[,] GetLandBitmap(); |
diff --git a/OpenSim/Framework/ISceneAgent.cs b/OpenSim/Framework/ISceneAgent.cs index 5d70b83..43e1b08 100644 --- a/OpenSim/Framework/ISceneAgent.cs +++ b/OpenSim/Framework/ISceneAgent.cs | |||
@@ -70,14 +70,6 @@ namespace OpenSim.Framework | |||
70 | AvatarAppearance Appearance { get; set; } | 70 | AvatarAppearance Appearance { get; set; } |
71 | 71 | ||
72 | /// <summary> | 72 | /// <summary> |
73 | /// Send initial scene data to the client controlling this agent | ||
74 | /// </summary> | ||
75 | /// <remarks> | ||
76 | /// This includes scene object data and the appearance data of other avatars. | ||
77 | /// </remarks> | ||
78 | void SendInitialDataToMe(); | ||
79 | |||
80 | /// <summary> | ||
81 | /// Direction in which the scene presence is looking. | 73 | /// Direction in which the scene presence is looking. |
82 | /// </summary> | 74 | /// </summary> |
83 | /// <remarks>Will be Vector3.Zero for a child agent.</remarks> | 75 | /// <remarks>Will be Vector3.Zero for a child agent.</remarks> |
diff --git a/OpenSim/Framework/InventoryCollection.cs b/OpenSim/Framework/InventoryCollection.cs index 59655eb..a55a1cb 100644 --- a/OpenSim/Framework/InventoryCollection.cs +++ b/OpenSim/Framework/InventoryCollection.cs | |||
@@ -40,5 +40,6 @@ namespace OpenSim.Framework | |||
40 | public UUID OwnerID; | 40 | public UUID OwnerID; |
41 | public UUID FolderID; | 41 | public UUID FolderID; |
42 | public int Version; | 42 | public int Version; |
43 | public int Descendents; | ||
43 | } | 44 | } |
44 | } | 45 | } |
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index c359a0c..dcf078c 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Text; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | 31 | ||
31 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
@@ -415,5 +416,40 @@ namespace OpenSim.Framework | |||
415 | { | 416 | { |
416 | return MemberwiseClone(); | 417 | return MemberwiseClone(); |
417 | } | 418 | } |
419 | |||
420 | public void ToLLSDxml(StringBuilder lsl, uint flagsMask = 0xffffffff) | ||
421 | { | ||
422 | LLSDxmlEncode.AddMap(lsl); | ||
423 | LLSDxmlEncode.AddElem("parent_id", Folder, lsl); | ||
424 | LLSDxmlEncode.AddElem("asset_id", AssetID, lsl); | ||
425 | LLSDxmlEncode.AddElem("item_id", ID, lsl); | ||
426 | |||
427 | LLSDxmlEncode.AddMap("permissions",lsl); | ||
428 | LLSDxmlEncode.AddElem("creator_id", CreatorIdAsUuid, lsl); | ||
429 | LLSDxmlEncode.AddElem("owner_id", Owner, lsl); | ||
430 | LLSDxmlEncode.AddElem("group_id", GroupID, lsl); | ||
431 | LLSDxmlEncode.AddElem("base_mask", (int)CurrentPermissions, lsl); | ||
432 | LLSDxmlEncode.AddElem("owner_mask", (int)CurrentPermissions, lsl); | ||
433 | LLSDxmlEncode.AddElem("group_mask", (int)GroupPermissions, lsl); | ||
434 | LLSDxmlEncode.AddElem("everyone_mask", (int)EveryOnePermissions, lsl); | ||
435 | LLSDxmlEncode.AddElem("next_owner_mask", (int)NextPermissions, lsl); | ||
436 | LLSDxmlEncode.AddElem("is_owner_group", GroupOwned, lsl); | ||
437 | LLSDxmlEncode.AddEndMap(lsl); | ||
438 | |||
439 | LLSDxmlEncode.AddElem("type", AssetType, lsl); | ||
440 | LLSDxmlEncode.AddElem("inv_type", InvType, lsl); | ||
441 | LLSDxmlEncode.AddElem("flags", (int)(Flags & flagsMask), lsl); | ||
442 | |||
443 | LLSDxmlEncode.AddMap("sale_info",lsl); | ||
444 | LLSDxmlEncode.AddElem("sale_price", SalePrice, lsl); | ||
445 | LLSDxmlEncode.AddElem("sale_type", SaleType, lsl); | ||
446 | LLSDxmlEncode.AddEndMap(lsl); | ||
447 | |||
448 | LLSDxmlEncode.AddElem("name", Name, lsl); | ||
449 | LLSDxmlEncode.AddElem("desc", Description, lsl); | ||
450 | LLSDxmlEncode.AddElem("created_at", CreationDate, lsl); | ||
451 | |||
452 | LLSDxmlEncode.AddEndMap(lsl); | ||
453 | } | ||
418 | } | 454 | } |
419 | } | 455 | } |
diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs new file mode 100644 index 0000000..97b3ca1 --- /dev/null +++ b/OpenSim/Framework/LLSDxmlEncode.cs | |||
@@ -0,0 +1,784 @@ | |||
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 | |||
28 | // a class for low level LLSD encoding into a provided StringBuilder | ||
29 | // for cases where we already need to know the low level detail | ||
30 | // and so using something like OSD or even protbuf is just a pure waste | ||
31 | |||
32 | using System; | ||
33 | using System.Globalization; | ||
34 | using System.Text; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Framework | ||
38 | { | ||
39 | public static class LLSDxmlEncode | ||
40 | { | ||
41 | static readonly DateTime depoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | ||
42 | |||
43 | public static void AddStart(StringBuilder sb, bool addxmlversion = false) | ||
44 | { | ||
45 | if(addxmlversion) | ||
46 | sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid | ||
47 | else | ||
48 | sb.Append("<llsd>"); | ||
49 | } | ||
50 | |||
51 | public const string LLSDEmpty = "<llsd><map /></llsd>"; | ||
52 | |||
53 | // got tired of creating a stringbuilder all the time; | ||
54 | public static StringBuilder Start(int size = 256, bool addxmlversion = false) | ||
55 | { | ||
56 | StringBuilder sb = new StringBuilder(size); | ||
57 | if(addxmlversion) | ||
58 | sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd>"); // legacy llsd xml name still valid | ||
59 | else | ||
60 | sb.Append("<llsd>"); | ||
61 | return sb; | ||
62 | } | ||
63 | |||
64 | public static void AddEnd(StringBuilder sb) | ||
65 | { | ||
66 | sb.Append("</llsd>"); | ||
67 | } | ||
68 | |||
69 | public static string End(StringBuilder sb) | ||
70 | { | ||
71 | sb.Append("</llsd>"); | ||
72 | return sb.ToString(); | ||
73 | } | ||
74 | |||
75 | // map == a list of key value pairs | ||
76 | public static void AddMap(StringBuilder sb) | ||
77 | { | ||
78 | sb.Append("<map>"); | ||
79 | } | ||
80 | |||
81 | public static void AddEndMap(StringBuilder sb) | ||
82 | { | ||
83 | sb.Append("</map>"); | ||
84 | } | ||
85 | |||
86 | public static void AddEmptyMap(StringBuilder sb) | ||
87 | { | ||
88 | sb.Append("<map />"); | ||
89 | } | ||
90 | |||
91 | // array == a list values | ||
92 | public static void AddArray(StringBuilder sb) | ||
93 | { | ||
94 | sb.Append("<array>"); | ||
95 | } | ||
96 | |||
97 | public static void AddEndArray(StringBuilder sb) | ||
98 | { | ||
99 | sb.Append("</array>"); | ||
100 | } | ||
101 | |||
102 | public static void AddEndMapAndArray(StringBuilder sb) | ||
103 | { | ||
104 | sb.Append("</map></array>"); | ||
105 | } | ||
106 | |||
107 | public static void AddEmptyArray(StringBuilder sb) | ||
108 | { | ||
109 | sb.Append("<array />"); | ||
110 | } | ||
111 | |||
112 | // undefined or null | ||
113 | public static void AddUnknownElem(StringBuilder sb) | ||
114 | { | ||
115 | sb.Append("<undef />"); | ||
116 | } | ||
117 | |||
118 | public static void AddElem(bool e, StringBuilder sb) | ||
119 | { | ||
120 | if(e) | ||
121 | sb.Append("<boolean>1</boolean>"); | ||
122 | else | ||
123 | sb.Append("<boolean />"); | ||
124 | } | ||
125 | |||
126 | public static void AddElem(byte e, StringBuilder sb) | ||
127 | { | ||
128 | if(e == 0) | ||
129 | sb.Append("<integer />"); | ||
130 | else | ||
131 | { | ||
132 | sb.Append("<integer>"); | ||
133 | sb.Append(e.ToString()); | ||
134 | sb.Append("</integer>"); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public static void AddElem(byte[] e, StringBuilder sb) | ||
139 | { | ||
140 | if(e == null || e.Length == 0) | ||
141 | sb.Append("binary />"); | ||
142 | else | ||
143 | { | ||
144 | sb.Append("<binary>"); // encode64 is default | ||
145 | sb.Append(Convert.ToBase64String(e,Base64FormattingOptions.None)); | ||
146 | sb.Append("</binary>"); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | public static void AddElem(int e, StringBuilder sb) | ||
151 | { | ||
152 | if(e == 0) | ||
153 | sb.Append("<integer />"); | ||
154 | else | ||
155 | { | ||
156 | sb.Append("<integer>"); | ||
157 | sb.Append(e.ToString()); | ||
158 | sb.Append("</integer>"); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | public static void AddElem(uint e, StringBuilder sb) | ||
163 | { | ||
164 | AddElem(uintToByteArray(e), sb); | ||
165 | } | ||
166 | |||
167 | public static void AddElem(ulong e, StringBuilder sb) | ||
168 | { | ||
169 | AddElem(ulongToByteArray(e), sb); | ||
170 | } | ||
171 | |||
172 | public static void AddElem(float e, StringBuilder sb) | ||
173 | { | ||
174 | if(e == 0) | ||
175 | sb.Append("<real />"); | ||
176 | else | ||
177 | { | ||
178 | sb.Append("<real>"); | ||
179 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | ||
180 | sb.Append("</real>"); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | public static void AddElem(Vector2 e, StringBuilder sb) | ||
185 | { | ||
186 | sb.Append("<array>"); | ||
187 | |||
188 | if(e.X == 0) | ||
189 | sb.Append("<real />"); | ||
190 | else | ||
191 | { | ||
192 | sb.Append("<real>"); | ||
193 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
194 | sb.Append("</real>"); | ||
195 | } | ||
196 | |||
197 | if(e.Y == 0) | ||
198 | sb.Append("<real /></array>"); | ||
199 | else | ||
200 | { | ||
201 | sb.Append("<real>"); | ||
202 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
203 | sb.Append("</real></array>"); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | public static void AddElem(Vector3 e, StringBuilder sb) | ||
208 | { | ||
209 | sb.Append("<array>"); | ||
210 | |||
211 | if(e.X == 0) | ||
212 | sb.Append("<real />"); | ||
213 | else | ||
214 | { | ||
215 | sb.Append("<real>"); | ||
216 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
217 | sb.Append("</real>"); | ||
218 | } | ||
219 | |||
220 | if(e.Y == 0) | ||
221 | sb.Append("<real />"); | ||
222 | else | ||
223 | { | ||
224 | sb.Append("<real>"); | ||
225 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
226 | sb.Append("</real>"); | ||
227 | } | ||
228 | |||
229 | if(e.Z == 0) | ||
230 | sb.Append("<real /></array>"); | ||
231 | else | ||
232 | { | ||
233 | sb.Append("<real>"); | ||
234 | sb.Append(e.Z.ToString(CultureInfo.InvariantCulture)); | ||
235 | sb.Append("</real></array>"); | ||
236 | } | ||
237 | } | ||
238 | |||
239 | public static void AddElem(Quaternion e, StringBuilder sb) | ||
240 | { | ||
241 | sb.Append("<array><key>x</key>"); | ||
242 | |||
243 | if(e.X == 0) | ||
244 | sb.Append("<real />"); | ||
245 | else | ||
246 | { | ||
247 | sb.Append("<real>"); | ||
248 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
249 | sb.Append("</real>"); | ||
250 | } | ||
251 | |||
252 | if(e.Y == 0) | ||
253 | sb.Append("<real />"); | ||
254 | else | ||
255 | { | ||
256 | sb.Append("<real>"); | ||
257 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
258 | sb.Append("</real>"); | ||
259 | } | ||
260 | if(e.Z == 0) | ||
261 | sb.Append("<real />"); | ||
262 | else | ||
263 | { | ||
264 | sb.Append("<real>"); | ||
265 | sb.Append(e.Z.ToString(CultureInfo.InvariantCulture)); | ||
266 | sb.Append("</real>"); | ||
267 | } | ||
268 | |||
269 | if(e.W == 0) | ||
270 | sb.Append("<real /></array>"); | ||
271 | else | ||
272 | { | ||
273 | sb.Append("<real>"); | ||
274 | sb.Append(e.W.ToString(CultureInfo.InvariantCulture)); | ||
275 | sb.Append("</real></array>"); | ||
276 | } | ||
277 | } | ||
278 | |||
279 | public static void AddElem(double e, StringBuilder sb) | ||
280 | { | ||
281 | if(e == 0) | ||
282 | sb.Append("<real />"); | ||
283 | else | ||
284 | { | ||
285 | sb.Append("<real>"); | ||
286 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | ||
287 | sb.Append("</real>"); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | public static void AddElem(UUID e, StringBuilder sb) | ||
292 | { | ||
293 | if(e == UUID.Zero) | ||
294 | sb.Append("<uuid />"); | ||
295 | else | ||
296 | { | ||
297 | sb.Append("<uuid>"); | ||
298 | EscapeToXML(e.ToString(), sb); | ||
299 | sb.Append("</uuid>"); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | public static void AddElem(string e, StringBuilder sb) | ||
304 | { | ||
305 | if(String.IsNullOrEmpty(e)) | ||
306 | sb.Append("<string />"); | ||
307 | else | ||
308 | { | ||
309 | sb.Append("<string>"); | ||
310 | EscapeToXML(e, sb); | ||
311 | sb.Append("</string>"); | ||
312 | } | ||
313 | } | ||
314 | |||
315 | public static void AddRawElem(string e, StringBuilder sb) | ||
316 | { | ||
317 | if(String.IsNullOrEmpty(e)) | ||
318 | return; | ||
319 | |||
320 | sb.Append(e); | ||
321 | } | ||
322 | |||
323 | public static void AddElem(Uri e, StringBuilder sb) | ||
324 | { | ||
325 | if(e == null) | ||
326 | { | ||
327 | sb.Append("<uri />"); | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | string s; | ||
332 | if (e.IsAbsoluteUri) | ||
333 | s = e.AbsoluteUri; | ||
334 | else | ||
335 | s = e.ToString(); | ||
336 | |||
337 | if(String.IsNullOrEmpty(s)) | ||
338 | sb.Append("<uri />"); | ||
339 | else | ||
340 | { | ||
341 | sb.Append("<uri>"); | ||
342 | sb.Append(s); | ||
343 | sb.Append("</uri>"); | ||
344 | } | ||
345 | } | ||
346 | |||
347 | public static void AddElem(DateTime e, StringBuilder sb) | ||
348 | { | ||
349 | DateTime u = e.ToUniversalTime(); | ||
350 | if(u == depoch) | ||
351 | { | ||
352 | sb.Append("<date />"); | ||
353 | return; | ||
354 | } | ||
355 | string format; | ||
356 | if(u.Hour == 0 && u.Minute == 0 && u.Second == 0) | ||
357 | format = "yyyy-MM-dd"; | ||
358 | else if (u.Millisecond > 0) | ||
359 | format = "yyyy-MM-ddTHH:mm:ss.ffZ"; | ||
360 | else | ||
361 | format = "yyyy-MM-ddTHH:mm:ssZ"; | ||
362 | sb.Append("<date>"); | ||
363 | sb.Append(u.ToString(format,CultureInfo.InvariantCulture)); | ||
364 | sb.Append("</date>"); | ||
365 | } | ||
366 | |||
367 | //************ key value ******************* | ||
368 | // assumes name is a valid llsd key | ||
369 | |||
370 | public static void AddMap(string name, StringBuilder sb) | ||
371 | { | ||
372 | sb.Append("<key>"); | ||
373 | sb.Append(name); | ||
374 | sb.Append("</key><map>"); | ||
375 | } | ||
376 | |||
377 | public static void AddEmptyMap(string name, StringBuilder sb) | ||
378 | { | ||
379 | sb.Append("<key>"); | ||
380 | sb.Append(name); | ||
381 | sb.Append("</key><map />"); | ||
382 | } | ||
383 | |||
384 | // array == a list values | ||
385 | public static void AddArray(string name, StringBuilder sb) | ||
386 | { | ||
387 | sb.Append("<key>"); | ||
388 | sb.Append(name); | ||
389 | sb.Append("</key><array>"); | ||
390 | } | ||
391 | |||
392 | public static void AddArrayAndMap(string name, StringBuilder sb) | ||
393 | { | ||
394 | sb.Append("<key>"); | ||
395 | sb.Append(name); | ||
396 | sb.Append("</key><array><map>"); | ||
397 | } | ||
398 | |||
399 | public static void AddEmptyArray(string name, StringBuilder sb) | ||
400 | { | ||
401 | sb.Append("<key>"); | ||
402 | sb.Append(name); | ||
403 | sb.Append("</key><array />"); | ||
404 | } | ||
405 | |||
406 | // undefined or null | ||
407 | public static void AddUnknownElem(string name, StringBuilder sb) | ||
408 | { | ||
409 | sb.Append("<key>"); | ||
410 | sb.Append(name); | ||
411 | sb.Append("</key><undef />"); | ||
412 | } | ||
413 | |||
414 | public static void AddElem(string name, bool e, StringBuilder sb) | ||
415 | { | ||
416 | sb.Append("<key>"); | ||
417 | sb.Append(name); | ||
418 | sb.Append("</key>"); | ||
419 | |||
420 | if(e) | ||
421 | sb.Append("<boolean>1</boolean>"); | ||
422 | else | ||
423 | sb.Append("<boolean />"); | ||
424 | } | ||
425 | |||
426 | public static void AddElem(string name, byte e, StringBuilder sb) | ||
427 | { | ||
428 | sb.Append("<key>"); | ||
429 | sb.Append(name); | ||
430 | sb.Append("</key>"); | ||
431 | |||
432 | if(e == 0) | ||
433 | sb.Append("<integer />"); | ||
434 | else | ||
435 | { | ||
436 | sb.Append("<integer>"); | ||
437 | sb.Append(e.ToString()); | ||
438 | sb.Append("</integer>"); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | public static void AddElem(string name, byte[] e, StringBuilder sb) | ||
443 | { | ||
444 | sb.Append("<key>"); | ||
445 | sb.Append(name); | ||
446 | sb.Append("</key>"); | ||
447 | |||
448 | if(e == null || e.Length == 0) | ||
449 | sb.Append("binary />"); | ||
450 | else | ||
451 | { | ||
452 | sb.Append("<binary>"); // encode64 is default | ||
453 | sb.Append(Convert.ToBase64String(e,Base64FormattingOptions.None)); | ||
454 | sb.Append("</binary>"); | ||
455 | } | ||
456 | } | ||
457 | |||
458 | public static void AddElem(string name, int e, StringBuilder sb) | ||
459 | { | ||
460 | sb.Append("<key>"); | ||
461 | sb.Append(name); | ||
462 | sb.Append("</key>"); | ||
463 | |||
464 | if(e == 0) | ||
465 | sb.Append("<integer />"); | ||
466 | else | ||
467 | { | ||
468 | sb.Append("<integer>"); | ||
469 | sb.Append(e.ToString()); | ||
470 | sb.Append("</integer>"); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | public static void AddElem(string name, uint e, StringBuilder sb) | ||
475 | { | ||
476 | AddElem(name, uintToByteArray(e), sb); | ||
477 | } | ||
478 | |||
479 | public static void AddElem(string name, ulong e, StringBuilder sb) | ||
480 | { | ||
481 | AddElem(name, ulongToByteArray(e), sb); | ||
482 | } | ||
483 | |||
484 | public static void AddElem(string name, float e, StringBuilder sb) | ||
485 | { | ||
486 | sb.Append("<key>"); | ||
487 | sb.Append(name); | ||
488 | sb.Append("</key>"); | ||
489 | |||
490 | if(e == 0) | ||
491 | sb.Append("<real />"); | ||
492 | else | ||
493 | { | ||
494 | sb.Append("<real>"); | ||
495 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | ||
496 | sb.Append("</real>"); | ||
497 | } | ||
498 | } | ||
499 | |||
500 | public static void AddElem(string name, Vector2 e, StringBuilder sb) | ||
501 | { | ||
502 | sb.Append("<key>"); | ||
503 | sb.Append(name); | ||
504 | sb.Append("</key><array>>"); | ||
505 | |||
506 | if(e.X == 0) | ||
507 | sb.Append("<real />"); | ||
508 | else | ||
509 | { | ||
510 | sb.Append("<real>"); | ||
511 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
512 | sb.Append("</real>"); | ||
513 | } | ||
514 | |||
515 | if(e.Y == 0) | ||
516 | sb.Append("<real /></array>"); | ||
517 | else | ||
518 | { | ||
519 | sb.Append("<real>"); | ||
520 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
521 | sb.Append("</real></array>"); | ||
522 | } | ||
523 | } | ||
524 | |||
525 | public static void AddElem(string name, Vector3 e, StringBuilder sb) | ||
526 | { | ||
527 | sb.Append("<key>"); | ||
528 | sb.Append(name); | ||
529 | sb.Append("</key><array>"); | ||
530 | |||
531 | if(e.X == 0) | ||
532 | sb.Append("<real />"); | ||
533 | else | ||
534 | { | ||
535 | sb.Append("<real>"); | ||
536 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
537 | sb.Append("</real>"); | ||
538 | } | ||
539 | |||
540 | if(e.Y == 0) | ||
541 | sb.Append("<real />"); | ||
542 | else | ||
543 | { | ||
544 | sb.Append("<real>"); | ||
545 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
546 | sb.Append("</real>"); | ||
547 | } | ||
548 | |||
549 | if(e.Z == 0) | ||
550 | sb.Append("<real /></array>"); | ||
551 | else | ||
552 | { | ||
553 | sb.Append("<real>"); | ||
554 | sb.Append(e.Z.ToString(CultureInfo.InvariantCulture)); | ||
555 | sb.Append("</real></array>"); | ||
556 | } | ||
557 | } | ||
558 | |||
559 | public static void AddElem(string name, Quaternion e, StringBuilder sb) | ||
560 | { | ||
561 | sb.Append("<key>"); | ||
562 | sb.Append(name); | ||
563 | sb.Append("</key><array>"); | ||
564 | |||
565 | if(e.X == 0) | ||
566 | sb.Append("<real />"); | ||
567 | else | ||
568 | { | ||
569 | sb.Append("<real>"); | ||
570 | sb.Append(e.X.ToString(CultureInfo.InvariantCulture)); | ||
571 | sb.Append("</real>"); | ||
572 | } | ||
573 | |||
574 | if(e.Y == 0) | ||
575 | sb.Append("<real />"); | ||
576 | else | ||
577 | { | ||
578 | sb.Append("<real>"); | ||
579 | sb.Append(e.Y.ToString(CultureInfo.InvariantCulture)); | ||
580 | sb.Append("</real>"); | ||
581 | } | ||
582 | if(e.Z == 0) | ||
583 | sb.Append("<real />"); | ||
584 | else | ||
585 | { | ||
586 | sb.Append("<real>"); | ||
587 | sb.Append(e.Z.ToString(CultureInfo.InvariantCulture)); | ||
588 | sb.Append("</real>"); | ||
589 | } | ||
590 | |||
591 | if(e.W == 0) | ||
592 | sb.Append("<real /></array>"); | ||
593 | else | ||
594 | { | ||
595 | sb.Append("<real>"); | ||
596 | sb.Append(e.W.ToString(CultureInfo.InvariantCulture)); | ||
597 | sb.Append("</real></array>"); | ||
598 | } | ||
599 | } | ||
600 | |||
601 | public static void AddElem(string name, double e, StringBuilder sb) | ||
602 | { | ||
603 | sb.Append("<key>"); | ||
604 | sb.Append(name); | ||
605 | sb.Append("</key>"); | ||
606 | |||
607 | if(e == 0) | ||
608 | sb.Append("<real />"); | ||
609 | else | ||
610 | { | ||
611 | sb.Append("<real>"); | ||
612 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | ||
613 | sb.Append("</real>"); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | public static void AddElem(string name, UUID e, StringBuilder sb) | ||
618 | { | ||
619 | sb.Append("<key>"); | ||
620 | sb.Append(name); | ||
621 | sb.Append("</key>"); | ||
622 | |||
623 | if(e == UUID.Zero) | ||
624 | sb.Append("<uuid />"); | ||
625 | else | ||
626 | { | ||
627 | sb.Append("<uuid>"); | ||
628 | EscapeToXML(e.ToString(), sb); | ||
629 | sb.Append("</uuid>"); | ||
630 | } | ||
631 | } | ||
632 | |||
633 | public static void AddElem(string name, string e, StringBuilder sb) | ||
634 | { | ||
635 | sb.Append("<key>"); | ||
636 | sb.Append(name); | ||
637 | sb.Append("</key>"); | ||
638 | |||
639 | if(String.IsNullOrEmpty(e)) | ||
640 | sb.Append("<string />"); | ||
641 | else | ||
642 | { | ||
643 | sb.Append("<string>"); | ||
644 | EscapeToXML(e, sb); | ||
645 | sb.Append("</string>"); | ||
646 | } | ||
647 | } | ||
648 | |||
649 | public static void AddRawElem(string name, string e, StringBuilder sb) | ||
650 | { | ||
651 | if (String.IsNullOrEmpty(e)) | ||
652 | return; | ||
653 | |||
654 | sb.Append("<key>"); | ||
655 | sb.Append(name); | ||
656 | sb.Append("</key>"); | ||
657 | sb.Append(e); | ||
658 | } | ||
659 | |||
660 | public static void AddElem(string name, Uri e, StringBuilder sb) | ||
661 | { | ||
662 | sb.Append("<key>"); | ||
663 | sb.Append(name); | ||
664 | sb.Append("</key>"); | ||
665 | |||
666 | if(e == null) | ||
667 | { | ||
668 | sb.Append("<uri />"); | ||
669 | return; | ||
670 | } | ||
671 | |||
672 | string s; | ||
673 | if (e.IsAbsoluteUri) | ||
674 | s = e.AbsoluteUri; | ||
675 | else | ||
676 | s = e.ToString(); | ||
677 | |||
678 | if(String.IsNullOrEmpty(s)) | ||
679 | sb.Append("<uri />"); | ||
680 | else | ||
681 | { | ||
682 | sb.Append("<uri>"); | ||
683 | sb.Append(s); | ||
684 | sb.Append("</uri>"); | ||
685 | } | ||
686 | } | ||
687 | |||
688 | public static void AddElem(string name, DateTime e, StringBuilder sb) | ||
689 | { | ||
690 | sb.Append("<key>"); | ||
691 | sb.Append(name); | ||
692 | sb.Append("</key>"); | ||
693 | |||
694 | DateTime u = e.ToUniversalTime(); | ||
695 | if(u == depoch) | ||
696 | { | ||
697 | sb.Append("<date />"); | ||
698 | return; | ||
699 | } | ||
700 | string format; | ||
701 | if(u.Hour == 0 && u.Minute == 0 && u.Second == 0) | ||
702 | format = "yyyy-MM-dd"; | ||
703 | else if (u.Millisecond > 0) | ||
704 | format = "yyyy-MM-ddTHH:mm:ss.ffZ"; | ||
705 | else | ||
706 | format = "yyyy-MM-ddTHH:mm:ssZ"; | ||
707 | sb.Append("<date>"); | ||
708 | sb.Append(u.ToString(format,CultureInfo.InvariantCulture)); | ||
709 | sb.Append("</date>"); | ||
710 | } | ||
711 | |||
712 | public static void AddLLSD(string e, StringBuilder sb) | ||
713 | { | ||
714 | sb.Append(e); | ||
715 | } | ||
716 | |||
717 | public static void AddLLSD(string name, string e, StringBuilder sb) | ||
718 | { | ||
719 | sb.Append("<key>"); | ||
720 | sb.Append(name); | ||
721 | sb.Append("</key>"); | ||
722 | sb.Append(e); | ||
723 | } | ||
724 | |||
725 | public static void EscapeToXML(string s, StringBuilder sb) | ||
726 | { | ||
727 | int i; | ||
728 | char c; | ||
729 | int len = s.Length; | ||
730 | |||
731 | for (i = 0; i < len; i++) | ||
732 | { | ||
733 | c = s[i]; | ||
734 | switch (c) | ||
735 | { | ||
736 | case '<': | ||
737 | sb.Append("<"); | ||
738 | break; | ||
739 | case '>': | ||
740 | sb.Append(">"); | ||
741 | break; | ||
742 | case '&': | ||
743 | sb.Append("&"); | ||
744 | break; | ||
745 | case '"': | ||
746 | sb.Append("""); | ||
747 | break; | ||
748 | case '\\': | ||
749 | sb.Append("'"); | ||
750 | break; | ||
751 | default: | ||
752 | sb.Append(c); | ||
753 | break; | ||
754 | } | ||
755 | } | ||
756 | } | ||
757 | |||
758 | public static byte[] ulongToByteArray(ulong uLongValue) | ||
759 | { | ||
760 | return new byte[8] | ||
761 | { | ||
762 | (byte)(uLongValue >> 56), | ||
763 | (byte)(uLongValue >> 48), | ||
764 | (byte)(uLongValue >> 40), | ||
765 | (byte)(uLongValue >> 32), | ||
766 | (byte)(uLongValue >> 24), | ||
767 | (byte)(uLongValue >> 16), | ||
768 | (byte)(uLongValue >> 8), | ||
769 | (byte)uLongValue | ||
770 | }; | ||
771 | } | ||
772 | |||
773 | public static byte[] uintToByteArray(uint value) | ||
774 | { | ||
775 | return new byte[4] | ||
776 | { | ||
777 | (byte)(value >> 24), | ||
778 | (byte)(value >> 16), | ||
779 | (byte)(value >> 8), | ||
780 | (byte)value | ||
781 | }; | ||
782 | } | ||
783 | } | ||
784 | } | ||
diff --git a/OpenSim/Framework/Login.cs b/OpenSim/Framework/Login.cs index 54a6654..b8a24ea 100644 --- a/OpenSim/Framework/Login.cs +++ b/OpenSim/Framework/Login.cs | |||
@@ -42,11 +42,13 @@ namespace OpenSim.Framework | |||
42 | public UUID SecureSession = UUID.Zero; | 42 | public UUID SecureSession = UUID.Zero; |
43 | public UUID Session; | 43 | public UUID Session; |
44 | public Vector3 StartPos; | 44 | public Vector3 StartPos; |
45 | public float StartFar; | ||
45 | public AvatarAppearance Appearance; | 46 | public AvatarAppearance Appearance; |
46 | 47 | ||
47 | public Login() | 48 | public Login() |
48 | { | 49 | { |
49 | StartPos = new Vector3(128, 128, 70); | 50 | StartPos = new Vector3(128, 128, 70); |
51 | StartFar = -1; | ||
50 | } | 52 | } |
51 | } | 53 | } |
52 | } | 54 | } |
diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs index 32d6978..e6b2800 100644 --- a/OpenSim/Framework/MapAndArray.cs +++ b/OpenSim/Framework/MapAndArray.cs | |||
@@ -41,14 +41,14 @@ namespace OpenSim.Framework | |||
41 | { | 41 | { |
42 | private Dictionary<TKey, TValue> m_dict; | 42 | private Dictionary<TKey, TValue> m_dict; |
43 | private TValue[] m_array; | 43 | private TValue[] m_array; |
44 | private object m_syncRoot = new object(); | ||
45 | 44 | ||
46 | /// <summary>Number of values currently stored in the collection</summary> | 45 | /// <summary>Number of values currently stored in the collection</summary> |
47 | public int Count { get { return m_array.Length; } } | 46 | public int Count { get { return m_dict.Count; } } |
48 | /// <summary>NOTE: This collection is thread safe. You do not need to | 47 | /// <summary>NOTE: This collection is thread safe. You do not need to |
49 | /// acquire a lock to add, remove, or enumerate entries. This | 48 | /// acquire a lock to add, remove, or enumerate entries. This |
50 | /// synchronization object should only be locked for larger | 49 | /// synchronization object should only be locked for larger |
51 | /// transactions</summary> | 50 | /// transactions</summary> |
51 | private object m_syncRoot = new object(); | ||
52 | public object SyncRoot { get { return m_syncRoot; } } | 52 | public object SyncRoot { get { return m_syncRoot; } } |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
@@ -57,7 +57,7 @@ namespace OpenSim.Framework | |||
57 | public MapAndArray() | 57 | public MapAndArray() |
58 | { | 58 | { |
59 | m_dict = new Dictionary<TKey, TValue>(); | 59 | m_dict = new Dictionary<TKey, TValue>(); |
60 | m_array = new TValue[0]; | 60 | m_array = null; |
61 | } | 61 | } |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
@@ -67,7 +67,7 @@ namespace OpenSim.Framework | |||
67 | public MapAndArray(int capacity) | 67 | public MapAndArray(int capacity) |
68 | { | 68 | { |
69 | m_dict = new Dictionary<TKey, TValue>(capacity); | 69 | m_dict = new Dictionary<TKey, TValue>(capacity); |
70 | m_array = new TValue[0]; | 70 | m_array = null; |
71 | } | 71 | } |
72 | 72 | ||
73 | /// <summary> | 73 | /// <summary> |
@@ -85,7 +85,7 @@ namespace OpenSim.Framework | |||
85 | bool containedKey = m_dict.ContainsKey(key); | 85 | bool containedKey = m_dict.ContainsKey(key); |
86 | 86 | ||
87 | m_dict[key] = value; | 87 | m_dict[key] = value; |
88 | CreateArray(); | 88 | m_array = null; |
89 | 89 | ||
90 | return !containedKey; | 90 | return !containedKey; |
91 | } | 91 | } |
@@ -103,8 +103,8 @@ namespace OpenSim.Framework | |||
103 | lock (m_syncRoot) | 103 | lock (m_syncRoot) |
104 | { | 104 | { |
105 | m_dict.Add(key, value); | 105 | m_dict.Add(key, value); |
106 | CreateArray(); | 106 | m_array = null; |
107 | return m_array.Length; | 107 | return m_dict.Count; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
@@ -118,8 +118,7 @@ namespace OpenSim.Framework | |||
118 | lock (m_syncRoot) | 118 | lock (m_syncRoot) |
119 | { | 119 | { |
120 | bool removed = m_dict.Remove(key); | 120 | bool removed = m_dict.Remove(key); |
121 | CreateArray(); | 121 | m_array = null; |
122 | |||
123 | return removed; | 122 | return removed; |
124 | } | 123 | } |
125 | } | 124 | } |
@@ -158,7 +157,7 @@ namespace OpenSim.Framework | |||
158 | lock (m_syncRoot) | 157 | lock (m_syncRoot) |
159 | { | 158 | { |
160 | m_dict = new Dictionary<TKey, TValue>(); | 159 | m_dict = new Dictionary<TKey, TValue>(); |
161 | m_array = new TValue[0]; | 160 | m_array = null; |
162 | } | 161 | } |
163 | } | 162 | } |
164 | 163 | ||
@@ -170,20 +169,17 @@ namespace OpenSim.Framework | |||
170 | /// values</returns> | 169 | /// values</returns> |
171 | public TValue[] GetArray() | 170 | public TValue[] GetArray() |
172 | { | 171 | { |
173 | return m_array; | 172 | lock (m_syncRoot) |
174 | } | 173 | { |
175 | 174 | if (m_array == null) | |
176 | private void CreateArray() | 175 | { |
177 | { | 176 | if(m_dict.Count == 0) |
178 | // Rebuild the array from the dictionary. This method must be | 177 | return new TValue[0]; |
179 | // called from inside a lock | 178 | m_array = new TValue[m_dict.Count]; |
180 | TValue[] array = new TValue[m_dict.Count]; | 179 | m_dict.Values.CopyTo(m_array, 0); |
181 | int i = 0; | 180 | } |
182 | 181 | return m_array; | |
183 | foreach (TValue value in m_dict.Values) | 182 | } |
184 | array[i++] = value; | ||
185 | |||
186 | m_array = array; | ||
187 | } | 183 | } |
188 | } | 184 | } |
189 | } | 185 | } |
diff --git a/OpenSim/Framework/MinHeap.cs b/OpenSim/Framework/MinHeap.cs index 99ac25d..2731e99 100644 --- a/OpenSim/Framework/MinHeap.cs +++ b/OpenSim/Framework/MinHeap.cs | |||
@@ -45,8 +45,8 @@ namespace OpenSim.Framework | |||
45 | 45 | ||
46 | internal void Clear() | 46 | internal void Clear() |
47 | { | 47 | { |
48 | this.index = -1; | 48 | index = -1; |
49 | this.heap = null; | 49 | heap = null; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
@@ -55,23 +55,26 @@ namespace OpenSim.Framework | |||
55 | internal T value; | 55 | internal T value; |
56 | internal Handle handle; | 56 | internal Handle handle; |
57 | 57 | ||
58 | internal HeapItem(T value, Handle handle) | 58 | internal HeapItem(T _value, Handle _handle) |
59 | { | 59 | { |
60 | this.value = value; | 60 | value = _value; |
61 | this.handle = handle; | 61 | handle = _handle; |
62 | } | 62 | } |
63 | 63 | ||
64 | internal void Clear() | 64 | internal void Clear() |
65 | { | 65 | { |
66 | if (this.handle != null) | 66 | if (handle != null) |
67 | this.handle.Clear(); | 67 | { |
68 | ClearRef(); | 68 | handle.heap = null; |
69 | handle = null; | ||
70 | } | ||
71 | value = default(T); | ||
69 | } | 72 | } |
70 | 73 | ||
71 | internal void ClearRef() | 74 | internal void ClearRef() |
72 | { | 75 | { |
73 | this.value = default(T); | 76 | value = default(T); |
74 | this.handle = null; | 77 | handle = null; |
75 | } | 78 | } |
76 | } | 79 | } |
77 | 80 | ||
@@ -81,6 +84,7 @@ namespace OpenSim.Framework | |||
81 | private int size; | 84 | private int size; |
82 | private object sync_root; | 85 | private object sync_root; |
83 | private int version; | 86 | private int version; |
87 | private int minCapacity; | ||
84 | 88 | ||
85 | private Comparison<T> comparison; | 89 | private Comparison<T> comparison; |
86 | 90 | ||
@@ -90,14 +94,15 @@ namespace OpenSim.Framework | |||
90 | public MinHeap(int capacity, IComparer<T> comparer) : | 94 | public MinHeap(int capacity, IComparer<T> comparer) : |
91 | this(capacity, new Comparison<T>(comparer.Compare)) { } | 95 | this(capacity, new Comparison<T>(comparer.Compare)) { } |
92 | public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { } | 96 | public MinHeap(Comparison<T> comparison) : this(DEFAULT_CAPACITY, comparison) { } |
93 | public MinHeap(int capacity, Comparison<T> comparison) | 97 | public MinHeap(int _capacity, Comparison<T> _comparison) |
94 | { | 98 | { |
95 | this.items = new HeapItem[capacity]; | 99 | minCapacity = 16; |
96 | this.comparison = comparison; | 100 | items = new HeapItem[_capacity]; |
97 | this.size = this.version = 0; | 101 | comparison = _comparison; |
102 | size = version = 0; | ||
98 | } | 103 | } |
99 | 104 | ||
100 | public int Count { get { return this.size; } } | 105 | public int Count { get { return size; } } |
101 | 106 | ||
102 | public bool IsReadOnly { get { return false; } } | 107 | public bool IsReadOnly { get { return false; } } |
103 | 108 | ||
@@ -108,15 +113,16 @@ namespace OpenSim.Framework | |||
108 | get | 113 | get |
109 | { | 114 | { |
110 | Handle handle = ValidateThisHandle(key); | 115 | Handle handle = ValidateThisHandle(key); |
111 | return this.items[handle.index].value; | 116 | return items[handle.index].value; |
112 | } | 117 | } |
113 | 118 | ||
114 | set | 119 | set |
115 | { | 120 | { |
116 | Handle handle = ValidateThisHandle(key); | 121 | Handle handle = ValidateThisHandle(key); |
117 | this.items[handle.index].value = value; | 122 | int indx = handle.index; |
118 | if (!BubbleUp(handle.index)) | 123 | items[indx].value = value; |
119 | BubbleDown(handle.index); | 124 | if (!BubbleUp(indx)) |
125 | BubbleDown(indx); | ||
120 | } | 126 | } |
121 | } | 127 | } |
122 | 128 | ||
@@ -124,9 +130,9 @@ namespace OpenSim.Framework | |||
124 | { | 130 | { |
125 | get | 131 | get |
126 | { | 132 | { |
127 | if (this.sync_root == null) | 133 | if (sync_root == null) |
128 | Interlocked.CompareExchange<object>(ref this.sync_root, new object(), null); | 134 | Interlocked.CompareExchange<object>(ref sync_root, new object(), null); |
129 | return this.sync_root; | 135 | return sync_root; |
130 | } | 136 | } |
131 | } | 137 | } |
132 | 138 | ||
@@ -152,27 +158,27 @@ namespace OpenSim.Framework | |||
152 | 158 | ||
153 | private void Set(HeapItem item, int index) | 159 | private void Set(HeapItem item, int index) |
154 | { | 160 | { |
155 | this.items[index] = item; | 161 | items[index] = item; |
156 | if (item.handle != null) | 162 | if (item.handle != null) |
157 | item.handle.index = index; | 163 | item.handle.index = index; |
158 | } | 164 | } |
159 | 165 | ||
160 | private bool BubbleUp(int index) | 166 | private bool BubbleUp(int index) |
161 | { | 167 | { |
162 | HeapItem item = this.items[index]; | 168 | HeapItem item = items[index]; |
163 | int current, parent; | 169 | int current, parent; |
164 | 170 | ||
165 | for (current = index, parent = (current - 1) / 2; | 171 | for (current = index, parent = (current - 1) / 2; |
166 | (current > 0) && (this.comparison(this.items[parent].value, item.value)) > 0; | 172 | (current > 0) && (comparison(items[parent].value, item.value)) > 0; |
167 | current = parent, parent = (current - 1) / 2) | 173 | current = parent, parent = (current - 1) / 2) |
168 | { | 174 | { |
169 | Set(this.items[parent], current); | 175 | Set(items[parent], current); |
170 | } | 176 | } |
171 | 177 | ||
172 | if (current != index) | 178 | if (current != index) |
173 | { | 179 | { |
174 | Set(item, current); | 180 | Set(item, current); |
175 | ++this.version; | 181 | ++version; |
176 | return true; | 182 | return true; |
177 | } | 183 | } |
178 | return false; | 184 | return false; |
@@ -180,24 +186,25 @@ namespace OpenSim.Framework | |||
180 | 186 | ||
181 | private void BubbleDown(int index) | 187 | private void BubbleDown(int index) |
182 | { | 188 | { |
183 | HeapItem item = this.items[index]; | 189 | HeapItem item = items[index]; |
184 | int current, child; | 190 | int current; |
191 | int child; | ||
185 | 192 | ||
186 | for (current = index, child = (2 * current) + 1; | 193 | for(current = index , child = (2 * current) + 1; |
187 | current < this.size / 2; | 194 | current < size / 2; |
188 | current = child, child = (2 * current) + 1) | 195 | current = child, child = (2 * current) + 1) |
189 | { | 196 | { |
190 | if ((child < this.size - 1) && this.comparison(this.items[child].value, this.items[child + 1].value) > 0) | 197 | if ((child < size - 1) && comparison(items[child].value, items[child + 1].value) > 0) |
191 | ++child; | 198 | ++child; |
192 | if (this.comparison(this.items[child].value, item.value) >= 0) | 199 | if (comparison(items[child].value, item.value) >= 0) |
193 | break; | 200 | break; |
194 | Set(this.items[child], current); | 201 | Set(items[child], current); |
195 | } | 202 | } |
196 | 203 | ||
197 | if (current != index) | 204 | if (current != index) |
198 | { | 205 | { |
199 | Set(item, current); | 206 | Set(item, current); |
200 | ++this.version; | 207 | ++version; |
201 | } | 208 | } |
202 | } | 209 | } |
203 | 210 | ||
@@ -206,7 +213,7 @@ namespace OpenSim.Framework | |||
206 | Handle handle = ValidateHandle(key); | 213 | Handle handle = ValidateHandle(key); |
207 | if (handle.index > -1) | 214 | if (handle.index > -1) |
208 | { | 215 | { |
209 | value = this.items[handle.index].value; | 216 | value = items[handle.index].value; |
210 | return true; | 217 | return true; |
211 | } | 218 | } |
212 | value = default(T); | 219 | value = default(T); |
@@ -228,12 +235,12 @@ namespace OpenSim.Framework | |||
228 | 235 | ||
229 | public void Add(T value, IHandle ihandle) | 236 | public void Add(T value, IHandle ihandle) |
230 | { | 237 | { |
231 | if (this.size == this.items.Length) | 238 | if (size == items.Length) |
232 | { | 239 | { |
233 | int capacity = (int)((this.items.Length * 200L) / 100L); | 240 | int newcapacity = (int)((items.Length * 200L) / 100L); |
234 | if (capacity < (this.items.Length + DEFAULT_CAPACITY)) | 241 | if (newcapacity < (items.Length + DEFAULT_CAPACITY)) |
235 | capacity = this.items.Length + DEFAULT_CAPACITY; | 242 | newcapacity = items.Length + DEFAULT_CAPACITY; |
236 | Array.Resize<HeapItem>(ref this.items, capacity); | 243 | Array.Resize<HeapItem>(ref items, newcapacity); |
237 | } | 244 | } |
238 | 245 | ||
239 | Handle handle = null; | 246 | Handle handle = null; |
@@ -245,8 +252,8 @@ namespace OpenSim.Framework | |||
245 | 252 | ||
246 | HeapItem item = new MinHeap<T>.HeapItem(value, handle); | 253 | HeapItem item = new MinHeap<T>.HeapItem(value, handle); |
247 | 254 | ||
248 | Set(item, this.size); | 255 | Set(item, size); |
249 | BubbleUp(this.size++); | 256 | BubbleUp(size++); |
250 | } | 257 | } |
251 | 258 | ||
252 | public void Add(T value) | 259 | public void Add(T value) |
@@ -256,50 +263,57 @@ namespace OpenSim.Framework | |||
256 | 263 | ||
257 | public T Min() | 264 | public T Min() |
258 | { | 265 | { |
259 | if (this.size == 0) | 266 | if (size == 0) |
260 | throw new InvalidOperationException("Heap is empty"); | 267 | throw new InvalidOperationException("Heap is empty"); |
261 | 268 | ||
262 | return this.items[0].value; | 269 | return items[0].value; |
263 | } | 270 | } |
264 | 271 | ||
265 | public void Clear() | 272 | public void Clear() |
266 | { | 273 | { |
267 | for (int index = 0; index < this.size; ++index) | 274 | for (int index = 0; index < size; ++index) |
268 | this.items[index].Clear(); | 275 | items[index].Clear(); |
269 | this.size = 0; | 276 | size = 0; |
270 | ++this.version; | 277 | if(items.Length > minCapacity) |
278 | items = new HeapItem[minCapacity]; | ||
279 | ++version; | ||
271 | } | 280 | } |
272 | 281 | ||
273 | public void TrimExcess() | 282 | public void TrimExcess() |
274 | { | 283 | { |
275 | int length = (int)(this.items.Length * 0.9); | 284 | int length = (int)(items.Length * 0.9); |
276 | if (this.size < length) | 285 | if (size < length) |
277 | Array.Resize<HeapItem>(ref this.items, Math.Min(this.size, DEFAULT_CAPACITY)); | 286 | Array.Resize<HeapItem>(ref items, Math.Min(size, minCapacity)); |
278 | } | 287 | } |
279 | 288 | ||
280 | private void RemoveAt(int index) | 289 | private void RemoveAt(int index) |
281 | { | 290 | { |
282 | if (this.size == 0) | 291 | if (size == 0) |
283 | throw new InvalidOperationException("Heap is empty"); | 292 | throw new InvalidOperationException("Heap is empty"); |
284 | if (index >= this.size) | 293 | if (index >= size) |
285 | throw new ArgumentOutOfRangeException("index"); | 294 | throw new ArgumentOutOfRangeException("index"); |
286 | 295 | ||
287 | this.items[index].Clear(); | 296 | items[index].Clear(); |
288 | if (--this.size > 0 && index != this.size) | 297 | --size; |
289 | { | 298 | if (size > 0) |
290 | Set(this.items[this.size], index); | 299 | { if(index != size) |
291 | this.items[this.size].ClearRef(); | 300 | { |
292 | if (!BubbleUp(index)) | 301 | Set(items[size], index); |
293 | BubbleDown(index); | 302 | items[size].ClearRef(); |
303 | if (!BubbleUp(index)) | ||
304 | BubbleDown(index); | ||
305 | } | ||
294 | } | 306 | } |
307 | else if(items.Length > 4 * minCapacity) | ||
308 | items = new HeapItem[minCapacity]; | ||
295 | } | 309 | } |
296 | 310 | ||
297 | public T RemoveMin() | 311 | public T RemoveMin() |
298 | { | 312 | { |
299 | if (this.size == 0) | 313 | if (size == 0) |
300 | throw new InvalidOperationException("Heap is empty"); | 314 | throw new InvalidOperationException("Heap is empty"); |
301 | 315 | ||
302 | HeapItem item = this.items[0]; | 316 | HeapItem item = items[0]; |
303 | RemoveAt(0); | 317 | RemoveAt(0); |
304 | return item.value; | 318 | return item.value; |
305 | } | 319 | } |
@@ -307,7 +321,7 @@ namespace OpenSim.Framework | |||
307 | public T Remove(IHandle ihandle) | 321 | public T Remove(IHandle ihandle) |
308 | { | 322 | { |
309 | Handle handle = ValidateThisHandle(ihandle); | 323 | Handle handle = ValidateThisHandle(ihandle); |
310 | HeapItem item = this.items[handle.index]; | 324 | HeapItem item = items[handle.index]; |
311 | RemoveAt(handle.index); | 325 | RemoveAt(handle.index); |
312 | return item.value; | 326 | return item.value; |
313 | } | 327 | } |
@@ -317,9 +331,9 @@ namespace OpenSim.Framework | |||
317 | EqualityComparer<T> comparer = EqualityComparer<T>.Default; | 331 | EqualityComparer<T> comparer = EqualityComparer<T>.Default; |
318 | int index; | 332 | int index; |
319 | 333 | ||
320 | for (index = 0; index < this.size; ++index) | 334 | for (index = 0; index < size; ++index) |
321 | { | 335 | { |
322 | if (comparer.Equals(this.items[index].value, value)) | 336 | if (comparer.Equals(items[index].value, value)) |
323 | return index; | 337 | return index; |
324 | } | 338 | } |
325 | return -1; | 339 | return -1; |
@@ -356,8 +370,8 @@ namespace OpenSim.Framework | |||
356 | if ((length - index) < this.size) | 370 | if ((length - index) < this.size) |
357 | throw new ArgumentException("Not enough space available in array starting at index"); | 371 | throw new ArgumentException("Not enough space available in array starting at index"); |
358 | 372 | ||
359 | for (int i = 0; i < this.size; ++i) | 373 | for (int i = 0; i < size; ++i) |
360 | array[index + i] = this.items[i].value; | 374 | array[index + i] = items[i].value; |
361 | } | 375 | } |
362 | 376 | ||
363 | public void CopyTo(Array array, int index) | 377 | public void CopyTo(Array array, int index) |
@@ -372,13 +386,13 @@ namespace OpenSim.Framework | |||
372 | int length = array.Length; | 386 | int length = array.Length; |
373 | if ((index < 0) || (index > length)) | 387 | if ((index < 0) || (index > length)) |
374 | throw new ArgumentOutOfRangeException("index"); | 388 | throw new ArgumentOutOfRangeException("index"); |
375 | if ((length - index) < this.size) | 389 | if ((length - index) < size) |
376 | throw new ArgumentException("Not enough space available in array starting at index"); | 390 | throw new ArgumentException("Not enough space available in array starting at index"); |
377 | 391 | ||
378 | try | 392 | try |
379 | { | 393 | { |
380 | for (int i = 0; i < this.size; ++i) | 394 | for (int i = 0; i < size; ++i) |
381 | array.SetValue(this.items[i].value, index + i); | 395 | array.SetValue(items[i].value, index + i); |
382 | } | 396 | } |
383 | catch (ArrayTypeMismatchException) | 397 | catch (ArrayTypeMismatchException) |
384 | { | 398 | { |
@@ -388,13 +402,13 @@ namespace OpenSim.Framework | |||
388 | 402 | ||
389 | public IEnumerator<T> GetEnumerator() | 403 | public IEnumerator<T> GetEnumerator() |
390 | { | 404 | { |
391 | int version = this.version; | 405 | int cversion = version; |
392 | 406 | ||
393 | for (int index = 0; index < this.size; ++index) | 407 | for (int index = 0; index < size; ++index) |
394 | { | 408 | { |
395 | if (version != this.version) | 409 | if (cversion != version) |
396 | throw new InvalidOperationException("Heap was modified while enumerating"); | 410 | throw new InvalidOperationException("Heap was modified while enumerating"); |
397 | yield return this.items[index].value; | 411 | yield return items[index].value; |
398 | } | 412 | } |
399 | } | 413 | } |
400 | 414 | ||
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index e513abd..7119964 100644 --- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs | |||
@@ -48,28 +48,25 @@ namespace OpenSim.Framework.Monitoring | |||
48 | Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); | 48 | Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); |
49 | 49 | ||
50 | sb.AppendFormat( | 50 | sb.AppendFormat( |
51 | "Last heap allocation rate : {0} MB/s\n", | 51 | "Heap allocation rate (last/avg): {0}/{1}MB/s\n", |
52 | Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); | 52 | Math.Round((MemoryWatchdog.LastHeapAllocationRate * 1000) / 1048576.0, 3), |
53 | Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1048576.0, 3)); | ||
53 | 54 | ||
54 | sb.AppendFormat( | ||
55 | "Average heap allocation rate: {0} MB/s\n", | ||
56 | Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); | ||
57 | |||
58 | Process myprocess = Process.GetCurrentProcess(); | ||
59 | // if (!myprocess.HasExited) | ||
60 | try | 55 | try |
61 | { | 56 | { |
62 | myprocess.Refresh(); | 57 | using (Process myprocess = Process.GetCurrentProcess()) |
63 | sb.AppendFormat( | 58 | { |
64 | "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", | 59 | sb.AppendFormat( |
65 | Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0), | 60 | "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", |
66 | Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0), | 61 | Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0), |
67 | Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0)); | 62 | Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0), |
68 | sb.AppendFormat( | 63 | Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0)); |
69 | "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", | 64 | sb.AppendFormat( |
70 | Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0), | 65 | "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", |
71 | Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0), | 66 | Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0), |
72 | Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0)); | 67 | Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0), |
68 | Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0)); | ||
69 | } | ||
73 | } | 70 | } |
74 | catch | 71 | catch |
75 | { } | 72 | { } |
diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs index ff3b041..f719099 100644 --- a/OpenSim/Framework/Monitoring/ChecksManager.cs +++ b/OpenSim/Framework/Monitoring/ChecksManager.cs | |||
@@ -88,7 +88,7 @@ namespace OpenSim.Framework.Monitoring | |||
88 | con.Output("check categories available are:"); | 88 | con.Output("check categories available are:"); |
89 | 89 | ||
90 | foreach (string category in RegisteredChecks.Keys) | 90 | foreach (string category in RegisteredChecks.Keys) |
91 | con.OutputFormat(" {0}", category); | 91 | con.Output(" {0}", category); |
92 | } | 92 | } |
93 | // else | 93 | // else |
94 | // { | 94 | // { |
diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index 7264c25..6c388b3 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Framework.Monitoring | |||
79 | /// </remarks> | 79 | /// </remarks> |
80 | private bool m_warnOverMaxQueue = true; | 80 | private bool m_warnOverMaxQueue = true; |
81 | 81 | ||
82 | private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000); | 82 | private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(5000); |
83 | 83 | ||
84 | private CancellationTokenSource m_cancelSource; | 84 | private CancellationTokenSource m_cancelSource; |
85 | 85 | ||
@@ -194,7 +194,7 @@ namespace OpenSim.Framework.Monitoring | |||
194 | { | 194 | { |
195 | if(!IsRunning) | 195 | if(!IsRunning) |
196 | return false; | 196 | return false; |
197 | 197 | ||
198 | if(!m_threadRunnig) | 198 | if(!m_threadRunnig) |
199 | { | 199 | { |
200 | WorkManager.RunInThreadPool(ProcessRequests, null, Name, false); | 200 | WorkManager.RunInThreadPool(ProcessRequests, null, Name, false); |
@@ -238,7 +238,7 @@ namespace OpenSim.Framework.Monitoring | |||
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | catch (ObjectDisposedException) | 241 | catch(ObjectDisposedException) |
242 | { | 242 | { |
243 | m_log.DebugFormat("[JobEngine] {0} stopping ignoring {1} jobs in queue", | 243 | m_log.DebugFormat("[JobEngine] {0} stopping ignoring {1} jobs in queue", |
244 | Name,m_jobQueue.Count); | 244 | Name,m_jobQueue.Count); |
diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs index c474622..f2e47f8 100644 --- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs | |||
@@ -110,20 +110,17 @@ namespace OpenSim.Framework.Monitoring | |||
110 | long memoryNow = GC.GetTotalMemory(false); | 110 | long memoryNow = GC.GetTotalMemory(false); |
111 | long memoryDiff = memoryNow - m_lastUpdateMemory; | 111 | long memoryDiff = memoryNow - m_lastUpdateMemory; |
112 | 112 | ||
113 | if (memoryDiff >= 0) | 113 | if (m_samples.Count >= m_maxSamples) |
114 | { | ||
115 | if (m_samples.Count >= m_maxSamples) | ||
116 | m_samples.Dequeue(); | 114 | m_samples.Dequeue(); |
117 | 115 | ||
118 | double elapsed = Util.EnvironmentTickCountSubtract(now, m_lastUpdateTick); | 116 | double elapsed = Util.EnvironmentTickCountSubtract(now, m_lastUpdateTick); |
119 | 117 | ||
120 | // This should never happen since it's not useful for updates to occur with no time elapsed, but | 118 | // This should never happen since it's not useful for updates to occur with no time elapsed, but |
121 | // protect ourselves from a divide-by-zero just in case. | 119 | // protect ourselves from a divide-by-zero just in case. |
122 | if (elapsed == 0) | 120 | if (elapsed == 0) |
123 | return; | 121 | return; |
124 | 122 | ||
125 | m_samples.Enqueue(memoryDiff / (double)elapsed); | 123 | m_samples.Enqueue(memoryDiff / (double)elapsed); |
126 | } | ||
127 | 124 | ||
128 | UpdateLastRecord(memoryNow, now); | 125 | UpdateLastRecord(memoryNow, now); |
129 | } | 126 | } |
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index 88a0297..c41c4b9 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -435,21 +435,19 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
435 | // Get the amount of physical memory, allocated with the instance of this program, in kilobytes; | 435 | // Get the amount of physical memory, allocated with the instance of this program, in kilobytes; |
436 | // the working set is the set of memory pages currently visible to this program in physical RAM | 436 | // the working set is the set of memory pages currently visible to this program in physical RAM |
437 | // memory and includes both shared (e.g. system libraries) and private data | 437 | // memory and includes both shared (e.g. system libraries) and private data |
438 | double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0; | ||
439 | |||
440 | // Get the number of threads from the system that are currently | ||
441 | // running | ||
442 | int numberThreadsRunning = 0; | 438 | int numberThreadsRunning = 0; |
443 | foreach (ProcessThread currentThread in | 439 | double memUsage = 0; |
444 | Process.GetCurrentProcess().Threads) | 440 | using(Process p = Process.GetCurrentProcess()) |
445 | { | 441 | { |
446 | // A known issue with the current process .Threads property is | 442 | memUsage = p.WorkingSet64 / 1024.0; |
447 | // that it can return null threads, thus don't count those as | 443 | |
448 | // running threads and prevent the program function from failing | 444 | // Get the number of threads from the system that are currently |
449 | if (currentThread != null && | 445 | // running |
450 | currentThread.ThreadState == ThreadState.Running) | 446 | |
447 | foreach (ProcessThread currentThread in p.Threads) | ||
451 | { | 448 | { |
452 | numberThreadsRunning++; | 449 | if (currentThread != null && currentThread.ThreadState == ThreadState.Running) |
450 | numberThreadsRunning++; | ||
453 | } | 451 | } |
454 | } | 452 | } |
455 | 453 | ||
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 2276341..4b1a229 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs | |||
@@ -242,11 +242,7 @@ namespace OpenSim.Framework.Monitoring | |||
242 | public virtual OSDMap ToBriefOSDMap() | 242 | public virtual OSDMap ToBriefOSDMap() |
243 | { | 243 | { |
244 | OSDMap ret = new OSDMap(); | 244 | OSDMap ret = new OSDMap(); |
245 | |||
246 | ret.Add("Value", OSD.FromReal(Value)); | 245 | ret.Add("Value", OSD.FromReal(Value)); |
247 | |||
248 | // double lastChangeOverTime, averageChangeOverTime; | ||
249 | |||
250 | return ret; | 246 | return ret; |
251 | } | 247 | } |
252 | 248 | ||
diff --git a/OpenSim/Framework/Monitoring/StatsLogger.cs b/OpenSim/Framework/Monitoring/StatsLogger.cs index b719af9..e87c188 100644 --- a/OpenSim/Framework/Monitoring/StatsLogger.cs +++ b/OpenSim/Framework/Monitoring/StatsLogger.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Framework.Monitoring | |||
79 | if (cmd[2] == "start") | 79 | if (cmd[2] == "start") |
80 | { | 80 | { |
81 | Start(); | 81 | Start(); |
82 | con.OutputFormat("Now recording all stats to file every {0}ms", m_statsLogIntervalMs); | 82 | con.Output("Now recording all stats to file every {0}ms", m_statsLogIntervalMs); |
83 | } | 83 | } |
84 | else if (cmd[2] == "stop") | 84 | else if (cmd[2] == "stop") |
85 | { | 85 | { |
@@ -106,7 +106,7 @@ namespace OpenSim.Framework.Monitoring | |||
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.Output("Stats saved to file {0}", path); |
110 | } | 110 | } |
111 | 111 | ||
112 | public static void Start() | 112 | public static void Start() |
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index a6b341f..05fb07a 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -117,14 +117,14 @@ namespace OpenSim.Framework.Monitoring | |||
117 | { | 117 | { |
118 | con.Output("Statistic categories available are:"); | 118 | con.Output("Statistic categories available are:"); |
119 | foreach (string category in RegisteredStats.Keys) | 119 | foreach (string category in RegisteredStats.Keys) |
120 | con.OutputFormat(" {0}", category); | 120 | con.Output(" {0}", category); |
121 | } | 121 | } |
122 | else | 122 | else |
123 | { | 123 | { |
124 | SortedDictionary<string, SortedDictionary<string, Stat>> category; | 124 | SortedDictionary<string, SortedDictionary<string, Stat>> category; |
125 | if (!RegisteredStats.TryGetValue(categoryName, out category)) | 125 | if (!RegisteredStats.TryGetValue(categoryName, out category)) |
126 | { | 126 | { |
127 | con.OutputFormat("No such category as {0}", categoryName); | 127 | con.Output("No such category as {0}", categoryName); |
128 | } | 128 | } |
129 | else | 129 | else |
130 | { | 130 | { |
@@ -150,14 +150,14 @@ namespace OpenSim.Framework.Monitoring | |||
150 | } | 150 | } |
151 | else | 151 | else |
152 | { | 152 | { |
153 | con.OutputFormat( | 153 | con.Output( |
154 | "No such stat {0} in {1}.{2}", statName, categoryName, containerName); | 154 | "No such stat {0} in {1}.{2}", statName, categoryName, containerName); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | con.OutputFormat("No such container {0} in category {1}", containerName, categoryName); | 160 | con.Output("No such container {0} in category {1}", containerName, categoryName); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | } | 163 | } |
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 9cac451..ad21d93 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -197,6 +197,9 @@ namespace OpenSim.Framework.Monitoring | |||
197 | foreach(ThreadWatchdogInfo twi in m_threads.Values) | 197 | foreach(ThreadWatchdogInfo twi in m_threads.Values) |
198 | { | 198 | { |
199 | Thread t = twi.Thread; | 199 | Thread t = twi.Thread; |
200 | // m_log.DebugFormat( | ||
201 | // "[WATCHDOG]: Stop: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); | ||
202 | |||
200 | if(t.IsAlive) | 203 | if(t.IsAlive) |
201 | t.Abort(); | 204 | t.Abort(); |
202 | } | 205 | } |
diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs index 5d9b185..ce639b9 100644 --- a/OpenSim/Framework/Monitoring/WorkManager.cs +++ b/OpenSim/Framework/Monitoring/WorkManager.cs | |||
@@ -88,6 +88,11 @@ namespace OpenSim.Framework.Monitoring | |||
88 | Watchdog.Stop(); | 88 | Watchdog.Stop(); |
89 | } | 89 | } |
90 | 90 | ||
91 | public static Thread StartThread(ThreadStart start, string name, bool alarmIfTimeout = false, bool log = true) | ||
92 | { | ||
93 | return StartThread(start, name, ThreadPriority.Normal, true, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log); | ||
94 | } | ||
95 | |||
91 | /// <summary> | 96 | /// <summary> |
92 | /// Start a new long-lived thread. | 97 | /// Start a new long-lived thread. |
93 | /// </summary> | 98 | /// </summary> |
@@ -99,9 +104,9 @@ namespace OpenSim.Framework.Monitoring | |||
99 | /// <param name="log">If true then creation of thread is logged.</param> | 104 | /// <param name="log">If true then creation of thread is logged.</param> |
100 | /// <returns>The newly created Thread object</returns> | 105 | /// <returns>The newly created Thread object</returns> |
101 | public static Thread StartThread( | 106 | public static Thread StartThread( |
102 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout, bool log = true) | 107 | ThreadStart start, string name, ThreadPriority priority, bool alarmIfTimeout, bool log = true) |
103 | { | 108 | { |
104 | return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log); | 109 | return StartThread(start, name, priority, true, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log); |
105 | } | 110 | } |
106 | 111 | ||
107 | /// <summary> | 112 | /// <summary> |
@@ -162,15 +167,22 @@ namespace OpenSim.Framework.Monitoring | |||
162 | { | 167 | { |
163 | Culture.SetCurrentCulture(); | 168 | Culture.SetCurrentCulture(); |
164 | callback(obj); | 169 | callback(obj); |
165 | Watchdog.RemoveThread(log:false); | ||
166 | } | 170 | } |
167 | catch (Exception e) | 171 | catch (Exception e) |
168 | { | 172 | { |
169 | m_log.Error(string.Format("[WATCHDOG]: Exception in thread {0}.", name), e); | 173 | m_log.Error(string.Format("[WATCHDOG]: Exception in thread {0}.", name), e); |
170 | } | 174 | } |
175 | finally | ||
176 | { | ||
177 | try | ||
178 | { | ||
179 | Watchdog.RemoveThread(log: false); | ||
180 | } | ||
181 | catch { } | ||
182 | } | ||
171 | }); | 183 | }); |
172 | 184 | ||
173 | StartThread(ts, name, ThreadPriority.Normal, true, false, log:log); | 185 | StartThread(ts, name, false, log:log); |
174 | } | 186 | } |
175 | 187 | ||
176 | /// <summary> | 188 | /// <summary> |
@@ -187,54 +199,6 @@ namespace OpenSim.Framework.Monitoring | |||
187 | Util.FireAndForget(callback, obj, name, timeout); | 199 | Util.FireAndForget(callback, obj, name, timeout); |
188 | } | 200 | } |
189 | 201 | ||
190 | /// <summary> | ||
191 | /// Run a job. | ||
192 | /// </summary> | ||
193 | /// <remarks> | ||
194 | /// This differs from direct scheduling (e.g. Util.FireAndForget) in that a job can be run in the job | ||
195 | /// engine if it is running, where all jobs are currently performed in sequence on a single thread. This is | ||
196 | /// to prevent observed overload and server freeze problems when there are hundreds of connections which all attempt to | ||
197 | /// perform work at once (e.g. in conference situations). With lower numbers of connections, the small | ||
198 | /// delay in performing jobs in sequence rather than concurrently has not been notiecable in testing, though a future more | ||
199 | /// sophisticated implementation could perform jobs concurrently when the server is under low load. | ||
200 | /// | ||
201 | /// However, be advised that some callers of this function rely on all jobs being performed in sequence if any | ||
202 | /// jobs are performed in sequence (i.e. if jobengine is active or not). Therefore, expanding the jobengine | ||
203 | /// beyond a single thread will require considerable thought. | ||
204 | /// | ||
205 | /// Also, any jobs submitted must be guaranteed to complete within a reasonable timeframe (e.g. they cannot | ||
206 | /// incorporate a network delay with a long timeout). At the moment, work that could suffer such issues | ||
207 | /// should still be run directly with RunInThread(), Util.FireAndForget(), etc. This is another area where | ||
208 | /// the job engine could be improved and so CPU utilization improved by better management of concurrency within | ||
209 | /// OpenSimulator. | ||
210 | /// </remarks> | ||
211 | /// <param name="jobType">General classification for the job (e.g. "RezAttachments").</param> | ||
212 | /// <param name="callback">Callback for job.</param> | ||
213 | /// <param name="obj">Object to pass to callback when run</param> | ||
214 | /// <param name="name">Specific name of job (e.g. "RezAttachments for Joe Bloggs"</param> | ||
215 | /// <param name="canRunInThisThread">If set to true then the job may be run in ths calling thread.</param> | ||
216 | /// <param name="mustNotTimeout">If the true then the job must never timeout.</param> | ||
217 | /// <param name="log">If set to true then extra logging is performed.</param> | ||
218 | public static void RunJob( | ||
219 | string jobType, WaitCallback callback, object obj, string name, | ||
220 | bool canRunInThisThread = false, bool mustNotTimeout = false, | ||
221 | bool log = false) | ||
222 | { | ||
223 | if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest) | ||
224 | { | ||
225 | Culture.SetCurrentCulture(); | ||
226 | callback(obj); | ||
227 | return; | ||
228 | } | ||
229 | |||
230 | if (JobEngine.IsRunning) | ||
231 | JobEngine.QueueJob(name, () => callback(obj)); | ||
232 | else if (canRunInThisThread) | ||
233 | callback(obj); | ||
234 | else | ||
235 | Util.FireAndForget(callback, obj, name, !mustNotTimeout); | ||
236 | } | ||
237 | |||
238 | private static void HandleControlCommand(string module, string[] args) | 202 | private static void HandleControlCommand(string module, string[] args) |
239 | { | 203 | { |
240 | // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) | 204 | // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) |
@@ -251,23 +215,23 @@ namespace OpenSim.Framework.Monitoring | |||
251 | if (subCommand == "stop") | 215 | if (subCommand == "stop") |
252 | { | 216 | { |
253 | JobEngine.Stop(); | 217 | JobEngine.Stop(); |
254 | MainConsole.Instance.OutputFormat("Stopped job engine."); | 218 | MainConsole.Instance.Output("Stopped job engine."); |
255 | } | 219 | } |
256 | else if (subCommand == "start") | 220 | else if (subCommand == "start") |
257 | { | 221 | { |
258 | JobEngine.Start(); | 222 | JobEngine.Start(); |
259 | MainConsole.Instance.OutputFormat("Started job engine."); | 223 | MainConsole.Instance.Output("Started job engine."); |
260 | } | 224 | } |
261 | else if (subCommand == "status") | 225 | else if (subCommand == "status") |
262 | { | 226 | { |
263 | MainConsole.Instance.OutputFormat("Job engine running: {0}", JobEngine.IsRunning); | 227 | MainConsole.Instance.Output("Job engine running: {0}", JobEngine.IsRunning); |
264 | 228 | ||
265 | JobEngine.Job job = JobEngine.CurrentJob; | 229 | JobEngine.Job job = JobEngine.CurrentJob; |
266 | MainConsole.Instance.OutputFormat("Current job {0}", job != null ? job.Name : "none"); | 230 | MainConsole.Instance.Output("Current job {0}", job != null ? job.Name : "none"); |
267 | 231 | ||
268 | MainConsole.Instance.OutputFormat( | 232 | MainConsole.Instance.Output( |
269 | "Jobs waiting: {0}", JobEngine.IsRunning ? JobEngine.JobsWaiting.ToString() : "n/a"); | 233 | "Jobs waiting: {0}", JobEngine.IsRunning ? JobEngine.JobsWaiting.ToString() : "n/a"); |
270 | MainConsole.Instance.OutputFormat("Log Level: {0}", JobEngine.LogLevel); | 234 | MainConsole.Instance.Output("Log Level: {0}", JobEngine.LogLevel); |
271 | } | 235 | } |
272 | else if (subCommand == "log") | 236 | else if (subCommand == "log") |
273 | { | 237 | { |
@@ -282,12 +246,12 @@ namespace OpenSim.Framework.Monitoring | |||
282 | // if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel)) | 246 | // if (ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out logLevel)) |
283 | // { | 247 | // { |
284 | JobEngine.LogLevel = logLevel; | 248 | JobEngine.LogLevel = logLevel; |
285 | MainConsole.Instance.OutputFormat("Set debug log level to {0}", JobEngine.LogLevel); | 249 | MainConsole.Instance.Output("Set debug log level to {0}", JobEngine.LogLevel); |
286 | // } | 250 | // } |
287 | } | 251 | } |
288 | else | 252 | else |
289 | { | 253 | { |
290 | MainConsole.Instance.OutputFormat("Unrecognized job engine subcommand {0}", subCommand); | 254 | MainConsole.Instance.Output("Unrecognized job engine subcommand {0}", subCommand); |
291 | } | 255 | } |
292 | } | 256 | } |
293 | } | 257 | } |
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index dfe9695..d79eb0d 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs | |||
@@ -37,6 +37,8 @@ namespace OpenSim.Framework | |||
37 | public bool isSandbox; | 37 | public bool isSandbox; |
38 | public bool HttpUsesSSL = false; | 38 | public bool HttpUsesSSL = false; |
39 | public string HttpSSLCN = ""; | 39 | public string HttpSSLCN = ""; |
40 | public string HttpSSLCertPath = ""; | ||
41 | public string HttpSSLCNCertPass = ""; | ||
40 | public uint httpSSLPort = 9001; | 42 | public uint httpSSLPort = 9001; |
41 | 43 | ||
42 | // "Out of band" managemnt https | 44 | // "Out of band" managemnt https |
@@ -62,6 +64,8 @@ namespace OpenSim.Framework | |||
62 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); | 64 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); |
63 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); | 65 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); |
64 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); | 66 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); |
67 | HttpSSLCertPath = config.Configs["Network"].GetString("http_listener_cert_path", HttpSSLCertPath); | ||
68 | HttpSSLCNCertPass = config.Configs["Network"].GetString("http_listener_cert_pass", HttpSSLCNCertPass); | ||
65 | 69 | ||
66 | // "Out of band management https" | 70 | // "Out of band management https" |
67 | ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); | 71 | ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); |
diff --git a/OpenSim/Framework/PhysicsInertia.cs b/OpenSim/Framework/PhysicsInertia.cs index fa83de8..5aae6d5 100644 --- a/OpenSim/Framework/PhysicsInertia.cs +++ b/OpenSim/Framework/PhysicsInertia.cs | |||
@@ -193,8 +193,6 @@ namespace OpenSim.Framework | |||
193 | using(MemoryStream ms = new MemoryStream(enc.GetBytes(text))) | 193 | using(MemoryStream ms = new MemoryStream(enc.GetBytes(text))) |
194 | using(XmlTextReader xreader = new XmlTextReader(ms)) | 194 | using(XmlTextReader xreader = new XmlTextReader(ms)) |
195 | { | 195 | { |
196 | xreader.ProhibitDtd = true; | ||
197 | |||
198 | v = new PhysicsInertiaData(); | 196 | v = new PhysicsInertiaData(); |
199 | v.FromXml2(xreader, out error); | 197 | v.FromXml2(xreader, out error); |
200 | } | 198 | } |
diff --git a/OpenSim/Framework/PluginManager.cs b/OpenSim/Framework/PluginManager.cs index 0c94fcb..794dcc9 100644 --- a/OpenSim/Framework/PluginManager.cs +++ b/OpenSim/Framework/PluginManager.cs | |||
@@ -129,7 +129,7 @@ namespace OpenSim.Framework | |||
129 | } | 129 | } |
130 | 130 | ||
131 | Addin addin = addins[ndx]; | 131 | Addin addin = addins[ndx]; |
132 | MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id); | 132 | MainConsole.Instance.Output("Uninstalling plugin {0}", addin.Id); |
133 | AddinManager.Registry.DisableAddin(addin.Id); | 133 | AddinManager.Registry.DisableAddin(addin.Id); |
134 | addin.Enabled = false; | 134 | addin.Enabled = false; |
135 | IProgressStatus ps = new ConsoleProgressStatus(false); | 135 | IProgressStatus ps = new ConsoleProgressStatus(false); |
@@ -487,7 +487,7 @@ namespace OpenSim.Framework | |||
487 | } | 487 | } |
488 | else | 488 | else |
489 | { | 489 | { |
490 | MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name); | 490 | MainConsole.Instance.Output("Not Enabled in this domain {0}", addin.Name); |
491 | } | 491 | } |
492 | return; | 492 | return; |
493 | } | 493 | } |
@@ -503,7 +503,7 @@ namespace OpenSim.Framework | |||
503 | 503 | ||
504 | foreach (Addin addin in addins) | 504 | foreach (Addin addin in addins) |
505 | { | 505 | { |
506 | MainConsole.Instance.OutputFormat("Addin {0}", addin.Name); | 506 | MainConsole.Instance.Output("Addin {0}", addin.Name); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 6e7a038..a49f53c 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -133,17 +133,26 @@ namespace OpenSim.Framework | |||
133 | [XmlIgnore] private float _lightCutoff; | 133 | [XmlIgnore] private float _lightCutoff; |
134 | [XmlIgnore] private float _lightFalloff; | 134 | [XmlIgnore] private float _lightFalloff; |
135 | [XmlIgnore] private float _lightIntensity = 1.0f; | 135 | [XmlIgnore] private float _lightIntensity = 1.0f; |
136 | [XmlIgnore] private bool _flexiEntry; | 136 | |
137 | [XmlIgnore] private bool _lightEntry; | ||
138 | [XmlIgnore] private bool _sculptEntry; | ||
139 | 137 | ||
140 | // Light Projection Filter | 138 | // Light Projection Filter |
141 | [XmlIgnore] private bool _projectionEntry; | ||
142 | [XmlIgnore] private UUID _projectionTextureID; | 139 | [XmlIgnore] private UUID _projectionTextureID; |
143 | [XmlIgnore] private float _projectionFOV; | 140 | [XmlIgnore] private float _projectionFOV; |
144 | [XmlIgnore] private float _projectionFocus; | 141 | [XmlIgnore] private float _projectionFocus; |
145 | [XmlIgnore] private float _projectionAmb; | 142 | [XmlIgnore] private float _projectionAmb; |
146 | 143 | ||
144 | [XmlIgnore] private uint _meshFlags; | ||
145 | |||
146 | [XmlIgnore] private bool _flexiEntry; | ||
147 | [XmlIgnore] private bool _lightEntry; | ||
148 | [XmlIgnore] private bool _sculptEntry; | ||
149 | [XmlIgnore] private bool _projectionEntry; | ||
150 | [XmlIgnore] private bool _meshFlagsEntry; | ||
151 | |||
152 | public bool MeshFlagEntry | ||
153 | { | ||
154 | get { return _meshFlagsEntry;} | ||
155 | } | ||
147 | public byte ProfileCurve | 156 | public byte ProfileCurve |
148 | { | 157 | { |
149 | get { return (byte)((byte)HollowShape | (byte)ProfileShape); } | 158 | get { return (byte)((byte)HollowShape | (byte)ProfileShape); } |
@@ -1026,117 +1035,131 @@ namespace OpenSim.Framework | |||
1026 | { | 1035 | { |
1027 | // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); | 1036 | // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); |
1028 | 1037 | ||
1029 | ushort FlexiEP = 0x10; | 1038 | const byte FlexiEP = 0x10; |
1030 | ushort LightEP = 0x20; | 1039 | const byte LightEP = 0x20; |
1031 | ushort SculptEP = 0x30; | 1040 | const byte SculptEP = 0x30; |
1032 | ushort ProjectionEP = 0x40; | 1041 | const byte ProjectionEP = 0x40; |
1042 | //const byte MeshEP = 0x60; | ||
1043 | const byte MeshFlagsEP = 0x70; | ||
1033 | 1044 | ||
1034 | int i = 0; | 1045 | int TotalBytesLength = 1; // ExtraParamsNum |
1035 | uint TotalBytesLength = 1; // ExtraParamsNum | ||
1036 | 1046 | ||
1037 | uint ExtraParamsNum = 0; | 1047 | uint ExtraParamsNum = 0; |
1038 | if (_flexiEntry) | 1048 | if (_flexiEntry) |
1039 | { | 1049 | { |
1040 | ExtraParamsNum++; | 1050 | ExtraParamsNum++; |
1041 | TotalBytesLength += 16;// data | 1051 | TotalBytesLength += 16 + 2 + 4;// data |
1042 | TotalBytesLength += 2 + 4; // type | ||
1043 | } | 1052 | } |
1044 | 1053 | ||
1045 | if (_lightEntry) | 1054 | if (_lightEntry) |
1046 | { | 1055 | { |
1047 | ExtraParamsNum++; | 1056 | ExtraParamsNum++; |
1048 | TotalBytesLength += 16;// data | 1057 | TotalBytesLength += 16 + 2 + 4; // data |
1049 | TotalBytesLength += 2 + 4; // type | ||
1050 | } | 1058 | } |
1051 | 1059 | ||
1052 | if (_sculptEntry) | 1060 | if (_sculptEntry) |
1053 | { | 1061 | { |
1054 | ExtraParamsNum++; | 1062 | ExtraParamsNum++; |
1055 | TotalBytesLength += 17;// data | 1063 | TotalBytesLength += 17 + 2 + 4;// data |
1056 | TotalBytesLength += 2 + 4; // type | ||
1057 | } | 1064 | } |
1058 | 1065 | ||
1059 | if (_projectionEntry) | 1066 | if (_projectionEntry) |
1060 | { | 1067 | { |
1061 | ExtraParamsNum++; | 1068 | ExtraParamsNum++; |
1062 | TotalBytesLength += 28;// data | 1069 | TotalBytesLength += 28 + 2 + 4; // data |
1063 | TotalBytesLength += 2 + 4;// type | 1070 | } |
1071 | |||
1072 | if (_meshFlagsEntry) | ||
1073 | { | ||
1074 | ExtraParamsNum++; | ||
1075 | TotalBytesLength += 4 + 2 + 4; // data | ||
1064 | } | 1076 | } |
1077 | byte[] returnBytes = new byte[TotalBytesLength]; | ||
1065 | 1078 | ||
1066 | byte[] returnbytes = new byte[TotalBytesLength]; | 1079 | returnBytes[0] = (byte)ExtraParamsNum; |
1067 | 1080 | ||
1068 | // uint paramlength = ExtraParamsNum; | 1081 | if(ExtraParamsNum == 0) |
1082 | return returnBytes; | ||
1069 | 1083 | ||
1070 | // Stick in the number of parameters | 1084 | int i = 1; |
1071 | returnbytes[i++] = (byte)ExtraParamsNum; | ||
1072 | 1085 | ||
1073 | if (_flexiEntry) | 1086 | if (_flexiEntry) |
1074 | { | 1087 | { |
1075 | byte[] FlexiData = GetFlexiBytes(); | 1088 | returnBytes[i] = FlexiEP; // 2 bytes id code |
1089 | i += 2; | ||
1090 | returnBytes[i] = 16; // 4 bytes size | ||
1091 | i += 4; | ||
1076 | 1092 | ||
1077 | returnbytes[i++] = (byte)(FlexiEP % 256); | 1093 | // Softness is packed in the upper bits of tension and drag |
1078 | returnbytes[i++] = (byte)((FlexiEP >> 8) % 256); | 1094 | returnBytes[i] = (byte)((_flexiSoftness & 2) << 6); |
1095 | returnBytes[i + 1] = (byte)((_flexiSoftness & 1) << 7); | ||
1079 | 1096 | ||
1080 | returnbytes[i++] = (byte)(FlexiData.Length % 256); | 1097 | returnBytes[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F); |
1081 | returnbytes[i++] = (byte)((FlexiData.Length >> 8) % 256); | 1098 | returnBytes[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F); |
1082 | returnbytes[i++] = (byte)((FlexiData.Length >> 16) % 256); | 1099 | returnBytes[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f); |
1083 | returnbytes[i++] = (byte)((FlexiData.Length >> 24) % 256); | 1100 | returnBytes[i++] = (byte)(_flexiWind * 10.01f); |
1084 | Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length); | 1101 | Utils.FloatToBytes(_flexiForceX, returnBytes, i); |
1085 | i += FlexiData.Length; | 1102 | Utils.FloatToBytes(_flexiForceY, returnBytes, i + 4); |
1103 | Utils.FloatToBytes(_flexiForceZ, returnBytes, i + 8); | ||
1104 | i += 12; | ||
1086 | } | 1105 | } |
1087 | 1106 | ||
1088 | if (_lightEntry) | 1107 | if (_lightEntry) |
1089 | { | 1108 | { |
1090 | byte[] LightData = GetLightBytes(); | 1109 | returnBytes[i] = LightEP; |
1091 | 1110 | i += 2; | |
1092 | returnbytes[i++] = (byte)(LightEP % 256); | 1111 | returnBytes[i] = 16; |
1093 | returnbytes[i++] = (byte)((LightEP >> 8) % 256); | 1112 | i += 4; |
1094 | 1113 | ||
1095 | returnbytes[i++] = (byte)(LightData.Length % 256); | 1114 | // Alpha channel in color is intensity |
1096 | returnbytes[i++] = (byte)((LightData.Length >> 8) % 256); | 1115 | Color4 tmpColor = new Color4(_lightColorR, _lightColorG, _lightColorB, _lightIntensity); |
1097 | returnbytes[i++] = (byte)((LightData.Length >> 16) % 256); | 1116 | tmpColor.GetBytes().CopyTo(returnBytes, i); |
1098 | returnbytes[i++] = (byte)((LightData.Length >> 24) % 256); | 1117 | Utils.FloatToBytes(_lightRadius, returnBytes, i + 4); |
1099 | Array.Copy(LightData, 0, returnbytes, i, LightData.Length); | 1118 | Utils.FloatToBytes(_lightCutoff, returnBytes, i + 8); |
1100 | i += LightData.Length; | 1119 | Utils.FloatToBytes(_lightFalloff, returnBytes, i + 12); |
1120 | i += 16; | ||
1101 | } | 1121 | } |
1102 | 1122 | ||
1103 | if (_sculptEntry) | 1123 | if (_sculptEntry) |
1104 | { | 1124 | { |
1105 | byte[] SculptData = GetSculptBytes(); | 1125 | //if(_sculptType == 5) |
1106 | 1126 | // returnBytes[i] = MeshEP; | |
1107 | returnbytes[i++] = (byte)(SculptEP % 256); | 1127 | //else |
1108 | returnbytes[i++] = (byte)((SculptEP >> 8) % 256); | 1128 | returnBytes[i] = SculptEP; |
1129 | i += 2; | ||
1130 | returnBytes[i] = 17; | ||
1131 | i += 4; | ||
1109 | 1132 | ||
1110 | returnbytes[i++] = (byte)(SculptData.Length % 256); | 1133 | _sculptTexture.GetBytes().CopyTo(returnBytes, i); |
1111 | returnbytes[i++] = (byte)((SculptData.Length >> 8) % 256); | 1134 | i += 16; |
1112 | returnbytes[i++] = (byte)((SculptData.Length >> 16) % 256); | 1135 | returnBytes[i++] = _sculptType; |
1113 | returnbytes[i++] = (byte)((SculptData.Length >> 24) % 256); | ||
1114 | Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length); | ||
1115 | i += SculptData.Length; | ||
1116 | } | 1136 | } |
1117 | 1137 | ||
1118 | if (_projectionEntry) | 1138 | if (_projectionEntry) |
1119 | { | 1139 | { |
1120 | byte[] ProjectionData = GetProjectionBytes(); | 1140 | returnBytes[i] = ProjectionEP; |
1141 | i += 2; | ||
1142 | returnBytes[i] = 28; | ||
1143 | i += 4; | ||
1121 | 1144 | ||
1122 | returnbytes[i++] = (byte)(ProjectionEP % 256); | 1145 | _projectionTextureID.GetBytes().CopyTo(returnBytes, i); |
1123 | returnbytes[i++] = (byte)((ProjectionEP >> 8) % 256); | 1146 | Utils.FloatToBytes(_projectionFOV, returnBytes, i + 16); |
1124 | returnbytes[i++] = (byte)((ProjectionData.Length) % 256); | 1147 | Utils.FloatToBytes(_projectionFocus, returnBytes, i + 20); |
1125 | returnbytes[i++] = (byte)((ProjectionData.Length >> 16) % 256); | 1148 | Utils.FloatToBytes(_projectionAmb, returnBytes, i + 24); |
1126 | returnbytes[i++] = (byte)((ProjectionData.Length >> 20) % 256); | 1149 | i += 28; |
1127 | returnbytes[i++] = (byte)((ProjectionData.Length >> 24) % 256); | ||
1128 | Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length); | ||
1129 | i += ProjectionData.Length; | ||
1130 | } | 1150 | } |
1131 | 1151 | ||
1132 | if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry) | 1152 | if (_meshFlagsEntry) |
1133 | { | 1153 | { |
1134 | byte[] returnbyte = new byte[1]; | 1154 | returnBytes[i] = MeshFlagsEP; |
1135 | returnbyte[0] = 0; | 1155 | i += 2; |
1136 | return returnbyte; | 1156 | returnBytes[i] = 4; |
1157 | i += 4; | ||
1158 | Utils.UIntToBytes(_meshFlags, returnBytes, i); | ||
1137 | } | 1159 | } |
1138 | 1160 | ||
1139 | return returnbytes; | 1161 | return returnBytes; |
1162 | |||
1140 | } | 1163 | } |
1141 | 1164 | ||
1142 | public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) | 1165 | public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) |
@@ -1145,6 +1168,8 @@ namespace OpenSim.Framework | |||
1145 | const ushort LightEP = 0x20; | 1168 | const ushort LightEP = 0x20; |
1146 | const ushort SculptEP = 0x30; | 1169 | const ushort SculptEP = 0x30; |
1147 | const ushort ProjectionEP = 0x40; | 1170 | const ushort ProjectionEP = 0x40; |
1171 | const ushort MeshEP = 0x60; | ||
1172 | const ushort MeshFlagsEP = 0x70; | ||
1148 | 1173 | ||
1149 | switch (type) | 1174 | switch (type) |
1150 | { | 1175 | { |
@@ -1166,6 +1191,7 @@ namespace OpenSim.Framework | |||
1166 | ReadLightData(data, 0); | 1191 | ReadLightData(data, 0); |
1167 | break; | 1192 | break; |
1168 | 1193 | ||
1194 | case MeshEP: | ||
1169 | case SculptEP: | 1195 | case SculptEP: |
1170 | if (!inUse) | 1196 | if (!inUse) |
1171 | { | 1197 | { |
@@ -1182,115 +1208,90 @@ namespace OpenSim.Framework | |||
1182 | } | 1208 | } |
1183 | ReadProjectionData(data, 0); | 1209 | ReadProjectionData(data, 0); |
1184 | break; | 1210 | break; |
1211 | case MeshFlagsEP: | ||
1212 | if (!inUse) | ||
1213 | { | ||
1214 | _meshFlagsEntry = false; | ||
1215 | return; | ||
1216 | } | ||
1217 | ReadMeshFlagsData(data, 0); | ||
1218 | break; | ||
1185 | } | 1219 | } |
1186 | } | 1220 | } |
1187 | 1221 | ||
1188 | public void ReadInExtraParamsBytes(byte[] data) | 1222 | public void ReadInExtraParamsBytes(byte[] data) |
1189 | { | 1223 | { |
1190 | if (data == null || data.Length == 1) | 1224 | if (data == null) |
1191 | return; | 1225 | return; |
1192 | 1226 | ||
1193 | const ushort FlexiEP = 0x10; | 1227 | _flexiEntry = false; |
1194 | const ushort LightEP = 0x20; | 1228 | _lightEntry = false; |
1195 | const ushort SculptEP = 0x30; | 1229 | _sculptEntry = false; |
1196 | const ushort ProjectionEP = 0x40; | 1230 | _projectionEntry = false; |
1231 | _meshFlagsEntry = false; | ||
1197 | 1232 | ||
1198 | bool lGotFlexi = false; | 1233 | if (data.Length == 1) |
1199 | bool lGotLight = false; | 1234 | return; |
1200 | bool lGotSculpt = false; | ||
1201 | bool lGotFilter = false; | ||
1202 | 1235 | ||
1203 | int i = 0; | 1236 | const byte FlexiEP = 0x10; |
1204 | byte extraParamCount = 0; | 1237 | const byte LightEP = 0x20; |
1205 | if (data.Length > 0) | 1238 | const byte SculptEP = 0x30; |
1206 | { | 1239 | const byte ProjectionEP = 0x40; |
1207 | extraParamCount = data[i++]; | 1240 | const byte MeshEP = 0x60; |
1208 | } | 1241 | const byte MeshFlagsEP = 0x70; |
1209 | 1242 | ||
1243 | byte extraParamCount = data[0]; | ||
1244 | int i = 1; | ||
1210 | for (int k = 0; k < extraParamCount; k++) | 1245 | for (int k = 0; k < extraParamCount; k++) |
1211 | { | 1246 | { |
1212 | ushort epType = Utils.BytesToUInt16(data, i); | 1247 | byte epType = data[i]; |
1213 | 1248 | i += 6; | |
1214 | i += 2; | ||
1215 | // uint paramLength = Helpers.BytesToUIntBig(data, i); | ||
1216 | 1249 | ||
1217 | i += 4; | ||
1218 | switch (epType) | 1250 | switch (epType) |
1219 | { | 1251 | { |
1220 | case FlexiEP: | 1252 | case FlexiEP: |
1221 | ReadFlexiData(data, i); | 1253 | ReadFlexiData(data, i); |
1222 | i += 16; | 1254 | i += 16; |
1223 | lGotFlexi = true; | ||
1224 | break; | 1255 | break; |
1225 | 1256 | ||
1226 | case LightEP: | 1257 | case LightEP: |
1227 | ReadLightData(data, i); | 1258 | ReadLightData(data, i); |
1228 | i += 16; | 1259 | i += 16; |
1229 | lGotLight = true; | ||
1230 | break; | 1260 | break; |
1231 | 1261 | ||
1262 | case MeshEP: | ||
1232 | case SculptEP: | 1263 | case SculptEP: |
1233 | ReadSculptData(data, i); | 1264 | ReadSculptData(data, i); |
1234 | i += 17; | 1265 | i += 17; |
1235 | lGotSculpt = true; | ||
1236 | break; | 1266 | break; |
1267 | |||
1237 | case ProjectionEP: | 1268 | case ProjectionEP: |
1238 | ReadProjectionData(data, i); | 1269 | ReadProjectionData(data, i); |
1239 | i += 28; | 1270 | i += 28; |
1240 | lGotFilter = true; | 1271 | break; |
1272 | |||
1273 | case MeshFlagsEP: | ||
1274 | ReadMeshFlagsData(data, i); | ||
1275 | i += 4; | ||
1241 | break; | 1276 | break; |
1242 | } | 1277 | } |
1243 | } | 1278 | } |
1244 | |||
1245 | if (!lGotFlexi) | ||
1246 | _flexiEntry = false; | ||
1247 | if (!lGotLight) | ||
1248 | _lightEntry = false; | ||
1249 | if (!lGotSculpt) | ||
1250 | _sculptEntry = false; | ||
1251 | if (!lGotFilter) | ||
1252 | _projectionEntry = false; | ||
1253 | } | 1279 | } |
1254 | 1280 | ||
1255 | public void ReadSculptData(byte[] data, int pos) | 1281 | public void ReadSculptData(byte[] data, int pos) |
1256 | { | 1282 | { |
1257 | UUID SculptUUID; | ||
1258 | byte SculptTypel; | ||
1259 | |||
1260 | if (data.Length-pos >= 17) | 1283 | if (data.Length-pos >= 17) |
1261 | { | 1284 | { |
1285 | _sculptTexture = new UUID(data, pos); | ||
1286 | _sculptType = data[pos + 16]; | ||
1262 | _sculptEntry = true; | 1287 | _sculptEntry = true; |
1263 | byte[] SculptTextureUUID = new byte[16]; | ||
1264 | SculptTypel = data[16 + pos]; | ||
1265 | Array.Copy(data, pos, SculptTextureUUID,0, 16); | ||
1266 | SculptUUID = new UUID(SculptTextureUUID, 0); | ||
1267 | } | 1288 | } |
1268 | else | 1289 | else |
1269 | { | 1290 | { |
1270 | _sculptEntry = false; | 1291 | _sculptEntry = false; |
1271 | SculptUUID = UUID.Zero; | 1292 | _sculptTexture = UUID.Zero; |
1272 | SculptTypel = 0x00; | 1293 | _sculptType = 0x00; |
1273 | } | ||
1274 | |||
1275 | if (_sculptEntry) | ||
1276 | { | ||
1277 | if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4) | ||
1278 | _sculptType = 4; | ||
1279 | } | 1294 | } |
1280 | |||
1281 | _sculptTexture = SculptUUID; | ||
1282 | _sculptType = SculptTypel; | ||
1283 | //m_log.Info("[SCULPT]:" + SculptUUID.ToString()); | ||
1284 | } | ||
1285 | |||
1286 | public byte[] GetSculptBytes() | ||
1287 | { | ||
1288 | byte[] data = new byte[17]; | ||
1289 | |||
1290 | _sculptTexture.GetBytes().CopyTo(data, 0); | ||
1291 | data[16] = (byte)_sculptType; | ||
1292 | |||
1293 | return data; | ||
1294 | } | 1295 | } |
1295 | 1296 | ||
1296 | public void ReadFlexiData(byte[] data, int pos) | 1297 | public void ReadFlexiData(byte[] data, int pos) |
@@ -1304,10 +1305,9 @@ namespace OpenSim.Framework | |||
1304 | _flexiDrag = (float)(data[pos++] & 0x7F) / 10.0f; | 1305 | _flexiDrag = (float)(data[pos++] & 0x7F) / 10.0f; |
1305 | _flexiGravity = (float)(data[pos++] / 10.0f) - 10.0f; | 1306 | _flexiGravity = (float)(data[pos++] / 10.0f) - 10.0f; |
1306 | _flexiWind = (float)data[pos++] / 10.0f; | 1307 | _flexiWind = (float)data[pos++] / 10.0f; |
1307 | Vector3 lForce = new Vector3(data, pos); | 1308 | _flexiForceX = Utils.BytesToFloat(data, pos); |
1308 | _flexiForceX = lForce.X; | 1309 | _flexiForceY = Utils.BytesToFloat(data, pos + 4); |
1309 | _flexiForceY = lForce.Y; | 1310 | _flexiForceZ = Utils.BytesToFloat(data, pos + 8); |
1310 | _flexiForceZ = lForce.Z; | ||
1311 | } | 1311 | } |
1312 | else | 1312 | else |
1313 | { | 1313 | { |
@@ -1324,25 +1324,6 @@ namespace OpenSim.Framework | |||
1324 | } | 1324 | } |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | public byte[] GetFlexiBytes() | ||
1328 | { | ||
1329 | byte[] data = new byte[16]; | ||
1330 | int i = 0; | ||
1331 | |||
1332 | // Softness is packed in the upper bits of tension and drag | ||
1333 | data[i] = (byte)((_flexiSoftness & 2) << 6); | ||
1334 | data[i + 1] = (byte)((_flexiSoftness & 1) << 7); | ||
1335 | |||
1336 | data[i++] |= (byte)((byte)(_flexiTension * 10.01f) & 0x7F); | ||
1337 | data[i++] |= (byte)((byte)(_flexiDrag * 10.01f) & 0x7F); | ||
1338 | data[i++] = (byte)((_flexiGravity + 10.0f) * 10.01f); | ||
1339 | data[i++] = (byte)(_flexiWind * 10.01f); | ||
1340 | Vector3 lForce = new Vector3(_flexiForceX, _flexiForceY, _flexiForceZ); | ||
1341 | lForce.GetBytes().CopyTo(data, i); | ||
1342 | |||
1343 | return data; | ||
1344 | } | ||
1345 | |||
1346 | public void ReadLightData(byte[] data, int pos) | 1327 | public void ReadLightData(byte[] data, int pos) |
1347 | { | 1328 | { |
1348 | if (data.Length - pos >= 16) | 1329 | if (data.Length - pos >= 16) |
@@ -1373,31 +1354,12 @@ namespace OpenSim.Framework | |||
1373 | } | 1354 | } |
1374 | } | 1355 | } |
1375 | 1356 | ||
1376 | public byte[] GetLightBytes() | ||
1377 | { | ||
1378 | byte[] data = new byte[16]; | ||
1379 | |||
1380 | // Alpha channel in color is intensity | ||
1381 | Color4 tmpColor = new Color4(_lightColorR,_lightColorG,_lightColorB,_lightIntensity); | ||
1382 | |||
1383 | tmpColor.GetBytes().CopyTo(data, 0); | ||
1384 | Utils.FloatToBytes(_lightRadius).CopyTo(data, 4); | ||
1385 | Utils.FloatToBytes(_lightCutoff).CopyTo(data, 8); | ||
1386 | Utils.FloatToBytes(_lightFalloff).CopyTo(data, 12); | ||
1387 | |||
1388 | return data; | ||
1389 | } | ||
1390 | |||
1391 | public void ReadProjectionData(byte[] data, int pos) | 1357 | public void ReadProjectionData(byte[] data, int pos) |
1392 | { | 1358 | { |
1393 | byte[] ProjectionTextureUUID = new byte[16]; | ||
1394 | |||
1395 | if (data.Length - pos >= 28) | 1359 | if (data.Length - pos >= 28) |
1396 | { | 1360 | { |
1397 | _projectionEntry = true; | 1361 | _projectionEntry = true; |
1398 | Array.Copy(data, pos, ProjectionTextureUUID,0, 16); | 1362 | _projectionTextureID = new UUID(data, pos); |
1399 | _projectionTextureID = new UUID(ProjectionTextureUUID, 0); | ||
1400 | |||
1401 | _projectionFOV = Utils.BytesToFloat(data, pos + 16); | 1363 | _projectionFOV = Utils.BytesToFloat(data, pos + 16); |
1402 | _projectionFocus = Utils.BytesToFloat(data, pos + 20); | 1364 | _projectionFocus = Utils.BytesToFloat(data, pos + 20); |
1403 | _projectionAmb = Utils.BytesToFloat(data, pos + 24); | 1365 | _projectionAmb = Utils.BytesToFloat(data, pos + 24); |
@@ -1412,19 +1374,20 @@ namespace OpenSim.Framework | |||
1412 | } | 1374 | } |
1413 | } | 1375 | } |
1414 | 1376 | ||
1415 | public byte[] GetProjectionBytes() | 1377 | public void ReadMeshFlagsData(byte[] data, int pos) |
1416 | { | 1378 | { |
1417 | byte[] data = new byte[28]; | 1379 | if (data.Length - pos >= 4) |
1418 | 1380 | { | |
1419 | _projectionTextureID.GetBytes().CopyTo(data, 0); | 1381 | _meshFlagsEntry = true; |
1420 | Utils.FloatToBytes(_projectionFOV).CopyTo(data, 16); | 1382 | _meshFlags = Utils.BytesToUInt(data, pos); |
1421 | Utils.FloatToBytes(_projectionFocus).CopyTo(data, 20); | 1383 | } |
1422 | Utils.FloatToBytes(_projectionAmb).CopyTo(data, 24); | 1384 | else |
1423 | 1385 | { | |
1424 | return data; | 1386 | _meshFlagsEntry = true; |
1387 | _meshFlags = 0; | ||
1388 | } | ||
1425 | } | 1389 | } |
1426 | 1390 | ||
1427 | |||
1428 | /// <summary> | 1391 | /// <summary> |
1429 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values | 1392 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values |
1430 | /// </summary> | 1393 | /// </summary> |
@@ -1436,7 +1399,6 @@ namespace OpenSim.Framework | |||
1436 | new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); | 1399 | new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); |
1437 | } | 1400 | } |
1438 | 1401 | ||
1439 | |||
1440 | /// <summary> | 1402 | /// <summary> |
1441 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values | 1403 | /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values |
1442 | /// </summary> | 1404 | /// </summary> |
@@ -1595,8 +1557,6 @@ namespace OpenSim.Framework | |||
1595 | { | 1557 | { |
1596 | using (XmlTextReader xtr = new XmlTextReader(sr)) | 1558 | using (XmlTextReader xtr = new XmlTextReader(sr)) |
1597 | { | 1559 | { |
1598 | xtr.ProhibitDtd = true; | ||
1599 | |||
1600 | xtr.MoveToContent(); | 1560 | xtr.MoveToContent(); |
1601 | 1561 | ||
1602 | string type = xtr.GetAttribute("type"); | 1562 | string type = xtr.GetAttribute("type"); |
diff --git a/OpenSim/Framework/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs index 22ffcdc..53b4f8c 100644 --- a/OpenSim/Framework/PriorityQueue.cs +++ b/OpenSim/Framework/PriorityQueue.cs | |||
@@ -46,12 +46,15 @@ namespace OpenSim.Framework | |||
46 | /// Total number of queues (priorities) available | 46 | /// Total number of queues (priorities) available |
47 | /// </summary> | 47 | /// </summary> |
48 | 48 | ||
49 | public const uint NumberOfQueues = 12; // includes immediate queues, m_queueCounts need to be set acording | 49 | public const uint NumberOfQueues = 13; // includes immediate queues, m_queueCounts need to be set acording |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Number of queuest (priorities) that are processed immediately | 52 | /// Number of queuest (priorities) that are processed immediately |
53 | /// </summary. | 53 | /// </summary. |
54 | public const uint NumberOfImmediateQueues = 2; | 54 | public const uint NumberOfImmediateQueues = 2; |
55 | // first queues are immediate, so no counts | ||
56 | private static readonly uint[] m_queueCounts = {0, 0, 8, 8, 5, 4, 3, 2, 1, 1, 1, 1, 1 }; | ||
57 | // this is ava, ava, attach, <10m, 20,40,80,160m,320,640,1280, + | ||
55 | 58 | ||
56 | private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[NumberOfQueues]; | 59 | private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[NumberOfQueues]; |
57 | private Dictionary<uint, LookupItem> m_lookupTable; | 60 | private Dictionary<uint, LookupItem> m_lookupTable; |
@@ -61,10 +64,8 @@ namespace OpenSim.Framework | |||
61 | // each pass. weighted towards the higher priority queues | 64 | // each pass. weighted towards the higher priority queues |
62 | private uint m_nextQueue = 0; | 65 | private uint m_nextQueue = 0; |
63 | private uint m_countFromQueue = 0; | 66 | private uint m_countFromQueue = 0; |
64 | // first queues are imediate, so no counts | 67 | private int m_capacity; |
65 | // private uint[] m_queueCounts = { 0, 0, 8, 4, 4, 2, 2, 2, 2, 1, 1, 1 }; | 68 | private int m_added; |
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, + | ||
68 | 69 | ||
69 | // next request is a counter of the number of updates queued, it provides | 70 | // next request is a counter of the number of updates queued, it provides |
70 | // a total ordering on the updates coming through the queue and is more | 71 | // a total ordering on the updates coming through the queue and is more |
@@ -84,17 +85,29 @@ namespace OpenSim.Framework | |||
84 | 85 | ||
85 | public PriorityQueue(int capacity) | 86 | public PriorityQueue(int capacity) |
86 | { | 87 | { |
87 | m_lookupTable = new Dictionary<uint, LookupItem>(capacity); | 88 | m_capacity = 16; |
89 | capacity /= 4; | ||
88 | 90 | ||
89 | for (int i = 0; i < m_heaps.Length; ++i) | 91 | for (int i = 0; i < m_heaps.Length; ++i) |
90 | m_heaps[i] = new MinHeap<MinHeapItem>(capacity); | 92 | m_heaps[i] = new MinHeap<MinHeapItem>(capacity); |
91 | 93 | ||
94 | m_lookupTable = new Dictionary<uint, LookupItem>(m_capacity); | ||
92 | m_nextQueue = NumberOfImmediateQueues; | 95 | m_nextQueue = NumberOfImmediateQueues; |
93 | m_countFromQueue = m_queueCounts[m_nextQueue]; | 96 | m_countFromQueue = m_queueCounts[m_nextQueue]; |
97 | m_added = 0; | ||
94 | } | 98 | } |
95 | #endregion Constructor | 99 | #endregion Constructor |
96 | 100 | ||
97 | #region PublicMethods | 101 | #region PublicMethods |
102 | public void Close() | ||
103 | { | ||
104 | for (int i = 0; i < m_heaps.Length; ++i) | ||
105 | m_heaps[i] = null; | ||
106 | m_heaps = null; | ||
107 | m_lookupTable.Clear(); | ||
108 | m_lookupTable = null; | ||
109 | } | ||
110 | |||
98 | /// <summary> | 111 | /// <summary> |
99 | /// Return the number of items in the queues | 112 | /// Return the number of items in the queues |
100 | /// </summary> | 113 | /// </summary> |
@@ -116,16 +129,33 @@ namespace OpenSim.Framework | |||
116 | public bool Enqueue(uint pqueue, EntityUpdate value) | 129 | public bool Enqueue(uint pqueue, EntityUpdate value) |
117 | { | 130 | { |
118 | LookupItem lookup; | 131 | LookupItem lookup; |
132 | IHandle lookupH; | ||
133 | UInt64 entry; | ||
119 | 134 | ||
120 | uint localid = value.Entity.LocalId; | 135 | uint localid = value.Entity.LocalId; |
121 | UInt64 entry = m_nextRequest++; | ||
122 | if (m_lookupTable.TryGetValue(localid, out lookup)) | 136 | if (m_lookupTable.TryGetValue(localid, out lookup)) |
123 | { | 137 | { |
124 | entry = lookup.Heap[lookup.Handle].EntryOrder; | 138 | lookupH = lookup.Handle; |
125 | value.Update(lookup.Heap[lookup.Handle].Value); | 139 | entry = lookup.Heap[lookupH].EntryOrder; |
126 | lookup.Heap.Remove(lookup.Handle); | 140 | EntityUpdate up = lookup.Heap[lookupH].Value; |
141 | value.Update(lookup.Heap[lookupH].Value); | ||
142 | lookup.Heap.Remove(lookupH); | ||
143 | |||
144 | if((up.Flags & PrimUpdateFlags.CancelKill) != 0) | ||
145 | entry = m_nextRequest++; | ||
146 | |||
147 | pqueue = Util.Clamp<uint>(pqueue, 0, NumberOfQueues - 1); | ||
148 | lookup.Heap = m_heaps[pqueue]; | ||
149 | lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); | ||
150 | m_lookupTable[localid] = lookup; | ||
151 | return true; | ||
127 | } | 152 | } |
128 | 153 | ||
154 | value.Update(); | ||
155 | |||
156 | entry = m_nextRequest++; | ||
157 | ++m_added; | ||
158 | |||
129 | pqueue = Util.Clamp<uint>(pqueue, 0, NumberOfQueues - 1); | 159 | pqueue = Util.Clamp<uint>(pqueue, 0, NumberOfQueues - 1); |
130 | lookup.Heap = m_heaps[pqueue]; | 160 | lookup.Heap = m_heaps[pqueue]; |
131 | lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); | 161 | lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); |
@@ -134,7 +164,6 @@ namespace OpenSim.Framework | |||
134 | return true; | 164 | return true; |
135 | } | 165 | } |
136 | 166 | ||
137 | |||
138 | public void Remove(List<uint> ids) | 167 | public void Remove(List<uint> ids) |
139 | { | 168 | { |
140 | LookupItem lookup; | 169 | LookupItem lookup; |
@@ -147,6 +176,11 @@ namespace OpenSim.Framework | |||
147 | m_lookupTable.Remove(localid); | 176 | m_lookupTable.Remove(localid); |
148 | } | 177 | } |
149 | } | 178 | } |
179 | if(m_lookupTable.Count == 0 && m_added > 8 * m_capacity) | ||
180 | { | ||
181 | m_lookupTable = new Dictionary<uint, LookupItem>(m_capacity); | ||
182 | m_added = 0; | ||
183 | } | ||
150 | } | 184 | } |
151 | 185 | ||
152 | /// <summary> | 186 | /// <summary> |
@@ -154,17 +188,17 @@ namespace OpenSim.Framework | |||
154 | /// oldest item from the next queue in order to provide fair access to | 188 | /// oldest item from the next queue in order to provide fair access to |
155 | /// all of the queues | 189 | /// all of the queues |
156 | /// </summary> | 190 | /// </summary> |
157 | public bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue) | 191 | public bool TryDequeue(out EntityUpdate value) |
158 | { | 192 | { |
159 | // If there is anything in imediate queues, return it first no | 193 | // If there is anything in immediate queues, return it first no |
160 | // matter what else. Breaks fairness. But very useful. | 194 | // matter what else. Breaks fairness. But very useful. |
195 | |||
161 | for (int iq = 0; iq < NumberOfImmediateQueues; iq++) | 196 | for (int iq = 0; iq < NumberOfImmediateQueues; iq++) |
162 | { | 197 | { |
163 | if (m_heaps[iq].Count > 0) | 198 | if (m_heaps[iq].Count > 0) |
164 | { | 199 | { |
165 | MinHeapItem item = m_heaps[iq].RemoveMin(); | 200 | MinHeapItem item = m_heaps[iq].RemoveMin(); |
166 | m_lookupTable.Remove(item.Value.Entity.LocalId); | 201 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
167 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
168 | value = item.Value; | 202 | value = item.Value; |
169 | 203 | ||
170 | return true; | 204 | return true; |
@@ -177,16 +211,15 @@ namespace OpenSim.Framework | |||
177 | // to give lower numbered queues a higher priority and higher percentage | 211 | // to give lower numbered queues a higher priority and higher percentage |
178 | // of the bandwidth. | 212 | // of the bandwidth. |
179 | 213 | ||
214 | MinHeap<MinHeapItem> curheap = m_heaps[m_nextQueue]; | ||
180 | // Check for more items to be pulled from the current queue | 215 | // Check for more items to be pulled from the current queue |
181 | if (m_heaps[m_nextQueue].Count > 0 && m_countFromQueue > 0) | 216 | if (m_countFromQueue > 0 && curheap.Count > 0) |
182 | { | 217 | { |
183 | m_countFromQueue--; | 218 | --m_countFromQueue; |
184 | 219 | ||
185 | MinHeapItem item = m_heaps[m_nextQueue].RemoveMin(); | 220 | MinHeapItem item = curheap.RemoveMin(); |
186 | m_lookupTable.Remove(item.Value.Entity.LocalId); | 221 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
187 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
188 | value = item.Value; | 222 | value = item.Value; |
189 | |||
190 | return true; | 223 | return true; |
191 | } | 224 | } |
192 | 225 | ||
@@ -196,44 +229,49 @@ namespace OpenSim.Framework | |||
196 | m_nextQueue++; | 229 | m_nextQueue++; |
197 | if(m_nextQueue >= NumberOfQueues) | 230 | if(m_nextQueue >= NumberOfQueues) |
198 | m_nextQueue = NumberOfImmediateQueues; | 231 | m_nextQueue = NumberOfImmediateQueues; |
232 | |||
233 | curheap = m_heaps[m_nextQueue]; | ||
234 | if (curheap.Count == 0) | ||
235 | continue; | ||
199 | 236 | ||
200 | m_countFromQueue = m_queueCounts[m_nextQueue]; | 237 | m_countFromQueue = m_queueCounts[m_nextQueue]; |
238 | --m_countFromQueue; | ||
201 | 239 | ||
202 | if (m_heaps[m_nextQueue].Count > 0) | 240 | MinHeapItem item = curheap.RemoveMin(); |
203 | { | 241 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
204 | m_countFromQueue--; | 242 | value = item.Value; |
205 | 243 | return true; | |
206 | MinHeapItem item = m_heaps[m_nextQueue].RemoveMin(); | ||
207 | m_lookupTable.Remove(item.Value.Entity.LocalId); | ||
208 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
209 | value = item.Value; | ||
210 | return true; | ||
211 | } | ||
212 | } | 244 | } |
213 | 245 | ||
214 | timeinqueue = 0; | ||
215 | value = default(EntityUpdate); | 246 | value = default(EntityUpdate); |
247 | if(m_lookupTable.Count == 0 && m_added > 8 * m_capacity) | ||
248 | { | ||
249 | m_lookupTable = new Dictionary<uint, LookupItem>(m_capacity); | ||
250 | m_added = 0; | ||
251 | } | ||
216 | return false; | 252 | return false; |
217 | } | 253 | } |
218 | 254 | ||
219 | public bool TryOrderedDequeue(out EntityUpdate value, out Int32 timeinqueue) | 255 | public bool TryOrderedDequeue(out EntityUpdate value) |
220 | { | 256 | { |
221 | // If there is anything in imediate queues, return it first no | 257 | for (int iq = 0; iq < NumberOfQueues; ++iq) |
222 | // matter what else. Breaks fairness. But very useful. | ||
223 | for (int iq = 0; iq < NumberOfQueues; iq++) | ||
224 | { | 258 | { |
225 | if (m_heaps[iq].Count > 0) | 259 | MinHeap<MinHeapItem> curheap = m_heaps[iq]; |
260 | if (curheap.Count > 0) | ||
226 | { | 261 | { |
227 | MinHeapItem item = m_heaps[iq].RemoveMin(); | 262 | MinHeapItem item = curheap.RemoveMin(); |
228 | m_lookupTable.Remove(item.Value.Entity.LocalId); | 263 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
229 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
230 | value = item.Value; | 264 | value = item.Value; |
231 | return true; | 265 | return true; |
232 | } | 266 | } |
233 | } | 267 | } |
234 | 268 | ||
235 | timeinqueue = 0; | ||
236 | value = default(EntityUpdate); | 269 | value = default(EntityUpdate); |
270 | if(m_lookupTable.Count == 0 && m_added > 8 * m_capacity) | ||
271 | { | ||
272 | m_lookupTable = new Dictionary<uint, LookupItem>(m_capacity); | ||
273 | m_added = 0; | ||
274 | } | ||
237 | return false; | 275 | return false; |
238 | } | 276 | } |
239 | 277 | ||
@@ -244,13 +282,11 @@ namespace OpenSim.Framework | |||
244 | public void Reprioritize(UpdatePriorityHandler handler) | 282 | public void Reprioritize(UpdatePriorityHandler handler) |
245 | { | 283 | { |
246 | MinHeapItem item; | 284 | MinHeapItem item; |
247 | foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values)) | 285 | uint pqueue = 0; |
286 | foreach (LookupItem lookup in new List<LookupItem>(m_lookupTable.Values)) | ||
248 | { | 287 | { |
249 | if (lookup.Heap.TryGetValue(lookup.Handle, out item)) | 288 | if (lookup.Heap.TryGetValue(lookup.Handle, out item)) |
250 | { | 289 | { |
251 | uint pqueue = item.PriorityQueue; | ||
252 | uint localid = item.Value.Entity.LocalId; | ||
253 | |||
254 | if (handler(ref pqueue, item.Value.Entity)) | 290 | if (handler(ref pqueue, item.Value.Entity)) |
255 | { | 291 | { |
256 | // unless the priority queue has changed, there is no need to modify | 292 | // unless the priority queue has changed, there is no need to modify |
@@ -263,14 +299,14 @@ namespace OpenSim.Framework | |||
263 | LookupItem litem = lookup; | 299 | LookupItem litem = lookup; |
264 | litem.Heap = m_heaps[pqueue]; | 300 | litem.Heap = m_heaps[pqueue]; |
265 | litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); | 301 | litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); |
266 | m_lookupTable[localid] = litem; | 302 | m_lookupTable[item.Value.Entity.LocalId] = litem; |
267 | } | 303 | } |
268 | } | 304 | } |
269 | else | 305 | else |
270 | { | 306 | { |
271 | // m_log.WarnFormat("[PQUEUE]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); | 307 | // m_log.WarnFormat("[PQUEUE]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); |
272 | lookup.Heap.Remove(lookup.Handle); | 308 | lookup.Heap.Remove(lookup.Handle); |
273 | this.m_lookupTable.Remove(localid); | 309 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
274 | } | 310 | } |
275 | } | 311 | } |
276 | } | 312 | } |
@@ -282,7 +318,7 @@ namespace OpenSim.Framework | |||
282 | { | 318 | { |
283 | string s = ""; | 319 | string s = ""; |
284 | for (int i = 0; i < NumberOfQueues; i++) | 320 | for (int i = 0; i < NumberOfQueues; i++) |
285 | s += String.Format("{0,7} ",m_heaps[i].Count); | 321 | s += String.Format("{0,7} ", m_heaps[i].Count); |
286 | return s; | 322 | return s; |
287 | } | 323 | } |
288 | 324 | ||
@@ -292,48 +328,44 @@ namespace OpenSim.Framework | |||
292 | private struct MinHeapItem : IComparable<MinHeapItem> | 328 | private struct MinHeapItem : IComparable<MinHeapItem> |
293 | { | 329 | { |
294 | private EntityUpdate value; | 330 | private EntityUpdate value; |
295 | internal EntityUpdate Value { | 331 | internal EntityUpdate Value |
296 | get { | 332 | { |
297 | return this.value; | 333 | get |
334 | { | ||
335 | return value; | ||
298 | } | 336 | } |
299 | } | 337 | } |
300 | 338 | ||
301 | private uint pqueue; | 339 | private uint pqueue; |
302 | internal uint PriorityQueue { | 340 | internal uint PriorityQueue |
303 | get { | 341 | { |
304 | return this.pqueue; | 342 | get |
305 | } | 343 | { |
306 | } | 344 | return pqueue; |
307 | |||
308 | private Int32 entrytime; | ||
309 | internal Int32 EntryTime { | ||
310 | get { | ||
311 | return this.entrytime; | ||
312 | } | 345 | } |
313 | } | 346 | } |
314 | 347 | ||
315 | private UInt64 entryorder; | 348 | private UInt64 entryorder; |
316 | internal UInt64 EntryOrder | 349 | internal UInt64 EntryOrder |
317 | { | 350 | { |
318 | get { | 351 | get |
319 | return this.entryorder; | 352 | { |
353 | return entryorder; | ||
320 | } | 354 | } |
321 | } | 355 | } |
322 | 356 | ||
323 | internal MinHeapItem(uint pqueue, MinHeapItem other) | 357 | internal MinHeapItem(uint _pqueue, MinHeapItem other) |
324 | { | 358 | { |
325 | this.entrytime = other.entrytime; | 359 | entryorder = other.entryorder; |
326 | this.entryorder = other.entryorder; | 360 | value = other.value; |
327 | this.value = other.value; | 361 | pqueue = _pqueue; |
328 | this.pqueue = pqueue; | ||
329 | } | 362 | } |
330 | 363 | ||
331 | internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value) | 364 | internal MinHeapItem(uint _pqueue, UInt64 _entryorder, EntityUpdate _value) |
332 | { | 365 | { |
333 | this.entrytime = Util.EnvironmentTickCount(); | 366 | entryorder = _entryorder; |
334 | this.entryorder = entryorder; | 367 | value = _value; |
335 | this.value = value; | 368 | pqueue = _pqueue; |
336 | this.pqueue = pqueue; | ||
337 | } | 369 | } |
338 | 370 | ||
339 | public override string ToString() | 371 | public override string ToString() |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 9e5162e..df0b8da 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -180,6 +180,7 @@ namespace OpenSim.Framework | |||
180 | 180 | ||
181 | private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>(); | 181 | private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>(); |
182 | 182 | ||
183 | public UUID CacheID { get; set;} | ||
183 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. | 184 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. |
184 | 185 | ||
185 | // MT: Yes. Estates can't span trust boundaries. Therefore, it can be | 186 | // MT: Yes. Estates can't span trust boundaries. Therefore, it can be |
@@ -196,7 +197,7 @@ namespace OpenSim.Framework | |||
196 | public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource, string configName) | 197 | public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource, string configName) |
197 | { | 198 | { |
198 | // m_configSource = configSource; | 199 | // m_configSource = configSource; |
199 | 200 | CacheID = UUID.Random(); | |
200 | if (string.Empty == filename) | 201 | if (string.Empty == filename) |
201 | { | 202 | { |
202 | ReadNiniConfig(configSource, "Region", configName); | 203 | ReadNiniConfig(configSource, "Region", configName); |
@@ -261,6 +262,7 @@ namespace OpenSim.Framework | |||
261 | ReadNiniConfig(source, name); | 262 | ReadNiniConfig(source, name); |
262 | 263 | ||
263 | m_serverURI = string.Empty; | 264 | m_serverURI = string.Empty; |
265 | CacheID = UUID.Random(); | ||
264 | } | 266 | } |
265 | 267 | ||
266 | public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri) | 268 | public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri) |
@@ -272,11 +274,13 @@ namespace OpenSim.Framework | |||
272 | m_internalEndPoint = internalEndPoint; | 274 | m_internalEndPoint = internalEndPoint; |
273 | m_externalHostName = externalUri; | 275 | m_externalHostName = externalUri; |
274 | m_serverURI = string.Empty; | 276 | m_serverURI = string.Empty; |
277 | CacheID = UUID.Random(); | ||
275 | } | 278 | } |
276 | 279 | ||
277 | public RegionInfo() | 280 | public RegionInfo() |
278 | { | 281 | { |
279 | m_serverURI = string.Empty; | 282 | m_serverURI = string.Empty; |
283 | CacheID = UUID.Random(); | ||
280 | } | 284 | } |
281 | 285 | ||
282 | public EstateSettings EstateSettings | 286 | public EstateSettings EstateSettings |
@@ -533,7 +537,7 @@ namespace OpenSim.Framework | |||
533 | { | 537 | { |
534 | while (name.Trim() == string.Empty) | 538 | while (name.Trim() == string.Empty) |
535 | { | 539 | { |
536 | name = MainConsole.Instance.CmdPrompt("New region name", name); | 540 | name = MainConsole.Instance.Prompt("New region name", name); |
537 | if (name.Trim() == string.Empty) | 541 | if (name.Trim() == string.Empty) |
538 | { | 542 | { |
539 | MainConsole.Instance.Output("Cannot interactively create region with no name"); | 543 | MainConsole.Instance.Output("Cannot interactively create region with no name"); |
@@ -579,7 +583,7 @@ namespace OpenSim.Framework | |||
579 | UUID newID = UUID.Random(); | 583 | UUID newID = UUID.Random(); |
580 | while (RegionID == UUID.Zero) | 584 | while (RegionID == UUID.Zero) |
581 | { | 585 | { |
582 | regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString()); | 586 | regionUUID = MainConsole.Instance.Prompt("RegionUUID", newID.ToString()); |
583 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) | 587 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) |
584 | { | 588 | { |
585 | MainConsole.Instance.Output("RegionUUID must be a valid UUID"); | 589 | MainConsole.Instance.Output("RegionUUID must be a valid UUID"); |
@@ -596,7 +600,7 @@ namespace OpenSim.Framework | |||
596 | string location = config.GetString("Location", String.Empty); | 600 | string location = config.GetString("Location", String.Empty); |
597 | if (location == String.Empty) | 601 | if (location == String.Empty) |
598 | { | 602 | { |
599 | location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000"); | 603 | location = MainConsole.Instance.Prompt("Region Location", "1000,1000"); |
600 | config.Set("Location", location); | 604 | config.Set("Location", location); |
601 | } | 605 | } |
602 | 606 | ||
@@ -632,7 +636,7 @@ namespace OpenSim.Framework | |||
632 | } | 636 | } |
633 | else | 637 | else |
634 | { | 638 | { |
635 | address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0")); | 639 | address = IPAddress.Parse(MainConsole.Instance.Prompt("Internal IP address", "0.0.0.0")); |
636 | config.Set("InternalAddress", address.ToString()); | 640 | config.Set("InternalAddress", address.ToString()); |
637 | } | 641 | } |
638 | 642 | ||
@@ -646,7 +650,7 @@ namespace OpenSim.Framework | |||
646 | } | 650 | } |
647 | else | 651 | else |
648 | { | 652 | { |
649 | port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000")); | 653 | port = Convert.ToInt32(MainConsole.Instance.Prompt("Internal port", "9000")); |
650 | config.Set("InternalPort", port); | 654 | config.Set("InternalPort", port); |
651 | } | 655 | } |
652 | m_internalEndPoint = new IPEndPoint(address, port); | 656 | m_internalEndPoint = new IPEndPoint(address, port); |
@@ -661,7 +665,7 @@ namespace OpenSim.Framework | |||
661 | else | 665 | else |
662 | { | 666 | { |
663 | if (creatingNew) | 667 | if (creatingNew) |
664 | m_resolveAddress = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Resolve hostname to IP on start (for running inside Docker)", "False")); | 668 | m_resolveAddress = Convert.ToBoolean(MainConsole.Instance.Prompt("Resolve hostname to IP on start (for running inside Docker)", "False")); |
665 | 669 | ||
666 | config.Set("ResolveAddress", m_resolveAddress.ToString()); | 670 | config.Set("ResolveAddress", m_resolveAddress.ToString()); |
667 | } | 671 | } |
@@ -676,7 +680,7 @@ namespace OpenSim.Framework | |||
676 | } | 680 | } |
677 | else | 681 | else |
678 | { | 682 | { |
679 | externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP"); | 683 | externalName = MainConsole.Instance.Prompt("External host name", "SYSTEMIP"); |
680 | config.Set("ExternalHostName", externalName); | 684 | config.Set("ExternalHostName", externalName); |
681 | } | 685 | } |
682 | if (externalName == "SYSTEMIP") | 686 | if (externalName == "SYSTEMIP") |
diff --git a/OpenSim/Framework/RegionInfoForEstateMenuArgs.cs b/OpenSim/Framework/RegionInfoForEstateMenuArgs.cs index f274da2..1b828ca 100644 --- a/OpenSim/Framework/RegionInfoForEstateMenuArgs.cs +++ b/OpenSim/Framework/RegionInfoForEstateMenuArgs.cs | |||
@@ -33,7 +33,7 @@ namespace OpenSim.Framework | |||
33 | { | 33 | { |
34 | public float billableFactor; | 34 | public float billableFactor; |
35 | public uint estateID; | 35 | public uint estateID; |
36 | public byte maxAgents; | 36 | public int maxAgents; |
37 | public float objectBonusFactor; | 37 | public float objectBonusFactor; |
38 | public uint parentEstateID; | 38 | public uint parentEstateID; |
39 | public int pricePerMeter; | 39 | public int pricePerMeter; |
@@ -48,5 +48,7 @@ namespace OpenSim.Framework | |||
48 | public float waterHeight; | 48 | public float waterHeight; |
49 | public string simName; | 49 | public string simName; |
50 | public string regionType; | 50 | public string regionType; |
51 | public int AgentCapacity; | ||
52 | public int ObjectsCapacity; | ||
51 | } | 53 | } |
52 | } | 54 | } |
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index af130a5..238ebb1 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | |||
@@ -156,7 +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 | |
160 | doc.LoadXml(xml); | 160 | doc.LoadXml(xml); |
161 | XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); | 161 | XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); |
162 | 162 | ||
@@ -221,7 +221,7 @@ namespace OpenSim.Framework.Serialization.External | |||
221 | using (StringWriter sw = new StringWriter()) | 221 | using (StringWriter sw = new StringWriter()) |
222 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | 222 | using (XmlTextWriter writer = new XmlTextWriter(sw)) |
223 | using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) | 223 | using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) |
224 | using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, ProhibitDtd = true})) | 224 | using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment})) |
225 | { | 225 | { |
226 | TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); | 226 | TransformXml(reader, writer, sceneName, homeURL, userService, scopeID); |
227 | 227 | ||
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index 33ffd83..e42d56f 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -178,7 +178,6 @@ 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; | ||
182 | reader.ReadStartElement("LandData"); | 181 | reader.ReadStartElement("LandData"); |
183 | 182 | ||
184 | ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); | 183 | ExternalRepresentationUtils.ExecuteReadProcessors<LandData>(landData, m_ldProcessors, reader); |
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs index fd21f3e..617c451 100644 --- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs +++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs | |||
@@ -63,7 +63,6 @@ namespace OpenSim.Framework.Serialization.External | |||
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 | xtr.ProhibitDtd = true; | ||
67 | 66 | ||
68 | xtr.ReadStartElement("RegionSettings"); | 67 | xtr.ReadStartElement("RegionSettings"); |
69 | 68 | ||
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 12194ad..9b02553 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -202,8 +202,6 @@ 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 | |||
207 | reader.ReadStartElement("InventoryItem"); | 205 | reader.ReadStartElement("InventoryItem"); |
208 | 206 | ||
209 | ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>( | 207 | ExternalRepresentationUtils.ExecuteReadProcessors<InventoryItemBase>( |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 81dd357..c09e53d 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -33,6 +33,9 @@ using System.Text; | |||
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Timers; | 35 | using System.Timers; |
36 | using System.Net; | ||
37 | using System.Net.Security; | ||
38 | using System.Security.Cryptography.X509Certificates; | ||
36 | using log4net; | 39 | using log4net; |
37 | using log4net.Appender; | 40 | using log4net.Appender; |
38 | using log4net.Core; | 41 | using log4net.Core; |
@@ -86,6 +89,26 @@ namespace OpenSim.Framework.Servers | |||
86 | m_osSecret = UUID.Random().ToString(); | 89 | m_osSecret = UUID.Random().ToString(); |
87 | } | 90 | } |
88 | 91 | ||
92 | private static bool m_NoVerifyCertChain = false; | ||
93 | private static bool m_NoVerifyCertHostname = false; | ||
94 | |||
95 | public static bool ValidateServerCertificate( | ||
96 | object sender, | ||
97 | X509Certificate certificate, | ||
98 | X509Chain chain, | ||
99 | SslPolicyErrors sslPolicyErrors) | ||
100 | { | ||
101 | if (m_NoVerifyCertChain) | ||
102 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors; | ||
103 | |||
104 | if (m_NoVerifyCertHostname) | ||
105 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; | ||
106 | |||
107 | if (sslPolicyErrors == SslPolicyErrors.None) | ||
108 | return true; | ||
109 | |||
110 | return false; | ||
111 | } | ||
89 | /// <summary> | 112 | /// <summary> |
90 | /// Must be overriden by child classes for their own server specific startup behaviour. | 113 | /// Must be overriden by child classes for their own server specific startup behaviour. |
91 | /// </summary> | 114 | /// </summary> |
@@ -96,6 +119,11 @@ namespace OpenSim.Framework.Servers | |||
96 | RegisterCommonComponents(Config); | 119 | RegisterCommonComponents(Config); |
97 | 120 | ||
98 | IConfig startupConfig = Config.Configs["Startup"]; | 121 | IConfig startupConfig = Config.Configs["Startup"]; |
122 | |||
123 | m_NoVerifyCertChain = startupConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); | ||
124 | m_NoVerifyCertHostname = startupConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); | ||
125 | ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; | ||
126 | |||
99 | int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); | 127 | int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); |
100 | m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; | 128 | m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; |
101 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | 129 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); |
@@ -113,11 +141,10 @@ namespace OpenSim.Framework.Servers | |||
113 | 141 | ||
114 | MainServer.Stop(); | 142 | MainServer.Stop(); |
115 | 143 | ||
116 | Thread.Sleep(5000); | 144 | Thread.Sleep(500); |
117 | Util.StopThreadPool(); | 145 | Util.StopThreadPool(); |
118 | WorkManager.Stop(); | 146 | WorkManager.Stop(); |
119 | 147 | ||
120 | Thread.Sleep(1000); | ||
121 | RemovePIDFile(); | 148 | RemovePIDFile(); |
122 | 149 | ||
123 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | 150 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 26694b5..d7cffb9 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -32,6 +32,7 @@ using System.Collections.Specialized; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Net; | 33 | using System.Net; |
34 | using System.Net.Sockets; | 34 | using System.Net.Sockets; |
35 | using System.Net.Security; | ||
35 | using System.Security.Cryptography.X509Certificates; | 36 | using System.Security.Cryptography.X509Certificates; |
36 | using System.Reflection; | 37 | using System.Reflection; |
37 | using System.Globalization; | 38 | using System.Globalization; |
@@ -43,10 +44,11 @@ using log4net; | |||
43 | using Nwc.XmlRpc; | 44 | using Nwc.XmlRpc; |
44 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
45 | using CoolHTTPListener = HttpServer.HttpListener; | 46 | using CoolHTTPListener = HttpServer.HttpListener; |
46 | using HttpListener=System.Net.HttpListener; | 47 | using LogPrio = HttpServer.LogPrio; |
47 | using LogPrio=HttpServer.LogPrio; | ||
48 | using OpenSim.Framework.Monitoring; | 48 | using OpenSim.Framework.Monitoring; |
49 | using System.IO.Compression; | 49 | using System.IO.Compression; |
50 | using System.Security.Cryptography; | ||
51 | using OpenSim.Framework.Servers; | ||
50 | 52 | ||
51 | namespace OpenSim.Framework.Servers.HttpServer | 53 | namespace OpenSim.Framework.Servers.HttpServer |
52 | { | 54 | { |
@@ -55,6 +57,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); | 58 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); |
57 | private static Encoding UTF8NoBOM = new System.Text.UTF8Encoding(false); | 59 | private static Encoding UTF8NoBOM = new System.Text.UTF8Encoding(false); |
60 | public static PollServiceRequestManager m_pollServiceManager; | ||
61 | private static object m_generalLock = new object(); | ||
58 | 62 | ||
59 | /// <summary> | 63 | /// <summary> |
60 | /// This is a pending websocket request before it got an sucessful upgrade response. | 64 | /// This is a pending websocket request before it got an sucessful upgrade response. |
@@ -107,19 +111,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
107 | new Dictionary<string, WebSocketRequestDelegate>(); | 111 | new Dictionary<string, WebSocketRequestDelegate>(); |
108 | 112 | ||
109 | protected uint m_port; | 113 | protected uint m_port; |
110 | protected uint m_sslport; | ||
111 | protected bool m_ssl; | 114 | protected bool m_ssl; |
112 | private X509Certificate2 m_cert; | 115 | private X509Certificate2 m_cert; |
113 | protected bool m_firstcaps = true; | ||
114 | protected string m_SSLCommonName = ""; | 116 | protected string m_SSLCommonName = ""; |
117 | protected List<string> m_certNames = new List<string>(); | ||
118 | protected List<string> m_certIPs = new List<string>(); | ||
119 | protected string m_certCN= ""; | ||
120 | protected RemoteCertificateValidationCallback m_certificateValidationCallback = null; | ||
115 | 121 | ||
116 | protected IPAddress m_listenIPAddress = IPAddress.Any; | 122 | protected IPAddress m_listenIPAddress = IPAddress.Any; |
117 | 123 | ||
118 | public PollServiceRequestManager PollServiceRequestManager { get; private set; } | 124 | |
125 | public string Protocol | ||
126 | { | ||
127 | get { return m_ssl ? "https://" : "http://"; } | ||
128 | } | ||
119 | 129 | ||
120 | public uint SSLPort | 130 | public uint SSLPort |
121 | { | 131 | { |
122 | get { return m_sslport; } | 132 | get { return m_port; } |
123 | } | 133 | } |
124 | 134 | ||
125 | public string SSLCommonName | 135 | public string SSLCommonName |
@@ -148,27 +158,166 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
148 | m_port = port; | 158 | m_port = port; |
149 | } | 159 | } |
150 | 160 | ||
151 | public BaseHttpServer(uint port, bool ssl) : this (port) | 161 | private void load_cert(string CPath, string CPass) |
152 | { | 162 | { |
153 | m_ssl = ssl; | 163 | try |
164 | { | ||
165 | m_cert = new X509Certificate2(CPath, CPass); | ||
166 | X509Extension ext = m_cert.Extensions["2.5.29.17"]; | ||
167 | if(ext != null) | ||
168 | { | ||
169 | AsnEncodedData asndata = new AsnEncodedData(ext.Oid, ext.RawData); | ||
170 | string datastr = asndata.Format(true); | ||
171 | string[] lines = datastr.Split(new char[] {'\n','\r'}); | ||
172 | foreach(string s in lines) | ||
173 | { | ||
174 | if(String.IsNullOrEmpty(s)) | ||
175 | continue; | ||
176 | string[] parts = s.Split(new char[] {'='}); | ||
177 | if(String.IsNullOrEmpty(parts[0])) | ||
178 | continue; | ||
179 | string entryName = parts[0].Replace(" ",""); | ||
180 | if(entryName == "DNSName") | ||
181 | m_certNames.Add(parts[1]); | ||
182 | else if(entryName == "IPAddress") | ||
183 | m_certIPs.Add(parts[1]); | ||
184 | else if(entryName == "Unknown(135)") // stupid mono | ||
185 | { | ||
186 | try | ||
187 | { | ||
188 | if(parts[1].Length == 8) | ||
189 | { | ||
190 | long tmp = long.Parse(parts[1], NumberStyles.AllowHexSpecifier); | ||
191 | tmp = IPAddress.HostToNetworkOrder(tmp); | ||
192 | tmp = (long)((ulong) tmp >> 32); | ||
193 | IPAddress ia = new IPAddress(tmp); | ||
194 | m_certIPs.Add(ia.ToString()); | ||
195 | } | ||
196 | } | ||
197 | catch {} | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | m_certCN = m_cert.GetNameInfo(X509NameType.SimpleName, false); | ||
202 | } | ||
203 | catch | ||
204 | { | ||
205 | throw new Exception("SSL cert load error"); | ||
206 | } | ||
154 | } | 207 | } |
155 | 208 | ||
156 | public BaseHttpServer(uint port, bool ssl, uint sslport, string CN) : this (port, ssl) | 209 | public BaseHttpServer(uint port, bool ssl, string CN, string CPath, string CPass) |
157 | { | 210 | { |
158 | if (m_ssl) | 211 | m_port = port; |
212 | if (ssl) | ||
159 | { | 213 | { |
160 | m_sslport = sslport; | 214 | if(string.IsNullOrEmpty(CPath)) |
215 | throw new Exception("invalid main http server cert path"); | ||
216 | |||
217 | if(Uri.CheckHostName(CN) == UriHostNameType.Unknown) | ||
218 | throw new Exception("invalid main http server CN (ExternalHostName)"); | ||
219 | |||
220 | m_certNames.Clear(); | ||
221 | m_certIPs.Clear(); | ||
222 | m_certCN= ""; | ||
223 | |||
224 | m_ssl = true; | ||
225 | load_cert(CPath, CPass); | ||
226 | |||
227 | if(!CheckSSLCertHost(CN)) | ||
228 | throw new Exception("invalid main http server CN (ExternalHostName)"); | ||
229 | |||
230 | m_SSLCommonName = CN; | ||
231 | |||
232 | if(m_cert.Issuer == m_cert.Subject ) | ||
233 | m_log.Warn("Self signed certificate. Clients need to allow this (some viewers debug option NoVerifySSLcert must be set to true"); | ||
161 | } | 234 | } |
235 | else | ||
236 | m_ssl = false; | ||
162 | } | 237 | } |
163 | 238 | ||
164 | public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) | 239 | public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) |
165 | { | 240 | { |
166 | if (m_ssl) | 241 | m_port = port; |
242 | if (ssl) | ||
167 | { | 243 | { |
168 | m_cert = new X509Certificate2(CPath, CPass); | 244 | load_cert(CPath, CPass); |
245 | if(m_cert.Issuer == m_cert.Subject ) | ||
246 | m_log.Warn("Self signed certificate. Http clients need to allow this"); | ||
247 | m_ssl = true; | ||
169 | } | 248 | } |
249 | else | ||
250 | m_ssl = false; | ||
251 | } | ||
252 | |||
253 | static bool MatchDNS(string hostname, string dns) | ||
254 | { | ||
255 | int indx = dns.IndexOf('*'); | ||
256 | if (indx == -1) | ||
257 | return (String.Compare(hostname, dns, true, CultureInfo.InvariantCulture) == 0); | ||
258 | |||
259 | int dnslen = dns.Length; | ||
260 | dnslen--; | ||
261 | if (indx == dnslen) | ||
262 | return true; // just * ? | ||
263 | |||
264 | if (indx > dnslen - 2) | ||
265 | return false; // 2 short ? | ||
266 | |||
267 | if (dns[indx + 1] != '.') | ||
268 | return false; | ||
269 | |||
270 | int indx2 = dns.IndexOf('*', indx + 1); | ||
271 | if (indx2 != -1) | ||
272 | return false; // there can only be one; | ||
273 | |||
274 | string end = dns.Substring(indx + 1); | ||
275 | int hostlen = hostname.Length; | ||
276 | int endlen = end.Length; | ||
277 | int length = hostlen - endlen; | ||
278 | if (length <= 0) | ||
279 | return false; | ||
280 | |||
281 | if (String.Compare(hostname, length, end, 0, endlen, true, CultureInfo.InvariantCulture) != 0) | ||
282 | return false; | ||
283 | |||
284 | if (indx == 0) | ||
285 | { | ||
286 | indx2 = hostname.IndexOf('.'); | ||
287 | return ((indx2 == -1) || (indx2 >= length)); | ||
288 | } | ||
289 | |||
290 | string start = dns.Substring(0, indx); | ||
291 | return (String.Compare(hostname, 0, start, 0, start.Length, true, CultureInfo.InvariantCulture) == 0); | ||
170 | } | 292 | } |
171 | 293 | ||
294 | public bool CheckSSLCertHost(string hostname) | ||
295 | { | ||
296 | UriHostNameType htype = Uri.CheckHostName(hostname); | ||
297 | |||
298 | if(htype == UriHostNameType.Unknown || htype == UriHostNameType.Basic) | ||
299 | return false; | ||
300 | if(htype == UriHostNameType.Dns) | ||
301 | { | ||
302 | foreach(string name in m_certNames) | ||
303 | { | ||
304 | if(MatchDNS(hostname, name)) | ||
305 | return true; | ||
306 | } | ||
307 | if(MatchDNS(hostname, m_certCN)) | ||
308 | return true; | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | foreach(string ip in m_certIPs) | ||
313 | { | ||
314 | if (String.Compare(hostname, ip, true, CultureInfo.InvariantCulture) == 0) | ||
315 | return true; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | return false; | ||
320 | } | ||
172 | /// <summary> | 321 | /// <summary> |
173 | /// Add a stream handler to the http server. If the handler already exists, then nothing happens. | 322 | /// Add a stream handler to the http server. If the handler already exists, then nothing happens. |
174 | /// </summary> | 323 | /// </summary> |
@@ -379,7 +528,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
379 | public void OnRequest(object source, RequestEventArgs args) | 528 | public void OnRequest(object source, RequestEventArgs args) |
380 | { | 529 | { |
381 | RequestNumber++; | 530 | RequestNumber++; |
382 | |||
383 | try | 531 | try |
384 | { | 532 | { |
385 | IHttpClientContext context = (IHttpClientContext)source; | 533 | IHttpClientContext context = (IHttpClientContext)source; |
@@ -396,12 +544,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
396 | if (psEvArgs.Request != null) | 544 | if (psEvArgs.Request != null) |
397 | { | 545 | { |
398 | OSHttpRequest req = new OSHttpRequest(context, request); | 546 | OSHttpRequest req = new OSHttpRequest(context, request); |
399 | |||
400 | Stream requestStream = req.InputStream; | ||
401 | |||
402 | string requestBody; | 547 | string requestBody; |
403 | Encoding encoding = Encoding.UTF8; | 548 | Encoding encoding = Encoding.UTF8; |
404 | using(StreamReader reader = new StreamReader(requestStream, encoding)) | 549 | using(StreamReader reader = new StreamReader(req.InputStream, encoding)) |
405 | requestBody = reader.ReadToEnd(); | 550 | requestBody = reader.ReadToEnd(); |
406 | 551 | ||
407 | Hashtable keysvals = new Hashtable(); | 552 | Hashtable keysvals = new Hashtable(); |
@@ -431,7 +576,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
431 | psEvArgs.Request(psreq.RequestID, keysvals); | 576 | psEvArgs.Request(psreq.RequestID, keysvals); |
432 | } | 577 | } |
433 | 578 | ||
434 | PollServiceRequestManager.Enqueue(psreq); | 579 | m_pollServiceManager.Enqueue(psreq); |
435 | } | 580 | } |
436 | else | 581 | else |
437 | { | 582 | { |
@@ -459,9 +604,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
459 | return; | 604 | return; |
460 | } | 605 | } |
461 | 606 | ||
462 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 607 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request)); |
463 | resp.ReuseContext = true; | 608 | |
464 | // resp.ReuseContext = false; | ||
465 | HandleRequest(req, resp); | 609 | HandleRequest(req, resp); |
466 | 610 | ||
467 | // !!!HACK ALERT!!! | 611 | // !!!HACK ALERT!!! |
@@ -472,16 +616,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
472 | request.AcceptTypes[i] = string.Empty; | 616 | request.AcceptTypes[i] = string.Empty; |
473 | } | 617 | } |
474 | 618 | ||
475 | // public void ConvertIHttpClientContextToOSHttp(object stateinfo) | ||
476 | // { | ||
477 | // HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; | ||
478 | |||
479 | // OSHttpRequest request = objstate.oreq; | ||
480 | // OSHttpResponse resp = objstate.oresp; | ||
481 | |||
482 | // HandleRequest(request,resp); | ||
483 | // } | ||
484 | |||
485 | /// <summary> | 619 | /// <summary> |
486 | /// This methods is the start of incoming HTTP request handling. | 620 | /// This methods is the start of incoming HTTP request handling. |
487 | /// </summary> | 621 | /// </summary> |
@@ -493,6 +627,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
493 | { | 627 | { |
494 | try | 628 | try |
495 | { | 629 | { |
630 | if(request.InputStream != null && request.InputStream.CanRead) | ||
631 | request.InputStream.Close(); | ||
496 | byte[] buffer500 = SendHTML500(response); | 632 | byte[] buffer500 = SendHTML500(response); |
497 | response.OutputStream.Write(buffer500, 0, buffer500.Length); | 633 | response.OutputStream.Write(buffer500, 0, buffer500.Length); |
498 | response.Send(); | 634 | response.Send(); |
@@ -540,9 +676,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
540 | // } | 676 | // } |
541 | // } | 677 | // } |
542 | 678 | ||
543 | //response.KeepAlive = true; | ||
544 | response.SendChunked = false; | ||
545 | |||
546 | string path = request.RawUrl; | 679 | string path = request.RawUrl; |
547 | string handlerKey = GetHandlerKey(request.HttpMethod, path); | 680 | string handlerKey = GetHandlerKey(request.HttpMethod, path); |
548 | byte[] buffer = null; | 681 | byte[] buffer = null; |
@@ -564,11 +697,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
564 | { | 697 | { |
565 | //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); | 698 | //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); |
566 | IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; | 699 | IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; |
567 | Stream requestStream = request.InputStream; | ||
568 | 700 | ||
569 | string requestBody; | 701 | string requestBody; |
570 | Encoding encoding = Encoding.UTF8; | 702 | Encoding encoding = Encoding.UTF8; |
571 | using(StreamReader reader = new StreamReader(requestStream, encoding)) | 703 | using(StreamReader reader = new StreamReader(request.InputStream, encoding)) |
572 | requestBody = reader.ReadToEnd(); | 704 | requestBody = reader.ReadToEnd(); |
573 | 705 | ||
574 | Hashtable keysvals = new Hashtable(); | 706 | Hashtable keysvals = new Hashtable(); |
@@ -609,11 +741,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
609 | else | 741 | else |
610 | { | 742 | { |
611 | IStreamHandler streamHandler = (IStreamHandler)requestHandler; | 743 | IStreamHandler streamHandler = (IStreamHandler)requestHandler; |
612 | |||
613 | using (MemoryStream memoryStream = new MemoryStream()) | 744 | using (MemoryStream memoryStream = new MemoryStream()) |
614 | { | 745 | { |
615 | streamHandler.Handle(path, request.InputStream, memoryStream, request, response); | 746 | streamHandler.Handle(path, request.InputStream, memoryStream, request, response); |
616 | memoryStream.Flush(); | ||
617 | buffer = memoryStream.ToArray(); | 747 | buffer = memoryStream.ToArray(); |
618 | } | 748 | } |
619 | } | 749 | } |
@@ -686,7 +816,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
686 | } | 816 | } |
687 | } | 817 | } |
688 | 818 | ||
689 | if(request.InputStream.CanRead) | 819 | if(request.InputStream != null && request.InputStream.CanRead) |
690 | request.InputStream.Dispose(); | 820 | request.InputStream.Dispose(); |
691 | 821 | ||
692 | if (buffer != null) | 822 | if (buffer != null) |
@@ -711,7 +841,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
711 | if (!response.SendChunked && response.ContentLength64 <= 0) | 841 | if (!response.SendChunked && response.ContentLength64 <= 0) |
712 | response.ContentLength64 = buffer.LongLength; | 842 | response.ContentLength64 = buffer.LongLength; |
713 | 843 | ||
714 | response.OutputStream.Write(buffer, 0, buffer.Length); | 844 | //response.OutputStream.Write(buffer, 0, buffer.Length); |
845 | response.RawBufferStart = 0; | ||
846 | response.RawBufferLen = buffer.Length; | ||
847 | response.RawBuffer = buffer; | ||
715 | } | 848 | } |
716 | 849 | ||
717 | // Do not include the time taken to actually send the response to the caller in the measurement | 850 | // Do not include the time taken to actually send the response to the caller in the measurement |
@@ -719,11 +852,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
719 | // server | 852 | // server |
720 | requestEndTick = Environment.TickCount; | 853 | requestEndTick = Environment.TickCount; |
721 | 854 | ||
855 | buffer = null; | ||
722 | response.Send(); | 856 | response.Send(); |
723 | 857 | response.RawBuffer = null; | |
724 | //response.OutputStream.Close(); | ||
725 | |||
726 | //response.FreeContext(); | ||
727 | } | 858 | } |
728 | catch (SocketException e) | 859 | catch (SocketException e) |
729 | { | 860 | { |
@@ -755,6 +886,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
755 | } | 886 | } |
756 | finally | 887 | finally |
757 | { | 888 | { |
889 | if(request.InputStream != null && request.InputStream.CanRead) | ||
890 | request.InputStream.Close(); | ||
891 | |||
758 | // Every month or so this will wrap and give bad numbers, not really a problem | 892 | // Every month or so this will wrap and give bad numbers, not really a problem |
759 | // since its just for reporting | 893 | // since its just for reporting |
760 | int tickdiff = requestEndTick - requestStartTick; | 894 | int tickdiff = requestEndTick - requestStartTick; |
@@ -1008,12 +1142,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1008 | using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) | 1142 | using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) |
1009 | requestBody = reader.ReadToEnd(); | 1143 | requestBody = reader.ReadToEnd(); |
1010 | 1144 | ||
1011 | } | 1145 | } |
1012 | finally | 1146 | finally |
1013 | { | 1147 | { |
1014 | if (innerStream != null) | 1148 | if (innerStream != null && innerStream.CanRead) |
1015 | innerStream.Dispose(); | 1149 | innerStream.Dispose(); |
1016 | requestStream.Dispose(); | 1150 | if (requestStream.CanRead) |
1151 | requestStream.Dispose(); | ||
1017 | } | 1152 | } |
1018 | 1153 | ||
1019 | //m_log.Debug(requestBody); | 1154 | //m_log.Debug(requestBody); |
@@ -1094,6 +1229,17 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1094 | 1229 | ||
1095 | if (gridproxy) | 1230 | if (gridproxy) |
1096 | xmlRprcRequest.Params.Add("gridproxy"); // Param[4] | 1231 | xmlRprcRequest.Params.Add("gridproxy"); // Param[4] |
1232 | |||
1233 | // reserve this for | ||
1234 | // ... by Fumi.Iseki for DTLNSLMoneyServer | ||
1235 | // BUT make its presence possible to detect/parse | ||
1236 | string rcn = request.IHttpClientContext.SSLCommonName; | ||
1237 | if(!string.IsNullOrWhiteSpace(rcn)) | ||
1238 | { | ||
1239 | rcn = "SSLCN:" + rcn; | ||
1240 | xmlRprcRequest.Params.Add(rcn); // Param[4] or Param[5] | ||
1241 | } | ||
1242 | |||
1097 | try | 1243 | try |
1098 | { | 1244 | { |
1099 | xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); | 1245 | xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); |
@@ -1116,6 +1262,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1116 | 1262 | ||
1117 | // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here | 1263 | // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here |
1118 | response.KeepAlive = keepAlive; | 1264 | response.KeepAlive = keepAlive; |
1265 | response.AddHeader("Access-Control-Allow-Origin", "*"); | ||
1119 | } | 1266 | } |
1120 | else | 1267 | else |
1121 | { | 1268 | { |
@@ -1160,7 +1307,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1160 | 1307 | ||
1161 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); | 1308 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); |
1162 | 1309 | ||
1163 | response.SendChunked = false; | ||
1164 | response.ContentLength64 = buffer.Length; | 1310 | response.ContentLength64 = buffer.Length; |
1165 | response.ContentEncoding = Encoding.UTF8; | 1311 | response.ContentEncoding = Encoding.UTF8; |
1166 | 1312 | ||
@@ -1245,7 +1391,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1245 | } | 1391 | } |
1246 | } | 1392 | } |
1247 | 1393 | ||
1248 | response.KeepAlive = true; | ||
1249 | string responseData = string.Empty; | 1394 | string responseData = string.Empty; |
1250 | 1395 | ||
1251 | responseData = jsonRpcResponse.Serialize(); | 1396 | responseData = jsonRpcResponse.Serialize(); |
@@ -1257,6 +1402,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1257 | private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response) | 1402 | private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response) |
1258 | { | 1403 | { |
1259 | //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); | 1404 | //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); |
1405 | bool notfound = false; | ||
1406 | |||
1260 | Stream requestStream = request.InputStream; | 1407 | Stream requestStream = request.InputStream; |
1261 | 1408 | ||
1262 | string requestBody; | 1409 | string requestBody; |
@@ -1265,7 +1412,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1265 | requestBody= reader.ReadToEnd(); | 1412 | requestBody= reader.ReadToEnd(); |
1266 | 1413 | ||
1267 | //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); | 1414 | //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); |
1268 | response.KeepAlive = true; | ||
1269 | 1415 | ||
1270 | OSD llsdRequest = null; | 1416 | OSD llsdRequest = null; |
1271 | OSD llsdResponse = null; | 1417 | OSD llsdResponse = null; |
@@ -1308,13 +1454,20 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1308 | else | 1454 | else |
1309 | { | 1455 | { |
1310 | // Oops, no handler for this.. give em the failed message | 1456 | // Oops, no handler for this.. give em the failed message |
1311 | llsdResponse = GenerateNoLLSDHandlerResponse(); | 1457 | notfound = true; |
1312 | } | 1458 | } |
1313 | } | 1459 | } |
1314 | } | 1460 | } |
1315 | else | 1461 | else |
1316 | { | 1462 | { |
1317 | llsdResponse = GenerateNoLLSDHandlerResponse(); | 1463 | notfound = true; |
1464 | } | ||
1465 | |||
1466 | if(notfound) | ||
1467 | { | ||
1468 | response.StatusCode = (int)HttpStatusCode.NotFound; | ||
1469 | response.StatusDescription = "Not found"; | ||
1470 | return null; | ||
1318 | } | 1471 | } |
1319 | 1472 | ||
1320 | byte[] buffer = new byte[0]; | 1473 | byte[] buffer = new byte[0]; |
@@ -1333,10 +1486,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1333 | buffer = BuildLLSDResponse(request, response, llsdResponse); | 1486 | buffer = BuildLLSDResponse(request, response, llsdResponse); |
1334 | } | 1487 | } |
1335 | 1488 | ||
1336 | response.SendChunked = false; | ||
1337 | response.ContentLength64 = buffer.Length; | 1489 | response.ContentLength64 = buffer.Length; |
1338 | response.ContentEncoding = Encoding.UTF8; | 1490 | response.ContentEncoding = Encoding.UTF8; |
1339 | response.KeepAlive = true; | ||
1340 | 1491 | ||
1341 | return buffer; | 1492 | return buffer; |
1342 | } | 1493 | } |
@@ -1541,15 +1692,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1541 | } | 1692 | } |
1542 | } | 1693 | } |
1543 | 1694 | ||
1544 | private OSDMap GenerateNoLLSDHandlerResponse() | ||
1545 | { | ||
1546 | OSDMap map = new OSDMap(); | ||
1547 | map["reason"] = OSD.FromString("LLSDRequest"); | ||
1548 | map["message"] = OSD.FromString("No handler registered for LLSD Requests"); | ||
1549 | map["login"] = OSD.FromString("false"); | ||
1550 | return map; | ||
1551 | } | ||
1552 | |||
1553 | public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) | 1695 | public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) |
1554 | { | 1696 | { |
1555 | // m_log.DebugFormat( | 1697 | // m_log.DebugFormat( |
@@ -1559,6 +1701,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1559 | switch (request.HttpMethod) | 1701 | switch (request.HttpMethod) |
1560 | { | 1702 | { |
1561 | case "OPTIONS": | 1703 | case "OPTIONS": |
1704 | response.AddHeader("Access-Control-Allow-Origin", "*"); | ||
1705 | response.AddHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS"); | ||
1706 | response.AddHeader("Access-Control-Allow-Headers", "Content-Type"); | ||
1562 | response.StatusCode = (int)OSHttpStatusCode.SuccessOk; | 1707 | response.StatusCode = (int)OSHttpStatusCode.SuccessOk; |
1563 | return null; | 1708 | return null; |
1564 | 1709 | ||
@@ -1781,20 +1926,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1781 | { | 1926 | { |
1782 | response.ProtocolVersion = (string)responsedata["http_protocol_version"]; | 1927 | response.ProtocolVersion = (string)responsedata["http_protocol_version"]; |
1783 | } | 1928 | } |
1784 | /* | 1929 | |
1785 | if (responsedata.ContainsKey("keepalive")) | 1930 | if (responsedata.ContainsKey("keepalive")) |
1786 | { | 1931 | { |
1787 | bool keepalive = (bool)responsedata["keepalive"]; | 1932 | bool keepalive = (bool)responsedata["keepalive"]; |
1788 | response.KeepAlive = keepalive; | 1933 | response.KeepAlive = keepalive; |
1789 | } | 1934 | } |
1790 | 1935 | ||
1791 | if (responsedata.ContainsKey("reusecontext")) | ||
1792 | response.ReuseContext = (bool) responsedata["reusecontext"]; | ||
1793 | */ | ||
1794 | // disable this things | ||
1795 | response.KeepAlive = false; | ||
1796 | response.ReuseContext = false; | ||
1797 | |||
1798 | // Cross-Origin Resource Sharing with simple requests | 1936 | // Cross-Origin Resource Sharing with simple requests |
1799 | if (responsedata.ContainsKey("access_control_allow_origin")) | 1937 | if (responsedata.ContainsKey("access_control_allow_origin")) |
1800 | response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]); | 1938 | response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]); |
@@ -1807,11 +1945,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1807 | contentType = "text/html"; | 1945 | contentType = "text/html"; |
1808 | } | 1946 | } |
1809 | 1947 | ||
1810 | |||
1811 | |||
1812 | // The client ignores anything but 200 here for web login, so ensure that this is 200 for that | 1948 | // The client ignores anything but 200 here for web login, so ensure that this is 200 for that |
1813 | 1949 | ||
1814 | |||
1815 | response.StatusCode = responsecode; | 1950 | response.StatusCode = responsecode; |
1816 | 1951 | ||
1817 | if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) | 1952 | if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) |
@@ -1821,7 +1956,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1821 | } | 1956 | } |
1822 | 1957 | ||
1823 | response.AddHeader("Content-Type", contentType); | 1958 | response.AddHeader("Content-Type", contentType); |
1824 | |||
1825 | if (responsedata.ContainsKey("headers")) | 1959 | if (responsedata.ContainsKey("headers")) |
1826 | { | 1960 | { |
1827 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | 1961 | Hashtable headerdata = (Hashtable)responsedata["headers"]; |
@@ -1840,10 +1974,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1840 | { | 1974 | { |
1841 | if (!(contentType.Contains("image") | 1975 | if (!(contentType.Contains("image") |
1842 | || contentType.Contains("x-shockwave-flash") | 1976 | || contentType.Contains("x-shockwave-flash") |
1843 | || contentType.Contains("application/gzip") | ||
1844 | || contentType.Contains("application/pdf") | ||
1845 | || contentType.Contains("application/zip") | ||
1846 | || contentType.Contains("application/x-xz") | ||
1847 | || contentType.Contains("application/x-oar") | 1977 | || contentType.Contains("application/x-oar") |
1848 | || contentType.Contains("application/vnd.ll.mesh"))) | 1978 | || contentType.Contains("application/vnd.ll.mesh"))) |
1849 | { | 1979 | { |
@@ -1856,7 +1986,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1856 | buffer = Convert.FromBase64String(responseString); | 1986 | buffer = Convert.FromBase64String(responseString); |
1857 | } | 1987 | } |
1858 | 1988 | ||
1859 | response.SendChunked = false; | ||
1860 | response.ContentLength64 = buffer.Length; | 1989 | response.ContentLength64 = buffer.Length; |
1861 | response.ContentEncoding = Encoding.UTF8; | 1990 | response.ContentEncoding = Encoding.UTF8; |
1862 | } | 1991 | } |
@@ -1873,7 +2002,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1873 | string responseString = GetHTTP404(host); | 2002 | string responseString = GetHTTP404(host); |
1874 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); | 2003 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); |
1875 | 2004 | ||
1876 | response.SendChunked = false; | ||
1877 | response.ContentLength64 = buffer.Length; | 2005 | response.ContentLength64 = buffer.Length; |
1878 | response.ContentEncoding = Encoding.UTF8; | 2006 | response.ContentEncoding = Encoding.UTF8; |
1879 | 2007 | ||
@@ -1889,17 +2017,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1889 | string responseString = GetHTTP500(); | 2017 | string responseString = GetHTTP500(); |
1890 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); | 2018 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); |
1891 | 2019 | ||
1892 | response.SendChunked = false; | ||
1893 | response.ContentLength64 = buffer.Length; | 2020 | response.ContentLength64 = buffer.Length; |
1894 | response.ContentEncoding = Encoding.UTF8; | 2021 | response.ContentEncoding = Encoding.UTF8; |
1895 | 2022 | ||
1896 | |||
1897 | return buffer; | 2023 | return buffer; |
1898 | } | 2024 | } |
1899 | 2025 | ||
1900 | public void Start() | 2026 | public void Start() |
1901 | { | 2027 | { |
1902 | Start(true); | 2028 | Start(true, true); |
1903 | } | 2029 | } |
1904 | 2030 | ||
1905 | /// <summary> | 2031 | /// <summary> |
@@ -1909,7 +2035,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1909 | /// If true then poll responses are performed asynchronsly. | 2035 | /// If true then poll responses are performed asynchronsly. |
1910 | /// Option exists to allow regression tests to perform processing synchronously. | 2036 | /// Option exists to allow regression tests to perform processing synchronously. |
1911 | /// </param> | 2037 | /// </param> |
1912 | public void Start(bool performPollResponsesAsync) | 2038 | public void Start(bool performPollResponsesAsync, bool runPool) |
1913 | { | 2039 | { |
1914 | m_log.InfoFormat( | 2040 | m_log.InfoFormat( |
1915 | "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); | 2041 | "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); |
@@ -1938,6 +2064,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1938 | //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); | 2064 | //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); |
1939 | //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | 2065 | //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); |
1940 | m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); | 2066 | m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); |
2067 | if(m_certificateValidationCallback != null) | ||
2068 | m_httpListener2.CertificateValidationCallback = m_certificateValidationCallback; | ||
1941 | m_httpListener2.ExceptionThrown += httpServerException; | 2069 | m_httpListener2.ExceptionThrown += httpServerException; |
1942 | m_httpListener2.LogWriter = httpserverlog; | 2070 | m_httpListener2.LogWriter = httpserverlog; |
1943 | } | 2071 | } |
@@ -1946,10 +2074,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1946 | //m_httpListener.Start(); | 2074 | //m_httpListener.Start(); |
1947 | m_httpListener2.Start(64); | 2075 | m_httpListener2.Start(64); |
1948 | 2076 | ||
1949 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 2077 | lock(m_generalLock) |
1950 | 2078 | { | |
1951 | PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); | 2079 | if (runPool) |
1952 | PollServiceRequestManager.Start(); | 2080 | { |
2081 | if(m_pollServiceManager == null) | ||
2082 | m_pollServiceManager = new PollServiceRequestManager(performPollResponsesAsync, 2, 25000); | ||
2083 | m_pollServiceManager.Start(); | ||
2084 | } | ||
2085 | } | ||
1953 | 2086 | ||
1954 | HTTPDRunning = true; | 2087 | HTTPDRunning = true; |
1955 | 2088 | ||
@@ -1963,7 +2096,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1963 | catch (Exception e) | 2096 | catch (Exception e) |
1964 | { | 2097 | { |
1965 | m_log.Error("[BASE HTTP SERVER]: Error - " + e.Message); | 2098 | m_log.Error("[BASE HTTP SERVER]: Error - " + e.Message); |
1966 | m_log.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + ", " + m_sslport + "?"); | 2099 | m_log.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); |
1967 | 2100 | ||
1968 | // We want this exception to halt the entire server since in current configurations we aren't too | 2101 | // We want this exception to halt the entire server since in current configurations we aren't too |
1969 | // useful without inbound HTTP. | 2102 | // useful without inbound HTTP. |
@@ -2002,18 +2135,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
2002 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) | 2135 | if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException")) |
2003 | return; | 2136 | return; |
2004 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); | 2137 | m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); |
2005 | /* | ||
2006 | if (HTTPDRunning)// && NotSocketErrors > 5) | ||
2007 | { | ||
2008 | Stop(); | ||
2009 | Thread.Sleep(200); | ||
2010 | StartHTTP(); | ||
2011 | m_log.Warn("[HTTPSERVER]: Died. Trying to kick....."); | ||
2012 | } | ||
2013 | */ | ||
2014 | } | 2138 | } |
2015 | 2139 | ||
2016 | public void Stop() | 2140 | public void Stop(bool stopPool = false) |
2017 | { | 2141 | { |
2018 | HTTPDRunning = false; | 2142 | HTTPDRunning = false; |
2019 | 2143 | ||
@@ -2021,8 +2145,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
2021 | 2145 | ||
2022 | try | 2146 | try |
2023 | { | 2147 | { |
2024 | if(PollServiceRequestManager != null) | 2148 | lock(m_generalLock) |
2025 | PollServiceRequestManager.Stop(); | 2149 | { |
2150 | if (stopPool && m_pollServiceManager != null) | ||
2151 | m_pollServiceManager.Stop(); | ||
2152 | } | ||
2026 | 2153 | ||
2027 | m_httpListener2.ExceptionThrown -= httpServerException; | 2154 | m_httpListener2.ExceptionThrown -= httpServerException; |
2028 | //m_httpListener2.DisconnectHandler = null; | 2155 | //m_httpListener2.DisconnectHandler = null; |
@@ -2129,17 +2256,16 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
2129 | string file = Path.Combine(".", "http_500.html"); | 2256 | string file = Path.Combine(".", "http_500.html"); |
2130 | if (!File.Exists(file)) | 2257 | if (!File.Exists(file)) |
2131 | return getDefaultHTTP500(); | 2258 | return getDefaultHTTP500(); |
2132 | 2259 | string result; | |
2133 | StreamReader sr = File.OpenText(file); | 2260 | using(StreamReader sr = File.OpenText(file)) |
2134 | string result = sr.ReadToEnd(); | 2261 | result = sr.ReadToEnd(); |
2135 | sr.Close(); | ||
2136 | return result; | 2262 | return result; |
2137 | } | 2263 | } |
2138 | 2264 | ||
2139 | // Fallback HTTP responses in case the HTTP error response files don't exist | 2265 | // Fallback HTTP responses in case the HTTP error response files don't exist |
2140 | private static string getDefaultHTTP404(string host) | 2266 | private static string getDefaultHTTP404(string host) |
2141 | { | 2267 | { |
2142 | return "<HTML><HEAD><TITLE>404 Page not found</TITLE><BODY><BR /><H1>Ooops!</H1><P>The page you requested doesn't exist.</P></BODY></HTML>"; | 2268 | return "<HTML><HEAD><TITLE>404 Page not found</TITLE><BODY><BR /><H1>Ooops!</H1><P>The page you requested doesn't exist.</P><P>If you are trying to log-in, your link parameters should have: "-loginpage http://" + host + "/?method=login -loginuri http://" + host + "/" in your link.</P><</BODY></HTML>"; |
2143 | } | 2269 | } |
2144 | 2270 | ||
2145 | private static string getDefaultHTTP500() | 2271 | private static string getDefaultHTTP500() |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs index f61b090..aba15b0 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs | |||
@@ -118,8 +118,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
118 | /// </summary> | 118 | /// </summary> |
119 | string StatusDescription { get; set; } | 119 | string StatusDescription { get; set; } |
120 | 120 | ||
121 | bool ReuseContext { get; set; } | ||
122 | |||
123 | /// <summary> | 121 | /// <summary> |
124 | /// Add a header field and content to the response. | 122 | /// Add a header field and content to the response. |
125 | /// </summary> | 123 | /// </summary> |
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index d7744fc..5a49881 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs | |||
@@ -195,6 +195,42 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | public byte[] RawBuffer | ||
199 | { | ||
200 | get | ||
201 | { | ||
202 | return _httpResponse.RawBuffer; | ||
203 | } | ||
204 | set | ||
205 | { | ||
206 | _httpResponse.RawBuffer = value; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | public int RawBufferStart | ||
211 | { | ||
212 | get | ||
213 | { | ||
214 | return _httpResponse.RawBufferStart; | ||
215 | } | ||
216 | set | ||
217 | { | ||
218 | _httpResponse.RawBufferStart = value; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | public int RawBufferLen | ||
223 | { | ||
224 | get | ||
225 | { | ||
226 | return _httpResponse.RawBufferLen; | ||
227 | } | ||
228 | set | ||
229 | { | ||
230 | _httpResponse.RawBufferLen = value; | ||
231 | } | ||
232 | } | ||
233 | |||
198 | /// <summary> | 234 | /// <summary> |
199 | /// Set a redirct location. | 235 | /// Set a redirct location. |
200 | /// </summary> | 236 | /// </summary> |
@@ -215,12 +251,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
215 | { | 251 | { |
216 | get | 252 | get |
217 | { | 253 | { |
218 | return _httpResponse.Chunked; | 254 | return _httpResponse.Chunked; |
219 | } | 255 | } |
220 | 256 | ||
221 | set | 257 | set |
222 | { | 258 | { |
223 | _httpResponse.Chunked = value; | 259 | _httpResponse.Chunked = value; |
224 | } | 260 | } |
225 | } | 261 | } |
226 | 262 | ||
@@ -257,27 +293,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
257 | } | 293 | } |
258 | } | 294 | } |
259 | 295 | ||
260 | public bool ReuseContext | ||
261 | { | ||
262 | get | ||
263 | { | ||
264 | if (_httpClientContext != null) | ||
265 | { | ||
266 | return !_httpClientContext.EndWhenDone; | ||
267 | } | ||
268 | return true; | ||
269 | } | ||
270 | set | ||
271 | { | ||
272 | if (_httpClientContext != null) | ||
273 | { | ||
274 | _httpClientContext.EndWhenDone = !value; | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | |||
279 | protected IHttpResponse _httpResponse; | 296 | protected IHttpResponse _httpResponse; |
280 | private IHttpClientContext _httpClientContext; | ||
281 | 297 | ||
282 | public OSHttpResponse() {} | 298 | public OSHttpResponse() {} |
283 | 299 | ||
@@ -295,12 +311,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
295 | public OSHttpResponse(OSHttpRequest req) | 311 | public OSHttpResponse(OSHttpRequest req) |
296 | { | 312 | { |
297 | _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest); | 313 | _httpResponse = new HttpResponse(req.IHttpClientContext, req.IHttpRequest); |
298 | _httpClientContext = req.IHttpClientContext; | 314 | |
299 | } | 315 | } |
300 | public OSHttpResponse(HttpResponse resp, IHttpClientContext clientContext) | 316 | |
317 | public OSHttpResponse(HttpResponse resp) | ||
301 | { | 318 | { |
302 | _httpResponse = resp; | 319 | _httpResponse = resp; |
303 | _httpClientContext = clientContext; | ||
304 | } | 320 | } |
305 | 321 | ||
306 | /// <summary> | 322 | /// <summary> |
@@ -320,15 +336,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
320 | /// </summary> | 336 | /// </summary> |
321 | public void Send() | 337 | public void Send() |
322 | { | 338 | { |
323 | _httpResponse.Body.Flush(); | 339 | _httpResponse.Chunked = false; |
324 | |||
325 | _httpResponse.Send(); | 340 | _httpResponse.Send(); |
326 | } | 341 | } |
327 | |||
328 | public void FreeContext() | ||
329 | { | ||
330 | if (_httpClientContext != null) | ||
331 | _httpClientContext.Close(); | ||
332 | } | ||
333 | } | 342 | } |
334 | } \ No newline at end of file | 343 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 7150aad..ed7c081 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -37,6 +37,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); | 37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); |
38 | 38 | ||
39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); | 39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); |
40 | public delegate void DropMethod(UUID requestID, UUID pId); | ||
40 | 41 | ||
41 | public class PollServiceEventArgs : EventArgs | 42 | public class PollServiceEventArgs : EventArgs |
42 | { | 43 | { |
@@ -44,6 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
44 | public GetEventsMethod GetEvents; | 45 | public GetEventsMethod GetEvents; |
45 | public NoEventsMethod NoEvents; | 46 | public NoEventsMethod NoEvents; |
46 | public RequestMethod Request; | 47 | public RequestMethod Request; |
48 | public DropMethod Drop; | ||
47 | public UUID Id; | 49 | public UUID Id; |
48 | public int TimeOutms; | 50 | public int TimeOutms; |
49 | public EventType Type; | 51 | public EventType Type; |
@@ -54,7 +56,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | LslHttp = 1, | 56 | LslHttp = 1, |
55 | Inventory = 2, | 57 | Inventory = 2, |
56 | Texture = 3, | 58 | Texture = 3, |
57 | Mesh = 4 | 59 | Mesh = 4, |
60 | Mesh2 = 5, | ||
61 | Asset = 6 | ||
58 | } | 62 | } |
59 | 63 | ||
60 | public string Url { get; set; } | 64 | public string Url { get; set; } |
@@ -73,13 +77,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
73 | RequestMethod pRequest, | 77 | RequestMethod pRequest, |
74 | string pUrl, | 78 | string pUrl, |
75 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, | 79 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, |
76 | UUID pId, int pTimeOutms) | 80 | DropMethod pDrop, UUID pId, int pTimeOutms) |
77 | { | 81 | { |
78 | Request = pRequest; | 82 | Request = pRequest; |
79 | Url = pUrl; | 83 | Url = pUrl; |
80 | HasEvents = pHasEvents; | 84 | HasEvents = pHasEvents; |
81 | GetEvents = pGetEvents; | 85 | GetEvents = pGetEvents; |
82 | NoEvents = pNoEvents; | 86 | NoEvents = pNoEvents; |
87 | Drop = pDrop; | ||
83 | Id = pId; | 88 | Id = pId; |
84 | TimeOutms = pTimeOutms; | 89 | TimeOutms = pTimeOutms; |
85 | Type = EventType.Poll; | 90 | Type = EventType.Poll; |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 60eca5f..f83b771 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -47,8 +47,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
47 | public readonly UUID RequestID; | 47 | public readonly UUID RequestID; |
48 | public int contextHash; | 48 | public int contextHash; |
49 | 49 | ||
50 | /* | ||
50 | private void GenContextHash() | 51 | private void GenContextHash() |
51 | { | 52 | { |
53 | |||
52 | Random rnd = new Random(); | 54 | Random rnd = new Random(); |
53 | contextHash = 0; | 55 | contextHash = 0; |
54 | if (Request.Headers["remote_addr"] != null) | 56 | if (Request.Headers["remote_addr"] != null) |
@@ -62,8 +64,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
62 | } | 64 | } |
63 | else | 65 | else |
64 | contextHash += rnd.Next() & 0xffff; | 66 | contextHash += rnd.Next() & 0xffff; |
65 | } | ||
66 | 67 | ||
68 | } | ||
69 | */ | ||
67 | public PollServiceHttpRequest( | 70 | public PollServiceHttpRequest( |
68 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) | 71 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) |
69 | { | 72 | { |
@@ -72,58 +75,181 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
72 | Request = pRequest; | 75 | Request = pRequest; |
73 | RequestTime = System.Environment.TickCount; | 76 | RequestTime = System.Environment.TickCount; |
74 | RequestID = UUID.Random(); | 77 | RequestID = UUID.Random(); |
75 | GenContextHash(); | 78 | // GenContextHash(); |
79 | contextHash = HttpContext.contextID; | ||
76 | } | 80 | } |
77 | 81 | ||
78 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | 82 | internal void DoHTTPGruntWork(Hashtable responsedata) |
79 | { | 83 | { |
84 | if (Request.Body.CanRead) | ||
85 | Request.Body.Dispose(); | ||
86 | |||
80 | OSHttpResponse response | 87 | OSHttpResponse response |
81 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | 88 | = new OSHttpResponse(new HttpResponse(HttpContext, Request)); |
82 | 89 | ||
83 | byte[] buffer = server.DoHTTPGruntWork(responsedata, response); | 90 | if (responsedata == null) |
91 | { | ||
92 | SendNoContentError(response); | ||
93 | return; | ||
94 | } | ||
84 | 95 | ||
85 | if(Request.Body.CanRead) | 96 | int responsecode = 200; |
86 | Request.Body.Dispose(); | 97 | string responseString = String.Empty; |
98 | string contentType; | ||
99 | byte[] buffer = null; | ||
100 | int rangeStart = 0; | ||
101 | int rangeLen = -1; | ||
87 | 102 | ||
88 | response.SendChunked = false; | 103 | try |
89 | response.ContentLength64 = buffer.Length; | 104 | { |
90 | response.ContentEncoding = Encoding.UTF8; | 105 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); |
91 | response.ReuseContext = false; | 106 | if(responsedata["int_response_code"] != null) |
107 | responsecode = (int)responsedata["int_response_code"]; | ||
108 | |||
109 | if (responsedata["bin_response_data"] != null) | ||
110 | { | ||
111 | buffer = (byte[])responsedata["bin_response_data"]; | ||
112 | responsedata["bin_response_data"] = null; | ||
113 | |||
114 | if (responsedata["bin_start"] != null) | ||
115 | rangeStart = (int)responsedata["bin_start"]; | ||
116 | |||
117 | if (responsedata["int_bytes"] != null) | ||
118 | rangeLen = (int)responsedata["int_bytes"]; | ||
119 | } | ||
120 | else | ||
121 | responseString = (string)responsedata["str_response_string"]; | ||
122 | |||
123 | contentType = (string)responsedata["content_type"]; | ||
124 | if (responseString == null) | ||
125 | responseString = String.Empty; | ||
126 | } | ||
127 | catch | ||
128 | { | ||
129 | SendNoContentError(response); | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | if (responsedata.ContainsKey("error_status_text")) | ||
134 | response.StatusDescription = (string)responsedata["error_status_text"]; | ||
135 | |||
136 | if (responsedata.ContainsKey("http_protocol_version")) | ||
137 | response.ProtocolVersion = (string)responsedata["http_protocol_version"]; | ||
138 | |||
139 | if (responsedata.ContainsKey("keepalive")) | ||
140 | response.KeepAlive = (bool)responsedata["keepalive"]; | ||
141 | |||
142 | // Cross-Origin Resource Sharing with simple requests | ||
143 | if (responsedata.ContainsKey("access_control_allow_origin")) | ||
144 | response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]); | ||
145 | |||
146 | response.StatusCode = responsecode; | ||
147 | |||
148 | if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) | ||
149 | { | ||
150 | response.RedirectLocation = (string)responsedata["str_redirect_location"]; | ||
151 | } | ||
152 | |||
153 | if (string.IsNullOrEmpty(contentType)) | ||
154 | response.AddHeader("Content-Type", "text/html"); | ||
155 | else | ||
156 | response.AddHeader("Content-Type", contentType); | ||
157 | |||
158 | if (responsedata.ContainsKey("headers")) | ||
159 | { | ||
160 | Hashtable headerdata = (Hashtable)responsedata["headers"]; | ||
161 | |||
162 | foreach (string header in headerdata.Keys) | ||
163 | response.AddHeader(header, headerdata[header].ToString()); | ||
164 | } | ||
165 | |||
166 | if(buffer == null) | ||
167 | { | ||
168 | if (!(contentType.Contains("image") | ||
169 | || contentType.Contains("x-shockwave-flash") | ||
170 | || contentType.Contains("application/x-oar") | ||
171 | || contentType.Contains("application/vnd.ll.mesh"))) | ||
172 | { | ||
173 | // Text | ||
174 | buffer = Encoding.UTF8.GetBytes(responseString); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | // Binary! | ||
179 | buffer = Convert.FromBase64String(responseString); | ||
180 | } | ||
181 | response.ContentEncoding = Encoding.UTF8; | ||
182 | } | ||
183 | |||
184 | if (rangeStart < 0 || rangeStart > buffer.Length) | ||
185 | rangeStart = 0; | ||
186 | |||
187 | if (rangeLen < 0) | ||
188 | rangeLen = buffer.Length; | ||
189 | else if (rangeLen + rangeStart > buffer.Length) | ||
190 | rangeLen = buffer.Length - rangeStart; | ||
191 | |||
192 | response.ContentLength64 = rangeLen; | ||
92 | 193 | ||
93 | try | 194 | try |
94 | { | 195 | { |
95 | response.OutputStream.Write(buffer, 0, buffer.Length); | 196 | if(rangeLen > 0) |
96 | response.OutputStream.Flush(); | 197 | { |
97 | response.Send(); | 198 | response.RawBufferStart = rangeStart; |
199 | response.RawBufferLen = rangeLen; | ||
200 | response.RawBuffer = buffer; | ||
201 | //response.OutputStream.Write(buffer, rangeStart, rangeLen); | ||
202 | } | ||
203 | |||
98 | buffer = null; | 204 | buffer = null; |
205 | |||
206 | response.Send(); | ||
207 | response.RawBuffer = null; | ||
99 | } | 208 | } |
100 | catch (Exception ex) | 209 | catch (Exception ex) |
101 | { | 210 | { |
102 | m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", ex); | 211 | if(ex is System.Net.Sockets.SocketException) |
212 | { | ||
213 | // only mute connection reset by peer so we are not totally blind for now | ||
214 | if(((System.Net.Sockets.SocketException)ex).SocketErrorCode != System.Net.Sockets.SocketError.ConnectionReset) | ||
215 | m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", ex); | ||
216 | } | ||
217 | else | ||
218 | m_log.Warn("[POLL SERVICE WORKER THREAD]: Error ", ex); | ||
103 | } | 219 | } |
104 | 220 | ||
105 | PollServiceArgs.RequestsHandled++; | 221 | PollServiceArgs.RequestsHandled++; |
106 | } | 222 | } |
107 | 223 | ||
108 | internal void DoHTTPstop(BaseHttpServer server) | 224 | internal void SendNoContentError(OSHttpResponse response) |
225 | { | ||
226 | response.ContentLength64 = 0; | ||
227 | response.ContentEncoding = Encoding.UTF8; | ||
228 | response.StatusCode = 500; | ||
229 | |||
230 | try | ||
231 | { | ||
232 | response.Send(); | ||
233 | } | ||
234 | catch { } | ||
235 | return; | ||
236 | } | ||
237 | |||
238 | internal void DoHTTPstop() | ||
109 | { | 239 | { |
110 | OSHttpResponse response | 240 | OSHttpResponse response |
111 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | 241 | = new OSHttpResponse(new HttpResponse(HttpContext, Request)); |
112 | 242 | ||
113 | if(Request.Body.CanRead) | 243 | if(Request.Body.CanRead) |
114 | Request.Body.Dispose(); | 244 | Request.Body.Dispose(); |
115 | 245 | ||
116 | response.SendChunked = false; | ||
117 | response.ContentLength64 = 0; | 246 | response.ContentLength64 = 0; |
118 | response.ContentEncoding = Encoding.UTF8; | 247 | response.ContentEncoding = Encoding.UTF8; |
119 | response.ReuseContext = false; | ||
120 | response.KeepAlive = false; | 248 | response.KeepAlive = false; |
121 | response.SendChunked = false; | ||
122 | response.StatusCode = 503; | 249 | response.StatusCode = 503; |
123 | 250 | ||
124 | try | 251 | try |
125 | { | 252 | { |
126 | response.OutputStream.Flush(); | ||
127 | response.Send(); | 253 | response.Send(); |
128 | } | 254 | } |
129 | catch | 255 | catch |
@@ -131,20 +257,4 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
131 | } | 257 | } |
132 | } | 258 | } |
133 | } | 259 | } |
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; | ||
148 | } | ||
149 | } | ||
150 | } \ No newline at end of file | 260 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c6a3e65..790aa99 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -1,4 +1,4 @@ | |||
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 | * |
@@ -30,13 +30,10 @@ using System.Collections; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using HttpServer; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Monitoring; | 33 | using OpenSim.Framework.Monitoring; |
36 | using Amib.Threading; | 34 | using Amib.Threading; |
37 | using System.IO; | ||
38 | using System.Text; | ||
39 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Collections.Concurrent; | ||
40 | 37 | ||
41 | namespace OpenSim.Framework.Servers.HttpServer | 38 | namespace OpenSim.Framework.Servers.HttpServer |
42 | { | 39 | { |
@@ -44,11 +41,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
44 | { | 41 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 43 | ||
47 | private readonly BaseHttpServer m_server; | 44 | private Dictionary<int, Queue<PollServiceHttpRequest>> m_bycontext; |
48 | 45 | private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>(); | |
49 | private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext; | 46 | private ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>(); |
50 | private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); | ||
51 | private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>(); | ||
52 | 47 | ||
53 | private uint m_WorkerThreadCount = 0; | 48 | private uint m_WorkerThreadCount = 0; |
54 | private Thread[] m_workerThreads; | 49 | private Thread[] m_workerThreads; |
@@ -59,14 +54,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
59 | private SmartThreadPool m_threadPool; | 54 | private SmartThreadPool m_threadPool; |
60 | 55 | ||
61 | public PollServiceRequestManager( | 56 | public PollServiceRequestManager( |
62 | BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) | 57 | bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout) |
63 | { | 58 | { |
64 | m_server = pSrv; | ||
65 | m_WorkerThreadCount = pWorkerThreadCount; | 59 | m_WorkerThreadCount = pWorkerThreadCount; |
66 | m_workerThreads = new Thread[m_WorkerThreadCount]; | 60 | m_workerThreads = new Thread[m_WorkerThreadCount]; |
67 | 61 | ||
68 | PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer(); | 62 | m_bycontext = new Dictionary<int, Queue<PollServiceHttpRequest>>(256); |
69 | m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp); | ||
70 | 63 | ||
71 | STPStartInfo startInfo = new STPStartInfo(); | 64 | STPStartInfo startInfo = new STPStartInfo(); |
72 | startInfo.IdleTimeout = 30000; | 65 | startInfo.IdleTimeout = 30000; |
@@ -81,6 +74,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
81 | 74 | ||
82 | public void Start() | 75 | public void Start() |
83 | { | 76 | { |
77 | if(m_running) | ||
78 | return; | ||
84 | m_running = true; | 79 | m_running = true; |
85 | m_threadPool.Start(); | 80 | m_threadPool.Start(); |
86 | //startup worker threads | 81 | //startup worker threads |
@@ -89,7 +84,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
89 | m_workerThreads[i] | 84 | m_workerThreads[i] |
90 | = WorkManager.StartThread( | 85 | = WorkManager.StartThread( |
91 | PoolWorkerJob, | 86 | PoolWorkerJob, |
92 | string.Format("PollServiceWorkerThread {0}:{1}", i, m_server.Port), | 87 | string.Format("PollServiceWorkerThread {0}", i), |
93 | ThreadPriority.Normal, | 88 | ThreadPriority.Normal, |
94 | true, | 89 | true, |
95 | false, | 90 | false, |
@@ -99,38 +94,34 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
99 | 94 | ||
100 | m_retrysThread = WorkManager.StartThread( | 95 | m_retrysThread = WorkManager.StartThread( |
101 | this.CheckRetries, | 96 | this.CheckRetries, |
102 | string.Format("PollServiceWatcherThread:{0}", m_server.Port), | 97 | string.Format("PollServiceWatcherThread"), |
103 | ThreadPriority.Normal, | 98 | ThreadPriority.Normal, |
104 | true, | 99 | true, |
105 | true, | 100 | true, |
106 | null, | 101 | null, |
107 | 1000 * 60 * 10); | 102 | 1000 * 60 * 10); |
108 | |||
109 | |||
110 | } | 103 | } |
111 | 104 | ||
112 | private void ReQueueEvent(PollServiceHttpRequest req) | 105 | private void ReQueueEvent(PollServiceHttpRequest req) |
113 | { | 106 | { |
114 | if (m_running) | 107 | if (m_running) |
115 | { | 108 | m_retryRequests.Enqueue(req); |
116 | lock (m_retryRequests) | ||
117 | m_retryRequests.Enqueue(req); | ||
118 | } | ||
119 | } | 109 | } |
120 | 110 | ||
121 | public void Enqueue(PollServiceHttpRequest req) | 111 | public void Enqueue(PollServiceHttpRequest req) |
122 | { | 112 | { |
113 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
114 | int rhash = req.contextHash; | ||
123 | lock (m_bycontext) | 115 | lock (m_bycontext) |
124 | { | 116 | { |
125 | Queue<PollServiceHttpRequest> ctxQeueue; | 117 | if (m_bycontext.TryGetValue(rhash, out ctxQeueue)) |
126 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | ||
127 | { | 118 | { |
128 | ctxQeueue.Enqueue(req); | 119 | ctxQeueue.Enqueue(req); |
129 | } | 120 | } |
130 | else | 121 | else |
131 | { | 122 | { |
132 | ctxQeueue = new Queue<PollServiceHttpRequest>(); | 123 | ctxQeueue = new Queue<PollServiceHttpRequest>(); |
133 | m_bycontext[req] = ctxQeueue; | 124 | m_bycontext[rhash] = ctxQeueue; |
134 | EnqueueInt(req); | 125 | EnqueueInt(req); |
135 | } | 126 | } |
136 | } | 127 | } |
@@ -139,9 +130,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
139 | public void byContextDequeue(PollServiceHttpRequest req) | 130 | public void byContextDequeue(PollServiceHttpRequest req) |
140 | { | 131 | { |
141 | Queue<PollServiceHttpRequest> ctxQeueue; | 132 | Queue<PollServiceHttpRequest> ctxQeueue; |
133 | int rhash = req.contextHash; | ||
142 | lock (m_bycontext) | 134 | lock (m_bycontext) |
143 | { | 135 | { |
144 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | 136 | if (m_bycontext.TryGetValue(rhash, out ctxQeueue)) |
145 | { | 137 | { |
146 | if (ctxQeueue.Count > 0) | 138 | if (ctxQeueue.Count > 0) |
147 | { | 139 | { |
@@ -150,35 +142,49 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
150 | } | 142 | } |
151 | else | 143 | else |
152 | { | 144 | { |
153 | m_bycontext.Remove(req); | 145 | m_bycontext.Remove(rhash); |
154 | } | 146 | } |
155 | } | 147 | } |
156 | } | 148 | } |
157 | } | 149 | } |
158 | 150 | ||
151 | public void DropByContext(PollServiceHttpRequest req) | ||
152 | { | ||
153 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
154 | int rhash = req.contextHash; | ||
155 | lock (m_bycontext) | ||
156 | { | ||
157 | if (m_bycontext.TryGetValue(rhash, out ctxQeueue)) | ||
158 | { | ||
159 | ctxQeueue.Clear(); | ||
160 | m_bycontext.Remove(rhash); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | |||
159 | public void EnqueueInt(PollServiceHttpRequest req) | 165 | public void EnqueueInt(PollServiceHttpRequest req) |
160 | { | 166 | { |
161 | if (m_running) | 167 | if (m_running) |
162 | m_requests.Enqueue(req); | 168 | m_requests.Add(req); |
163 | } | 169 | } |
164 | 170 | ||
165 | private void CheckRetries() | 171 | private void CheckRetries() |
166 | { | 172 | { |
173 | PollServiceHttpRequest preq; | ||
167 | while (m_running) | 174 | while (m_running) |
168 | |||
169 | { | 175 | { |
170 | Thread.Sleep(100); // let the world move .. back to faster rate | 176 | Thread.Sleep(100); |
171 | Watchdog.UpdateThread(); | 177 | Watchdog.UpdateThread(); |
172 | lock (m_retryRequests) | 178 | while (m_running && m_retryRequests.TryDequeue(out preq)) |
173 | { | 179 | m_requests.Add(preq); |
174 | while (m_retryRequests.Count > 0 && m_running) | ||
175 | m_requests.Enqueue(m_retryRequests.Dequeue()); | ||
176 | } | ||
177 | } | 180 | } |
178 | } | 181 | } |
179 | 182 | ||
180 | public void Stop() | 183 | public void Stop() |
181 | { | 184 | { |
185 | if(!m_running) | ||
186 | return; | ||
187 | |||
182 | m_running = false; | 188 | m_running = false; |
183 | 189 | ||
184 | Thread.Sleep(100); // let the world move | 190 | Thread.Sleep(100); // let the world move |
@@ -194,103 +200,123 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
194 | qu.Clear(); | 200 | qu.Clear(); |
195 | m_bycontext.Clear(); | 201 | m_bycontext.Clear(); |
196 | 202 | ||
203 | PollServiceHttpRequest req; | ||
197 | try | 204 | try |
198 | { | 205 | { |
199 | foreach (PollServiceHttpRequest req in m_retryRequests) | 206 | while(m_retryRequests.TryDequeue(out req)) |
200 | { | 207 | req.DoHTTPstop(); |
201 | req.DoHTTPstop(m_server); | ||
202 | } | ||
203 | } | 208 | } |
204 | catch | 209 | catch |
205 | { | 210 | { |
206 | } | 211 | } |
207 | 212 | ||
208 | PollServiceHttpRequest wreq; | 213 | try |
209 | 214 | { | |
210 | m_retryRequests.Clear(); | 215 | while(m_requests.TryTake(out req, 0)) |
211 | 216 | req.DoHTTPstop(); | |
212 | while (m_requests.Count() > 0) | 217 | } |
218 | catch | ||
213 | { | 219 | { |
214 | try | ||
215 | { | ||
216 | wreq = m_requests.Dequeue(0); | ||
217 | wreq.DoHTTPstop(m_server); | ||
218 | } | ||
219 | catch | ||
220 | { | ||
221 | } | ||
222 | } | 220 | } |
223 | 221 | ||
224 | m_requests.Clear(); | 222 | m_requests.Dispose(); |
223 | |||
225 | } | 224 | } |
226 | 225 | ||
227 | // work threads | 226 | // work threads |
228 | 227 | ||
229 | private void PoolWorkerJob() | 228 | private void PoolWorkerJob() |
230 | { | 229 | { |
230 | PollServiceHttpRequest req; | ||
231 | while (m_running) | 231 | while (m_running) |
232 | { | 232 | { |
233 | PollServiceHttpRequest req = m_requests.Dequeue(4500); | 233 | try |
234 | Watchdog.UpdateThread(); | ||
235 | if (req != null) | ||
236 | { | 234 | { |
237 | try | 235 | req = null; |
236 | if (!m_requests.TryTake(out req, 4500) || req == null) | ||
238 | { | 237 | { |
239 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 238 | Watchdog.UpdateThread(); |
239 | continue; | ||
240 | } | ||
241 | |||
242 | Watchdog.UpdateThread(); | ||
243 | |||
244 | if (!req.HttpContext.CanSend()) | ||
245 | { | ||
246 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); | ||
247 | byContextDequeue(req); | ||
248 | continue; | ||
249 | } | ||
250 | |||
251 | if (req.HttpContext.IsSending()) | ||
252 | { | ||
253 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
240 | { | 254 | { |
241 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 255 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
256 | byContextDequeue(req); | ||
257 | } | ||
258 | else | ||
259 | ReQueueEvent(req); | ||
260 | continue; | ||
261 | } | ||
242 | 262 | ||
263 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
264 | { | ||
265 | PollServiceHttpRequest nreq = req; | ||
266 | m_threadPool.QueueWorkItem(x => | ||
267 | { | ||
268 | try | ||
269 | { | ||
270 | Hashtable responsedata = nreq.PollServiceArgs.GetEvents(nreq.RequestID, nreq.PollServiceArgs.Id); | ||
271 | nreq.DoHTTPGruntWork(responsedata); | ||
272 | } | ||
273 | catch (ObjectDisposedException) { } | ||
274 | finally | ||
275 | { | ||
276 | byContextDequeue(nreq); | ||
277 | nreq = null; | ||
278 | } | ||
279 | return null; | ||
280 | }, null); | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
285 | { | ||
286 | PollServiceHttpRequest nreq = req; | ||
243 | m_threadPool.QueueWorkItem(x => | 287 | m_threadPool.QueueWorkItem(x => |
244 | { | 288 | { |
245 | try | 289 | try |
246 | { | 290 | { |
247 | req.DoHTTPGruntWork(m_server, responsedata); | 291 | nreq.DoHTTPGruntWork(nreq.PollServiceArgs.NoEvents(nreq.RequestID, nreq.PollServiceArgs.Id)); |
248 | } | ||
249 | catch (ObjectDisposedException) | ||
250 | { | ||
251 | } | 292 | } |
293 | catch (ObjectDisposedException) { } | ||
252 | finally | 294 | finally |
253 | { | 295 | { |
254 | byContextDequeue(req); | 296 | byContextDequeue(nreq); |
297 | nreq = null; | ||
255 | } | 298 | } |
256 | return null; | 299 | return null; |
257 | }, null); | 300 | }, null); |
258 | } | 301 | } |
259 | else | 302 | else |
260 | { | 303 | { |
261 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 304 | ReQueueEvent(req); |
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 | } | ||
285 | } | 305 | } |
286 | } | 306 | } |
287 | catch (Exception e) | 307 | } |
288 | { | 308 | catch (ThreadAbortException) |
289 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 309 | { |
290 | } | 310 | Thread.ResetAbort(); |
311 | // Shouldn't set this to 'false', the normal shutdown should cause things to exit | ||
312 | // but robust is still not normal neither is mono | ||
313 | m_running = false; | ||
314 | } | ||
315 | catch (Exception e) | ||
316 | { | ||
317 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | ||
291 | } | 318 | } |
292 | } | 319 | } |
293 | } | 320 | } |
294 | |||
295 | } | 321 | } |
296 | } | 322 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs index 67fc14e..bd55657 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs | |||
@@ -54,8 +54,6 @@ 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 | |||
59 | XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); | 57 | XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); |
60 | deserial = (TRequest) deserializer.Deserialize(xmlReader); | 58 | deserial = (TRequest) deserializer.Deserialize(xmlReader); |
61 | } | 59 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 158befa..68073c1 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | |||
@@ -210,8 +210,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
210 | { | 210 | { |
211 | try | 211 | try |
212 | { | 212 | { |
213 | xmlReader.ProhibitDtd = true; | ||
214 | |||
215 | XmlSerializer deserializer = new XmlSerializer(typeof(RestSessionObject<TRequest>)); | 213 | XmlSerializer deserializer = new XmlSerializer(typeof(RestSessionObject<TRequest>)); |
216 | deserial = (RestSessionObject<TRequest>)deserializer.Deserialize(xmlReader); | 214 | deserial = (RestSessionObject<TRequest>)deserializer.Deserialize(xmlReader); |
217 | } | 215 | } |
@@ -271,8 +269,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
271 | { | 269 | { |
272 | try | 270 | try |
273 | { | 271 | { |
274 | xmlReader.ProhibitDtd = true; | ||
275 | |||
276 | XmlSerializer deserializer = new XmlSerializer(typeof(TRequest)); | 272 | XmlSerializer deserializer = new XmlSerializer(typeof(TRequest)); |
277 | deserial = (TRequest)deserializer.Deserialize(xmlReader); | 273 | deserial = (TRequest)deserializer.Deserialize(xmlReader); |
278 | } | 274 | } |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 9b1d906..a42ff83 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -42,6 +42,7 @@ namespace OpenSim.Framework.Servers | |||
42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private static BaseHttpServer instance = null; | 44 | private static BaseHttpServer instance = null; |
45 | private static BaseHttpServer unsecureinstance = null; | ||
45 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); | 46 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); |
46 | 47 | ||
47 | /// <summary> | 48 | /// <summary> |
@@ -86,10 +87,26 @@ namespace OpenSim.Framework.Servers | |||
86 | set | 87 | set |
87 | { | 88 | { |
88 | lock (m_Servers) | 89 | lock (m_Servers) |
90 | { | ||
91 | if (!m_Servers.ContainsValue(value)) | ||
92 | throw new Exception("HTTP server must already have been registered to be set as the main instance"); | ||
93 | |||
94 | instance = value; | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public static BaseHttpServer UnSecureInstance | ||
100 | { | ||
101 | get { return unsecureinstance; } | ||
102 | |||
103 | set | ||
104 | { | ||
105 | lock (m_Servers) | ||
89 | if (!m_Servers.ContainsValue(value)) | 106 | if (!m_Servers.ContainsValue(value)) |
90 | throw new Exception("HTTP server must already have been registered to be set as the main instance"); | 107 | throw new Exception("HTTP server must already have been registered to be set as the main instance"); |
91 | 108 | ||
92 | instance = value; | 109 | unsecureinstance = value; |
93 | } | 110 | } |
94 | } | 111 | } |
95 | 112 | ||
@@ -175,35 +192,35 @@ namespace OpenSim.Framework.Servers | |||
175 | 192 | ||
176 | if (!int.TryParse(rawNewDebug, out newDebug)) | 193 | if (!int.TryParse(rawNewDebug, out newDebug)) |
177 | { | 194 | { |
178 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); | 195 | MainConsole.Instance.Output("{0} is not a valid debug level", rawNewDebug); |
179 | return; | 196 | return; |
180 | } | 197 | } |
181 | 198 | ||
182 | if (newDebug < 0 || newDebug > 6) | 199 | if (newDebug < 0 || newDebug > 6) |
183 | { | 200 | { |
184 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); | 201 | MainConsole.Instance.Output("{0} is outside the valid debug level range of 0..6", newDebug); |
185 | return; | 202 | return; |
186 | } | 203 | } |
187 | 204 | ||
188 | if (allReqs || inReqs) | 205 | if (allReqs || inReqs) |
189 | { | 206 | { |
190 | MainServer.DebugLevel = newDebug; | 207 | MainServer.DebugLevel = newDebug; |
191 | MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); | 208 | MainConsole.Instance.Output("IN debug level set to {0}", newDebug); |
192 | } | 209 | } |
193 | 210 | ||
194 | if (allReqs || outReqs) | 211 | if (allReqs || outReqs) |
195 | { | 212 | { |
196 | WebUtil.DebugLevel = newDebug; | 213 | WebUtil.DebugLevel = newDebug; |
197 | MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); | 214 | MainConsole.Instance.Output("OUT debug level set to {0}", newDebug); |
198 | } | 215 | } |
199 | } | 216 | } |
200 | else | 217 | else |
201 | { | 218 | { |
202 | if (allReqs || inReqs) | 219 | if (allReqs || inReqs) |
203 | MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); | 220 | MainConsole.Instance.Output("Current IN debug level is {0}", DebugLevel); |
204 | 221 | ||
205 | if (allReqs || outReqs) | 222 | if (allReqs || outReqs) |
206 | MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); | 223 | MainConsole.Instance.Output("Current OUT debug level is {0}", WebUtil.DebugLevel); |
207 | } | 224 | } |
208 | } | 225 | } |
209 | 226 | ||
@@ -360,10 +377,9 @@ namespace OpenSim.Framework.Servers | |||
360 | { | 377 | { |
361 | foreach (BaseHttpServer httpServer in m_Servers.Values) | 378 | foreach (BaseHttpServer httpServer in m_Servers.Values) |
362 | { | 379 | { |
363 | httpServer.Stop(); | 380 | httpServer.Stop(true); |
364 | } | 381 | } |
365 | } | 382 | } |
366 | } | 383 | } |
367 | |||
368 | } | 384 | } |
369 | } \ No newline at end of file | 385 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 3c2dce8..81b112f 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -31,6 +31,7 @@ using System.Diagnostics; | |||
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Linq; | 32 | using System.Linq; |
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Runtime; | ||
34 | using System.Text; | 35 | using System.Text; |
35 | using System.Text.RegularExpressions; | 36 | using System.Text.RegularExpressions; |
36 | using System.Threading; | 37 | using System.Threading; |
@@ -491,24 +492,28 @@ namespace OpenSim.Framework.Servers | |||
491 | 492 | ||
492 | if (!int.TryParse(rawLevel, out newLevel)) | 493 | if (!int.TryParse(rawLevel, out newLevel)) |
493 | { | 494 | { |
494 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawLevel); | 495 | MainConsole.Instance.Output("{0} is not a valid debug level", rawLevel); |
495 | return; | 496 | return; |
496 | } | 497 | } |
497 | 498 | ||
498 | if (newLevel < 0 || newLevel > Util.MAX_THREADPOOL_LEVEL) | 499 | if (newLevel < 0 || newLevel > Util.MAX_THREADPOOL_LEVEL) |
499 | { | 500 | { |
500 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0.." + Util.MAX_THREADPOOL_LEVEL, newLevel); | 501 | MainConsole.Instance.Output("{0} is outside the valid debug level range of 0.." + Util.MAX_THREADPOOL_LEVEL, newLevel); |
501 | return; | 502 | return; |
502 | } | 503 | } |
503 | 504 | ||
504 | Util.LogThreadPool = newLevel; | 505 | Util.LogThreadPool = newLevel; |
505 | MainConsole.Instance.OutputFormat("LogThreadPool set to {0}", newLevel); | 506 | MainConsole.Instance.Output("LogThreadPool set to {0}", newLevel); |
506 | } | 507 | } |
507 | 508 | ||
508 | private void HandleForceGc(string module, string[] args) | 509 | private void HandleForceGc(string module, string[] args) |
509 | { | 510 | { |
510 | Notice("Manually invoking runtime garbage collection"); | 511 | Notice("Manually invoking runtime garbage collection"); |
512 | GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; | ||
511 | GC.Collect(); | 513 | GC.Collect(); |
514 | GC.WaitForPendingFinalizers(); | ||
515 | GC.Collect(); | ||
516 | GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.Default; | ||
512 | } | 517 | } |
513 | 518 | ||
514 | public virtual void HandleShow(string module, string[] cmd) | 519 | public virtual void HandleShow(string module, string[] cmd) |
@@ -923,9 +928,7 @@ namespace OpenSim.Framework.Servers | |||
923 | } | 928 | } |
924 | catch { } | 929 | catch { } |
925 | 930 | ||
926 | if ( | 931 | if (Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem) |
927 | Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem | ||
928 | || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
929 | { | 932 | { |
930 | sb.AppendFormat("\nThread pool used: Framework main threadpool\n"); | 933 | sb.AppendFormat("\nThread pool used: Framework main threadpool\n"); |
931 | return sb.ToString(); | 934 | return sb.ToString(); |
@@ -988,9 +991,9 @@ namespace OpenSim.Framework.Servers | |||
988 | } | 991 | } |
989 | 992 | ||
990 | if (Watchdog.AbortThread(threadId)) | 993 | if (Watchdog.AbortThread(threadId)) |
991 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); | 994 | MainConsole.Instance.Output("Aborted thread with id {0}", threadId); |
992 | else | 995 | else |
993 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); | 996 | MainConsole.Instance.Output("ERROR - Thread with id {0} not found in managed threads", threadId); |
994 | } | 997 | } |
995 | 998 | ||
996 | /// <summary> | 999 | /// <summary> |
@@ -1017,7 +1020,7 @@ namespace OpenSim.Framework.Servers | |||
1017 | protected void Notice(string format, params object[] components) | 1020 | protected void Notice(string format, params object[] components) |
1018 | { | 1021 | { |
1019 | if (m_console != null) | 1022 | if (m_console != null) |
1020 | m_console.OutputFormat(format, components); | 1023 | m_console.Output(format, components); |
1021 | } | 1024 | } |
1022 | 1025 | ||
1023 | public virtual void Shutdown() | 1026 | public virtual void Shutdown() |
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index 5cec2b5..0e5e83e 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs | |||
@@ -37,52 +37,6 @@ using log4net; | |||
37 | 37 | ||
38 | namespace OpenSim.Framework | 38 | namespace OpenSim.Framework |
39 | { | 39 | { |
40 | public abstract class TerrainData | ||
41 | { | ||
42 | // Terrain always is a square | ||
43 | public int SizeX { get; protected set; } | ||
44 | public int SizeY { get; protected set; } | ||
45 | public int SizeZ { get; protected set; } | ||
46 | |||
47 | // A height used when the user doesn't specify anything | ||
48 | public const float DefaultTerrainHeight = 21f; | ||
49 | |||
50 | public abstract float this[int x, int y] { get; set; } | ||
51 | // Someday terrain will have caves | ||
52 | // at most holes :p | ||
53 | public abstract float this[int x, int y, int z] { get; set; } | ||
54 | |||
55 | public abstract bool IsTaintedAt(int xx, int yy); | ||
56 | public abstract bool IsTaintedAt(int xx, int yy, bool clearOnTest); | ||
57 | public abstract void TaintAllTerrain(); | ||
58 | public abstract void ClearTaint(); | ||
59 | |||
60 | public abstract void ClearLand(); | ||
61 | public abstract void ClearLand(float height); | ||
62 | |||
63 | // Return a representation of this terrain for storing as a blob in the database. | ||
64 | // Returns 'true' to say blob was stored in the 'out' locations. | ||
65 | public abstract bool GetDatabaseBlob(out int DBFormatRevisionCode, out Array blob); | ||
66 | |||
67 | // Given a revision code and a blob from the database, create and return the right type of TerrainData. | ||
68 | // The sizes passed are the expected size of the region. The database info will be used to | ||
69 | // initialize the heightmap of that sized region with as much data is in the blob. | ||
70 | // Return created TerrainData or 'null' if unsuccessful. | ||
71 | public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) | ||
72 | { | ||
73 | // For the moment, there is only one implementation class | ||
74 | return new HeightmapTerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); | ||
75 | } | ||
76 | |||
77 | // return a special compressed representation of the heightmap in ushort | ||
78 | public abstract float[] GetCompressedMap(); | ||
79 | public abstract float CompressionFactor { get; } | ||
80 | |||
81 | public abstract float[] GetFloatsSerialized(); | ||
82 | public abstract double[,] GetDoubles(); | ||
83 | public abstract TerrainData Clone(); | ||
84 | } | ||
85 | |||
86 | // The terrain is stored in the database as a blob with a 'revision' field. | 40 | // The terrain is stored in the database as a blob with a 'revision' field. |
87 | // Some implementations of terrain storage would fill the revision field with | 41 | // Some implementations of terrain storage would fill the revision field with |
88 | // the time the terrain was stored. When real revisions were added and this | 42 | // the time the terrain was stored. When real revisions were added and this |
@@ -112,18 +66,37 @@ namespace OpenSim.Framework | |||
112 | RevisionHigh = 1234 | 66 | RevisionHigh = 1234 |
113 | } | 67 | } |
114 | 68 | ||
115 | // Version of terrain that is a heightmap. | 69 | public class TerrainData |
116 | // This should really be 'LLOptimizedHeightmapTerrainData' as it includes knowledge | ||
117 | // of 'patches' which are 16x16 terrain areas which can be sent separately to the viewer. | ||
118 | // The heighmap is kept as an array of ushorts. The ushort values are converted to | ||
119 | // and from floats by TerrainCompressionFactor. | ||
120 | public class HeightmapTerrainData : TerrainData | ||
121 | { | 70 | { |
122 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 71 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
123 | private static string LogHeader = "[HEIGHTMAP TERRAIN DATA]"; | 72 | private static string LogHeader = "[TERRAIN DATA]"; |
73 | |||
74 | private float[,] m_heightmap; | ||
75 | // Remember subregions of the heightmap that has changed. | ||
76 | private bool[,] m_taint; | ||
77 | |||
78 | // legacy CompressionFactor | ||
79 | public float CompressionFactor { get; private set; } | ||
80 | |||
81 | // Terrain always is a square | ||
82 | public int SizeX { get; protected set; } | ||
83 | public int SizeY { get; protected set; } | ||
84 | public int SizeZ { get; protected set; } | ||
85 | |||
86 | // A height used when the user doesn't specify anything | ||
87 | public const float DefaultTerrainHeight = 21f; | ||
88 | |||
89 | // Given a revision code and a blob from the database, create and return the right type of TerrainData. | ||
90 | // The sizes passed are the expected size of the region. The database info will be used to | ||
91 | // initialize the heightmap of that sized region with as much data is in the blob. | ||
92 | // Return created TerrainData or 'null' if unsuccessful. | ||
93 | public static TerrainData CreateFromDatabaseBlobFactory(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) | ||
94 | { | ||
95 | // For the moment, there is only one implementation class | ||
96 | return new TerrainData(pSizeX, pSizeY, pSizeZ, pFormatCode, pBlob); | ||
97 | } | ||
124 | 98 | ||
125 | // TerrainData.this[x, y] | 99 | public float this[int x, int y] |
126 | public override float this[int x, int y] | ||
127 | { | 100 | { |
128 | get { return m_heightmap[x, y]; } | 101 | get { return m_heightmap[x, y]; } |
129 | set | 102 | set |
@@ -136,21 +109,18 @@ namespace OpenSim.Framework | |||
136 | } | 109 | } |
137 | } | 110 | } |
138 | 111 | ||
139 | // TerrainData.this[x, y, z] | 112 | public float this[int x, int y, int z] |
140 | public override float this[int x, int y, int z] | ||
141 | { | 113 | { |
142 | get { return this[x, y]; } | 114 | get { return this[x, y]; } |
143 | set { this[x, y] = value; } | 115 | set { this[x, y] = value; } |
144 | } | 116 | } |
145 | 117 | ||
146 | // TerrainData.ClearTaint | 118 | public void ClearTaint() |
147 | public override void ClearTaint() | ||
148 | { | 119 | { |
149 | SetAllTaint(false); | 120 | SetAllTaint(false); |
150 | } | 121 | } |
151 | 122 | ||
152 | // TerrainData.TaintAllTerrain | 123 | public void TaintAllTerrain() |
153 | public override void TaintAllTerrain() | ||
154 | { | 124 | { |
155 | SetAllTaint(true); | 125 | SetAllTaint(true); |
156 | } | 126 | } |
@@ -162,13 +132,12 @@ namespace OpenSim.Framework | |||
162 | m_taint[ii, jj] = setting; | 132 | m_taint[ii, jj] = setting; |
163 | } | 133 | } |
164 | 134 | ||
165 | // TerrainData.ClearLand | 135 | public void ClearLand() |
166 | public override void ClearLand() | ||
167 | { | 136 | { |
168 | ClearLand(DefaultTerrainHeight); | 137 | ClearLand(DefaultTerrainHeight); |
169 | } | 138 | } |
170 | // TerrainData.ClearLand(float) | 139 | |
171 | public override void ClearLand(float pHeight) | 140 | public void ClearLand(float pHeight) |
172 | { | 141 | { |
173 | for (int xx = 0; xx < SizeX; xx++) | 142 | for (int xx = 0; xx < SizeX; xx++) |
174 | for (int yy = 0; yy < SizeY; yy++) | 143 | for (int yy = 0; yy < SizeY; yy++) |
@@ -178,7 +147,7 @@ namespace OpenSim.Framework | |||
178 | // Return 'true' of the patch that contains these region coordinates has been modified. | 147 | // Return 'true' of the patch that contains these region coordinates has been modified. |
179 | // Note that checking the taint clears it. | 148 | // Note that checking the taint clears it. |
180 | // There is existing code that relies on this feature. | 149 | // There is existing code that relies on this feature. |
181 | public override bool IsTaintedAt(int xx, int yy, bool clearOnTest) | 150 | public bool IsTaintedAt(int xx, int yy, bool clearOnTest) |
182 | { | 151 | { |
183 | int tx = xx / Constants.TerrainPatchSize; | 152 | int tx = xx / Constants.TerrainPatchSize; |
184 | int ty = yy / Constants.TerrainPatchSize; | 153 | int ty = yy / Constants.TerrainPatchSize; |
@@ -191,41 +160,22 @@ namespace OpenSim.Framework | |||
191 | // Old form that clears the taint flag when we check it. | 160 | // Old form that clears the taint flag when we check it. |
192 | // ubit: this dangerus naming should be only check without clear | 161 | // ubit: this dangerus naming should be only check without clear |
193 | // keeping for old modules outthere | 162 | // keeping for old modules outthere |
194 | public override bool IsTaintedAt(int xx, int yy) | 163 | public bool IsTaintedAt(int xx, int yy) |
195 | { | 164 | { |
196 | return IsTaintedAt(xx, yy, true /* clearOnTest */); | 165 | return IsTaintedAt(xx, yy, true /* clearOnTest */); |
197 | } | 166 | } |
198 | 167 | ||
199 | // TerrainData.GetDatabaseBlob | 168 | // TerrainData.GetDatabaseBlob |
200 | // The user wants something to store in the database. | 169 | // The user wants something to store in the database. |
201 | public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) | 170 | public bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) |
202 | { | 171 | { |
203 | bool ret = false; | 172 | DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip; |
204 | /* save all as Variable2DGzip | 173 | blob = ToCompressedTerrainSerializationV2DGzip(); |
205 | if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize) | 174 | return true; |
206 | { | ||
207 | DBRevisionCode = (int)DBTerrainRevision.Legacy256; | ||
208 | blob = ToLegacyTerrainSerialization(); | ||
209 | ret = true; | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | */ | ||
214 | DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip; | ||
215 | // DBRevisionCode = (int)DBTerrainRevision.Variable2D; | ||
216 | blob = ToCompressedTerrainSerializationV2DGzip(); | ||
217 | // blob = ToCompressedTerrainSerializationV2D(); | ||
218 | ret = true; | ||
219 | // } | ||
220 | return ret; | ||
221 | } | 175 | } |
222 | 176 | ||
223 | // TerrainData.CompressionFactor | ||
224 | private float m_compressionFactor = 100.0f; | ||
225 | public override float CompressionFactor { get { return m_compressionFactor; } } | ||
226 | |||
227 | // TerrainData.GetCompressedMap | 177 | // TerrainData.GetCompressedMap |
228 | public override float[] GetCompressedMap() | 178 | public float[] GetCompressedMap() |
229 | { | 179 | { |
230 | float[] newMap = new float[SizeX * SizeY]; | 180 | float[] newMap = new float[SizeX * SizeY]; |
231 | 181 | ||
@@ -235,21 +185,16 @@ namespace OpenSim.Framework | |||
235 | newMap[ind++] = m_heightmap[xx, yy]; | 185 | newMap[ind++] = m_heightmap[xx, yy]; |
236 | 186 | ||
237 | return newMap; | 187 | return newMap; |
238 | |||
239 | } | 188 | } |
240 | // TerrainData.Clone | 189 | |
241 | public override TerrainData Clone() | 190 | public TerrainData Clone() |
242 | { | 191 | { |
243 | HeightmapTerrainData ret = new HeightmapTerrainData(SizeX, SizeY, SizeZ); | 192 | TerrainData ret = new TerrainData(SizeX, SizeY, SizeZ); |
244 | ret.m_heightmap = (float[,])this.m_heightmap.Clone(); | 193 | ret.m_heightmap = (float[,])this.m_heightmap.Clone(); |
245 | return ret; | 194 | return ret; |
246 | } | 195 | } |
247 | 196 | ||
248 | // TerrainData.GetFloatsSerialized | 197 | public float[] GetFloatsSerialized() |
249 | // This one dimensional version is ordered so height = map[y*sizeX+x]; | ||
250 | // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain | ||
251 | // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. | ||
252 | public override float[] GetFloatsSerialized() | ||
253 | { | 198 | { |
254 | int points = SizeX * SizeY; | 199 | int points = SizeX * SizeY; |
255 | float[] heights = new float[points]; | 200 | float[] heights = new float[points]; |
@@ -264,8 +209,7 @@ namespace OpenSim.Framework | |||
264 | return heights; | 209 | return heights; |
265 | } | 210 | } |
266 | 211 | ||
267 | // TerrainData.GetDoubles | 212 | public double[,] GetDoubles() |
268 | public override double[,] GetDoubles() | ||
269 | { | 213 | { |
270 | double[,] ret = new double[SizeX, SizeY]; | 214 | double[,] ret = new double[SizeX, SizeY]; |
271 | for (int xx = 0; xx < SizeX; xx++) | 215 | for (int xx = 0; xx < SizeX; xx++) |
@@ -275,14 +219,53 @@ namespace OpenSim.Framework | |||
275 | return ret; | 219 | return ret; |
276 | } | 220 | } |
277 | 221 | ||
222 | public unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax) | ||
223 | { | ||
224 | zmax = float.MinValue; | ||
225 | zmin = float.MaxValue; | ||
278 | 226 | ||
279 | // ============================================================= | 227 | int stride = m_heightmap.GetLength(1); |
280 | 228 | ||
281 | private float[,] m_heightmap; | 229 | int startx = px * 16 * stride; |
282 | // Remember subregions of the heightmap that has changed. | 230 | int endx = (px + 1) * 16 * stride; |
283 | private bool[,] m_taint; | 231 | int starty = py * 16; |
232 | fixed (float* map = m_heightmap) | ||
233 | { | ||
234 | for (int i = startx; i < endx; i += stride) | ||
235 | { | ||
236 | float* p = &map[i]; | ||
237 | for (int j = starty; j < starty + 16; j++) | ||
238 | { | ||
239 | float val = p[j]; | ||
240 | if (val > zmax) zmax = val; | ||
241 | if (val < zmin) zmin = val; | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | public unsafe void GetPatchBlock(float[] _block, int px, int py, float sub, float premult) | ||
248 | { | ||
249 | int k = 0; | ||
250 | int stride = m_heightmap.GetLength(1); | ||
284 | 251 | ||
285 | // that is coded as the float height times the compression factor (usually '100' | 252 | int startX = px * 16 * stride; |
253 | int endX = (px + 1) * 16 * stride; | ||
254 | int startY = py * 16; | ||
255 | fixed(float* block = _block, map = m_heightmap) | ||
256 | { | ||
257 | for (int y = startY; y < startY + 16; y++) | ||
258 | { | ||
259 | for (int x = startX; x < endX; x += stride) | ||
260 | { | ||
261 | block[k++] = (map[x + y] - sub) * premult; | ||
262 | } | ||
263 | } | ||
264 | } | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | // that is coded as the float height times the compression factor (usually '100' | ||
286 | // to make for two decimal points). | 269 | // to make for two decimal points). |
287 | public short ToCompressedHeightshort(float pHeight) | 270 | public short ToCompressedHeightshort(float pHeight) |
288 | { | 271 | { |
@@ -305,6 +288,7 @@ namespace OpenSim.Framework | |||
305 | return ushort.MaxValue; | 288 | return ushort.MaxValue; |
306 | return (ushort)pHeight; | 289 | return (ushort)pHeight; |
307 | } | 290 | } |
291 | */ | ||
308 | 292 | ||
309 | public float FromCompressedHeight(short pHeight) | 293 | public float FromCompressedHeight(short pHeight) |
310 | { | 294 | { |
@@ -318,12 +302,12 @@ namespace OpenSim.Framework | |||
318 | 302 | ||
319 | // To keep with the legacy theme, create an instance of this class based on the | 303 | // To keep with the legacy theme, create an instance of this class based on the |
320 | // way terrain used to be passed around. | 304 | // way terrain used to be passed around. |
321 | public HeightmapTerrainData(double[,] pTerrain) | 305 | public TerrainData(double[,] pTerrain) |
322 | { | 306 | { |
323 | SizeX = pTerrain.GetLength(0); | 307 | SizeX = pTerrain.GetLength(0); |
324 | SizeY = pTerrain.GetLength(1); | 308 | SizeY = pTerrain.GetLength(1); |
325 | SizeZ = (int)Constants.RegionHeight; | 309 | SizeZ = (int)Constants.RegionHeight; |
326 | m_compressionFactor = 100.0f; | 310 | CompressionFactor = 100.0f; |
327 | 311 | ||
328 | m_heightmap = new float[SizeX, SizeY]; | 312 | m_heightmap = new float[SizeX, SizeY]; |
329 | for (int ii = 0; ii < SizeX; ii++) | 313 | for (int ii = 0; ii < SizeX; ii++) |
@@ -341,12 +325,12 @@ namespace OpenSim.Framework | |||
341 | } | 325 | } |
342 | 326 | ||
343 | // Create underlying structures but don't initialize the heightmap assuming the caller will immediately do that | 327 | // Create underlying structures but don't initialize the heightmap assuming the caller will immediately do that |
344 | public HeightmapTerrainData(int pX, int pY, int pZ) | 328 | public TerrainData(int pX, int pY, int pZ) |
345 | { | 329 | { |
346 | SizeX = pX; | 330 | SizeX = pX; |
347 | SizeY = pY; | 331 | SizeY = pY; |
348 | SizeZ = pZ; | 332 | SizeZ = pZ; |
349 | m_compressionFactor = 100.0f; | 333 | CompressionFactor = 100.0f; |
350 | m_heightmap = new float[SizeX, SizeY]; | 334 | m_heightmap = new float[SizeX, SizeY]; |
351 | m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; | 335 | m_taint = new bool[SizeX / Constants.TerrainPatchSize, SizeY / Constants.TerrainPatchSize]; |
352 | // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); | 336 | // m_log.DebugFormat("{0} new by dimensions. sizeX={1}, sizeY={2}, sizeZ={3}", LogHeader, SizeX, SizeY, SizeZ); |
@@ -354,10 +338,10 @@ namespace OpenSim.Framework | |||
354 | ClearLand(0f); | 338 | ClearLand(0f); |
355 | } | 339 | } |
356 | 340 | ||
357 | public HeightmapTerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ) | 341 | public TerrainData(float[] cmap, float pCompressionFactor, int pX, int pY, int pZ) |
358 | : this(pX, pY, pZ) | 342 | : this(pX, pY, pZ) |
359 | { | 343 | { |
360 | m_compressionFactor = pCompressionFactor; | 344 | CompressionFactor = pCompressionFactor; |
361 | int ind = 0; | 345 | int ind = 0; |
362 | for (int xx = 0; xx < SizeX; xx++) | 346 | for (int xx = 0; xx < SizeX; xx++) |
363 | for (int yy = 0; yy < SizeY; yy++) | 347 | for (int yy = 0; yy < SizeY; yy++) |
@@ -366,7 +350,7 @@ namespace OpenSim.Framework | |||
366 | } | 350 | } |
367 | 351 | ||
368 | // Create a heighmap from a database blob | 352 | // Create a heighmap from a database blob |
369 | public HeightmapTerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) | 353 | public TerrainData(int pSizeX, int pSizeY, int pSizeZ, int pFormatCode, byte[] pBlob) |
370 | : this(pSizeX, pSizeY, pSizeZ) | 354 | : this(pSizeX, pSizeY, pSizeZ) |
371 | { | 355 | { |
372 | switch ((DBTerrainRevision)pFormatCode) | 356 | switch ((DBTerrainRevision)pFormatCode) |
@@ -476,13 +460,9 @@ namespace OpenSim.Framework | |||
476 | ret = str.ToArray(); | 460 | ret = str.ToArray(); |
477 | } | 461 | } |
478 | } | 462 | } |
479 | catch | 463 | catch {} |
480 | { | ||
481 | |||
482 | } | ||
483 | 464 | ||
484 | m_log.DebugFormat("{0} V2D {1} bytes", | 465 | m_log.DebugFormat("{0} V2D {1} bytes", LogHeader, ret.Length); |
485 | LogHeader, ret.Length); | ||
486 | 466 | ||
487 | return ret; | 467 | return ret; |
488 | } | 468 | } |
@@ -502,7 +482,8 @@ namespace OpenSim.Framework | |||
502 | for (int yy = 0; yy < SizeY; yy++) | 482 | for (int yy = 0; yy < SizeY; yy++) |
503 | for (int xx = 0; xx < SizeX; xx++) | 483 | for (int xx = 0; xx < SizeX; xx++) |
504 | { | 484 | { |
505 | bw.Write((float)m_heightmap[xx, yy]); | 485 | //bw.Write((float)m_heightmap[xx, yy]); |
486 | bw.Write((float)Math.Round(m_heightmap[xx, yy], 3, MidpointRounding.AwayFromZero)); | ||
506 | } | 487 | } |
507 | 488 | ||
508 | bw.Flush(); | 489 | bw.Flush(); |
@@ -520,12 +501,9 @@ namespace OpenSim.Framework | |||
520 | } | 501 | } |
521 | } | 502 | } |
522 | } | 503 | } |
523 | catch | 504 | catch {} |
524 | { | ||
525 | 505 | ||
526 | } | 506 | m_log.DebugFormat("{0} V2DGzip {1} bytes", LogHeader, ret.Length); |
527 | m_log.DebugFormat("{0} V2DGzip {1} bytes", | ||
528 | LogHeader, ret.Length); | ||
529 | return ret; | 507 | return ret; |
530 | } | 508 | } |
531 | 509 | ||
@@ -548,7 +526,7 @@ namespace OpenSim.Framework | |||
548 | hmSizeY = br.ReadInt32(); | 526 | hmSizeY = br.ReadInt32(); |
549 | hmCompressionFactor = br.ReadInt32(); | 527 | hmCompressionFactor = br.ReadInt32(); |
550 | 528 | ||
551 | m_compressionFactor = hmCompressionFactor; | 529 | CompressionFactor = hmCompressionFactor; |
552 | 530 | ||
553 | // In case database info doesn't match real terrain size, initialize the whole terrain. | 531 | // In case database info doesn't match real terrain size, initialize the whole terrain. |
554 | ClearLand(); | 532 | ClearLand(); |
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs index 5ad0030..c8eb57d 100644 --- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs +++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs | |||
@@ -220,12 +220,6 @@ namespace OpenSim.Framework.Tests | |||
220 | 220 | ||
221 | AvAppearance.VisualParams = VisualParams; | 221 | AvAppearance.VisualParams = VisualParams; |
222 | 222 | ||
223 | List<byte> wearbyte = new List<byte>(); | ||
224 | for (int i = 0; i < VisualParams.Length; i++) | ||
225 | { | ||
226 | wearbyte.Add(VisualParams[i]); | ||
227 | } | ||
228 | |||
229 | AvAppearance.SetAppearance(AvAppearance.Texture, (byte[])VisualParams.Clone()); | 223 | AvAppearance.SetAppearance(AvAppearance.Texture, (byte[])VisualParams.Clone()); |
230 | } | 224 | } |
231 | 225 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1afc5a4..187ed4f 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -30,6 +30,8 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Data; | 31 | using System.Data; |
32 | using System.Diagnostics; | 32 | using System.Diagnostics; |
33 | using System.Drawing; | ||
34 | using System.Drawing.Imaging; | ||
33 | using System.Globalization; | 35 | using System.Globalization; |
34 | using System.IO; | 36 | using System.IO; |
35 | using System.IO.Compression; | 37 | using System.IO.Compression; |
@@ -92,6 +94,7 @@ namespace OpenSim.Framework | |||
92 | // explicitly given | 94 | // explicitly given |
93 | All = 0x8e000, | 95 | All = 0x8e000, |
94 | AllAndExport = 0x9e000, | 96 | AllAndExport = 0x9e000, |
97 | AllAndExportNoMod = 0x9a000, | ||
95 | AllEffective = 0x9e000, | 98 | AllEffective = 0x9e000, |
96 | UnfoldedMask = 0x1e000 | 99 | UnfoldedMask = 0x1e000 |
97 | } | 100 | } |
@@ -108,9 +111,7 @@ namespace OpenSim.Framework | |||
108 | { | 111 | { |
109 | None, | 112 | None, |
110 | RegressionTest, | 113 | RegressionTest, |
111 | UnsafeQueueUserWorkItem, | ||
112 | QueueUserWorkItem, | 114 | QueueUserWorkItem, |
113 | BeginInvoke, | ||
114 | SmartThreadPool, | 115 | SmartThreadPool, |
115 | Thread, | 116 | Thread, |
116 | } | 117 | } |
@@ -261,10 +262,7 @@ namespace OpenSim.Framework | |||
261 | /// <returns>The distance between the two vectors</returns> | 262 | /// <returns>The distance between the two vectors</returns> |
262 | public static double GetDistanceTo(Vector3 a, Vector3 b) | 263 | public static double GetDistanceTo(Vector3 a, Vector3 b) |
263 | { | 264 | { |
264 | float dx = a.X - b.X; | 265 | return Vector3.Distance(a,b); |
265 | float dy = a.Y - b.Y; | ||
266 | float dz = a.Z - b.Z; | ||
267 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); | ||
268 | } | 266 | } |
269 | 267 | ||
270 | /// <summary> | 268 | /// <summary> |
@@ -276,10 +274,7 @@ namespace OpenSim.Framework | |||
276 | /// <returns></returns> | 274 | /// <returns></returns> |
277 | public static bool DistanceLessThan(Vector3 a, Vector3 b, double amount) | 275 | public static bool DistanceLessThan(Vector3 a, Vector3 b, double amount) |
278 | { | 276 | { |
279 | float dx = a.X - b.X; | 277 | return Vector3.DistanceSquared(a,b) < (amount * amount); |
280 | float dy = a.Y - b.Y; | ||
281 | float dz = a.Z - b.Z; | ||
282 | return (dx*dx + dy*dy + dz*dz) < (amount*amount); | ||
283 | } | 278 | } |
284 | 279 | ||
285 | /// <summary> | 280 | /// <summary> |
@@ -380,15 +375,17 @@ namespace OpenSim.Framework | |||
380 | get { return randomClass; } | 375 | get { return randomClass; } |
381 | } | 376 | } |
382 | 377 | ||
378 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
383 | public static ulong UIntsToLong(uint X, uint Y) | 379 | public static ulong UIntsToLong(uint X, uint Y) |
384 | { | 380 | { |
385 | return Utils.UIntsToLong(X, Y); | 381 | return ((ulong)X << 32) | (ulong)Y; |
386 | } | 382 | } |
387 | 383 | ||
388 | // Regions are identified with a 'handle' made up of its world coordinates packed into a ulong. | 384 | // Regions are identified with a 'handle' made up of its world coordinates packed into a ulong. |
389 | // Region handles are based on the coordinate of the region corner with lower X and Y | 385 | // Region handles are based on the coordinate of the region corner with lower X and Y |
390 | // var regions need more work than this to get that right corner from a generic world position | 386 | // var regions need more work than this to get that right corner from a generic world position |
391 | // this corner must be on a grid point | 387 | // this corner must be on a grid point |
388 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
392 | public static ulong RegionWorldLocToHandle(uint X, uint Y) | 389 | public static ulong RegionWorldLocToHandle(uint X, uint Y) |
393 | { | 390 | { |
394 | ulong handle = X & 0xffffff00; // make sure it matchs grid coord points. | 391 | ulong handle = X & 0xffffff00; // make sure it matchs grid coord points. |
@@ -397,6 +394,7 @@ namespace OpenSim.Framework | |||
397 | return handle; | 394 | return handle; |
398 | } | 395 | } |
399 | 396 | ||
397 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
400 | public static ulong RegionGridLocToHandle(uint X, uint Y) | 398 | public static ulong RegionGridLocToHandle(uint X, uint Y) |
401 | { | 399 | { |
402 | ulong handle = X; | 400 | ulong handle = X; |
@@ -405,12 +403,14 @@ namespace OpenSim.Framework | |||
405 | return handle; | 403 | return handle; |
406 | } | 404 | } |
407 | 405 | ||
406 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
408 | public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y) | 407 | public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y) |
409 | { | 408 | { |
410 | X = (uint)(handle >> 32); | 409 | X = (uint)(handle >> 32); |
411 | Y = (uint)(handle & 0xfffffffful); | 410 | Y = (uint)(handle & 0xfffffffful); |
412 | } | 411 | } |
413 | 412 | ||
413 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
414 | 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) |
415 | { | 415 | { |
416 | X = (uint)(handle >> 40) & 0x00ffffffu; // bring from higher half, divide by 256 and clean | 416 | X = (uint)(handle >> 40) & 0x00ffffffu; // bring from higher half, divide by 256 and clean |
@@ -420,21 +420,25 @@ namespace OpenSim.Framework | |||
420 | 420 | ||
421 | // A region location can be 'world coordinates' (meters) or 'region grid coordinates' | 421 | // A region location can be 'world coordinates' (meters) or 'region grid coordinates' |
422 | // grid coordinates have a fixed step of 256m as defined by viewers | 422 | // grid coordinates have a fixed step of 256m as defined by viewers |
423 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
423 | public static uint WorldToRegionLoc(uint worldCoord) | 424 | public static uint WorldToRegionLoc(uint worldCoord) |
424 | { | 425 | { |
425 | return worldCoord >> 8; | 426 | return worldCoord >> 8; |
426 | } | 427 | } |
427 | 428 | ||
428 | // Convert a region's 'region grid coordinate' to its 'world coordinate'. | 429 | // Convert a region's 'region grid coordinate' to its 'world coordinate'. |
430 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
429 | public static uint RegionToWorldLoc(uint regionCoord) | 431 | public static uint RegionToWorldLoc(uint regionCoord) |
430 | { | 432 | { |
431 | return regionCoord << 8; | 433 | return regionCoord << 8; |
432 | } | 434 | } |
433 | 435 | ||
434 | 436 | ||
435 | public static bool checkServiceURI(string uristr, out string serviceURI) | 437 | public static bool checkServiceURI(string uristr, out string serviceURI, out string serviceHost, out string serviceIPstr) |
436 | { | 438 | { |
437 | serviceURI = string.Empty; | 439 | serviceURI = string.Empty; |
440 | serviceHost = string.Empty; | ||
441 | serviceIPstr = string.Empty; | ||
438 | try | 442 | try |
439 | { | 443 | { |
440 | Uri uri = new Uri(uristr); | 444 | Uri uri = new Uri(uristr); |
@@ -443,6 +447,13 @@ namespace OpenSim.Framework | |||
443 | serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":80/"; | 447 | serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":80/"; |
444 | else if(uri.Port == 443) | 448 | else if(uri.Port == 443) |
445 | serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":443/"; | 449 | serviceURI = serviceURI.Trim(new char[] { '/', ' ' }) +":443/"; |
450 | serviceHost = uri.Host; | ||
451 | |||
452 | IPEndPoint ep = Util.getEndPoint(serviceHost,uri.Port); | ||
453 | if(ep == null) | ||
454 | return false; | ||
455 | |||
456 | serviceIPstr = ep.Address.ToString(); | ||
446 | return true; | 457 | return true; |
447 | } | 458 | } |
448 | catch | 459 | catch |
@@ -452,9 +463,10 @@ namespace OpenSim.Framework | |||
452 | return false; | 463 | return false; |
453 | } | 464 | } |
454 | 465 | ||
455 | public static bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) | 466 | public static bool buildHGRegionURI(string inputName, out string serverURI, out string serverHost, out string regionName) |
456 | { | 467 | { |
457 | serverURI = string.Empty; | 468 | serverURI = string.Empty; |
469 | serverHost = string.Empty; | ||
458 | regionName = string.Empty; | 470 | regionName = string.Empty; |
459 | 471 | ||
460 | inputName = inputName.Trim(); | 472 | inputName = inputName.Trim(); |
@@ -563,6 +575,7 @@ namespace OpenSim.Framework | |||
563 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; | 575 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":80/"; |
564 | else if(uri.Port == 443) | 576 | else if(uri.Port == 443) |
565 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; | 577 | serverURI = serverURI.Trim(new char[] { '/', ' ' }) +":443/"; |
578 | serverHost = uri.Host; | ||
566 | return true; | 579 | return true; |
567 | } | 580 | } |
568 | 581 | ||
@@ -575,14 +588,15 @@ namespace OpenSim.Framework | |||
575 | } | 588 | } |
576 | 589 | ||
577 | // Clamp the maximum magnitude of a vector | 590 | // Clamp the maximum magnitude of a vector |
591 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
578 | public static Vector3 ClampV(Vector3 x, float max) | 592 | public static Vector3 ClampV(Vector3 x, float max) |
579 | { | 593 | { |
580 | float lenSq = x.LengthSquared(); | 594 | float lenSq = x.LengthSquared(); |
581 | if (lenSq > (max * max)) | 595 | if (lenSq > (max * max)) |
582 | { | 596 | { |
583 | x = x / x.Length() * max; | 597 | lenSq = max / (float)Math.Sqrt(lenSq); |
598 | x = x * lenSq; | ||
584 | } | 599 | } |
585 | |||
586 | return x; | 600 | return x; |
587 | } | 601 | } |
588 | 602 | ||
@@ -671,7 +685,7 @@ namespace OpenSim.Framework | |||
671 | public static string GetFormattedXml(string rawXml) | 685 | public static string GetFormattedXml(string rawXml) |
672 | { | 686 | { |
673 | XmlDocument xd = new XmlDocument(); | 687 | XmlDocument xd = new XmlDocument(); |
674 | xd.XmlResolver=null; | 688 | |
675 | xd.LoadXml(rawXml); | 689 | xd.LoadXml(rawXml); |
676 | 690 | ||
677 | StringBuilder sb = new StringBuilder(); | 691 | StringBuilder sb = new StringBuilder(); |
@@ -825,8 +839,8 @@ namespace OpenSim.Framework | |||
825 | 839 | ||
826 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) | 840 | private static byte[] ComputeMD5Hash(string data, Encoding encoding) |
827 | { | 841 | { |
828 | MD5 md5 = MD5.Create(); | 842 | using(MD5 md5 = MD5.Create()) |
829 | return md5.ComputeHash(encoding.GetBytes(data)); | 843 | return md5.ComputeHash(encoding.GetBytes(data)); |
830 | } | 844 | } |
831 | 845 | ||
832 | /// <summary> | 846 | /// <summary> |
@@ -859,11 +873,24 @@ namespace OpenSim.Framework | |||
859 | private static byte[] ComputeSHA1Hash(byte[] src) | 873 | private static byte[] ComputeSHA1Hash(byte[] src) |
860 | { | 874 | { |
861 | byte[] ret; | 875 | byte[] ret; |
862 | using(SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider()) | 876 | using (SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider()) |
863 | ret = SHA1.ComputeHash(src); | 877 | ret = SHA1.ComputeHash(src); |
864 | return ret; | 878 | return ret; |
865 | } | 879 | } |
866 | 880 | ||
881 | public static UUID ComputeSHA1UUID(string src) | ||
882 | { | ||
883 | return ComputeSHA1UUID(Encoding.Default.GetBytes(src)); | ||
884 | } | ||
885 | |||
886 | public static UUID ComputeSHA1UUID(byte[] src) | ||
887 | { | ||
888 | byte[] ret; | ||
889 | using (SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider()) | ||
890 | ret = SHA1.ComputeHash(src); | ||
891 | return new UUID(ret, 2); | ||
892 | } | ||
893 | |||
867 | public static int fast_distance2d(int x, int y) | 894 | public static int fast_distance2d(int x, int y) |
868 | { | 895 | { |
869 | x = Math.Abs(x); | 896 | x = Math.Abs(x); |
@@ -883,7 +910,7 @@ namespace OpenSim.Framework | |||
883 | /// <returns></returns> | 910 | /// <returns></returns> |
884 | public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) | 911 | public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) |
885 | { | 912 | { |
886 | return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z | 913 | return v.X >= min.X && v.Y >= min.Y && v.Z >= min.Z |
887 | && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; | 914 | && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; |
888 | } | 915 | } |
889 | 916 | ||
@@ -1279,12 +1306,12 @@ namespace OpenSim.Framework | |||
1279 | 1306 | ||
1280 | public static string dbDir() | 1307 | public static string dbDir() |
1281 | { | 1308 | { |
1282 | return Path.Combine("..", Path.Combine("..", "db")); | 1309 | return Path.Combine("..", Path.Combine("..", "var/lib/db")); |
1283 | } | 1310 | } |
1284 | 1311 | ||
1285 | public static string cacheDir() | 1312 | public static string cacheDir() |
1286 | { | 1313 | { |
1287 | return Path.Combine("..", Path.Combine("..", "caches")); | 1314 | return Path.Combine("..", Path.Combine("..", "var/cache")); |
1288 | } | 1315 | } |
1289 | 1316 | ||
1290 | public static string configDir() | 1317 | public static string configDir() |
@@ -1300,7 +1327,7 @@ namespace OpenSim.Framework | |||
1300 | 1327 | ||
1301 | public static string logsDir() | 1328 | public static string logsDir() |
1302 | { | 1329 | { |
1303 | return Path.Combine("..", "logs"); | 1330 | return Path.Combine("..", "var/log"); |
1304 | } | 1331 | } |
1305 | 1332 | ||
1306 | public static string webDir() | 1333 | public static string webDir() |
@@ -1935,7 +1962,9 @@ namespace OpenSim.Framework | |||
1935 | string ru = String.Empty; | 1962 | string ru = String.Empty; |
1936 | 1963 | ||
1937 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 1964 | if (Environment.OSVersion.Platform == PlatformID.Unix) |
1938 | ru = "Unix/Mono"; | 1965 | { |
1966 | ru = "Unix/Mono"; | ||
1967 | } | ||
1939 | else | 1968 | else |
1940 | if (Environment.OSVersion.Platform == PlatformID.MacOSX) | 1969 | if (Environment.OSVersion.Platform == PlatformID.MacOSX) |
1941 | ru = "OSX/Mono"; | 1970 | ru = "OSX/Mono"; |
@@ -2385,6 +2414,38 @@ namespace OpenSim.Framework | |||
2385 | return sb.ToString(); | 2414 | return sb.ToString(); |
2386 | } | 2415 | } |
2387 | 2416 | ||
2417 | public static bool TryParseHttpRange(string header, out int start, out int end) | ||
2418 | { | ||
2419 | start = end = 0; | ||
2420 | |||
2421 | if (header.StartsWith("bytes=")) | ||
2422 | { | ||
2423 | string[] rangeValues = header.Substring(6).Split('-'); | ||
2424 | |||
2425 | if (rangeValues.Length == 2) | ||
2426 | { | ||
2427 | string rawStart = rangeValues[0].Trim(); | ||
2428 | if (rawStart != "" && !Int32.TryParse(rawStart, out start)) | ||
2429 | return false; | ||
2430 | |||
2431 | if (start < 0) | ||
2432 | return false; | ||
2433 | |||
2434 | string rawEnd = rangeValues[1].Trim(); | ||
2435 | if (rawEnd == "") | ||
2436 | { | ||
2437 | end = -1; | ||
2438 | return true; | ||
2439 | } | ||
2440 | else if (Int32.TryParse(rawEnd, out end)) | ||
2441 | return end > 0; | ||
2442 | } | ||
2443 | } | ||
2444 | |||
2445 | start = end = 0; | ||
2446 | return false; | ||
2447 | } | ||
2448 | |||
2388 | /// <summary> | 2449 | /// <summary> |
2389 | /// Used to trigger an early library load on Windows systems. | 2450 | /// Used to trigger an early library load on Windows systems. |
2390 | /// </summary> | 2451 | /// </summary> |
@@ -2408,53 +2469,6 @@ namespace OpenSim.Framework | |||
2408 | 2469 | ||
2409 | #region FireAndForget Threading Pattern | 2470 | #region FireAndForget Threading Pattern |
2410 | 2471 | ||
2411 | /// <summary> | ||
2412 | /// Created to work around a limitation in Mono with nested delegates | ||
2413 | /// </summary> | ||
2414 | private sealed class FireAndForgetWrapper | ||
2415 | { | ||
2416 | private static volatile FireAndForgetWrapper instance; | ||
2417 | private static object syncRoot = new Object(); | ||
2418 | |||
2419 | public static FireAndForgetWrapper Instance { | ||
2420 | get { | ||
2421 | |||
2422 | if (instance == null) | ||
2423 | { | ||
2424 | lock (syncRoot) | ||
2425 | { | ||
2426 | if (instance == null) | ||
2427 | { | ||
2428 | instance = new FireAndForgetWrapper(); | ||
2429 | } | ||
2430 | } | ||
2431 | } | ||
2432 | |||
2433 | return instance; | ||
2434 | } | ||
2435 | } | ||
2436 | |||
2437 | public void FireAndForget(System.Threading.WaitCallback callback) | ||
2438 | { | ||
2439 | callback.BeginInvoke(null, EndFireAndForget, callback); | ||
2440 | } | ||
2441 | |||
2442 | public void FireAndForget(System.Threading.WaitCallback callback, object obj) | ||
2443 | { | ||
2444 | callback.BeginInvoke(obj, EndFireAndForget, callback); | ||
2445 | } | ||
2446 | |||
2447 | private static void EndFireAndForget(IAsyncResult ar) | ||
2448 | { | ||
2449 | System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState; | ||
2450 | |||
2451 | try { callback.EndInvoke(ar); } | ||
2452 | catch (Exception ex) { m_log.Error("[UTIL]: Asynchronous method threw an exception: " + ex.Message, ex); } | ||
2453 | |||
2454 | ar.AsyncWaitHandle.Close(); | ||
2455 | } | ||
2456 | } | ||
2457 | |||
2458 | public static void InitThreadPool(int minThreads, int maxThreads) | 2472 | public static void InitThreadPool(int minThreads, int maxThreads) |
2459 | { | 2473 | { |
2460 | if (maxThreads < 2) | 2474 | if (maxThreads < 2) |
@@ -2485,16 +2499,17 @@ namespace OpenSim.Framework | |||
2485 | 2499 | ||
2486 | switch (FireAndForgetMethod) | 2500 | switch (FireAndForgetMethod) |
2487 | { | 2501 | { |
2488 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: | ||
2489 | case FireAndForgetMethod.QueueUserWorkItem: | 2502 | case FireAndForgetMethod.QueueUserWorkItem: |
2490 | case FireAndForgetMethod.BeginInvoke: | ||
2491 | int workerThreads, iocpThreads; | 2503 | int workerThreads, iocpThreads; |
2492 | ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); | 2504 | ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads); |
2493 | return workerThreads; | 2505 | return workerThreads; |
2494 | case FireAndForgetMethod.SmartThreadPool: | 2506 | case FireAndForgetMethod.SmartThreadPool: |
2495 | return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads; | 2507 | return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads; |
2496 | case FireAndForgetMethod.Thread: | 2508 | case FireAndForgetMethod.Thread: |
2497 | return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count; | 2509 | { |
2510 | using(Process p = System.Diagnostics.Process.GetCurrentProcess()) | ||
2511 | return MAX_SYSTEM_THREADS - p.Threads.Count; | ||
2512 | } | ||
2498 | default: | 2513 | default: |
2499 | throw new NotImplementedException(); | 2514 | throw new NotImplementedException(); |
2500 | } | 2515 | } |
@@ -2641,20 +2656,6 @@ namespace OpenSim.Framework | |||
2641 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context, bool dotimeout = true) | 2656 | public static void FireAndForget(System.Threading.WaitCallback callback, object obj, string context, bool dotimeout = true) |
2642 | { | 2657 | { |
2643 | Interlocked.Increment(ref numTotalThreadFuncsCalled); | 2658 | Interlocked.Increment(ref numTotalThreadFuncsCalled); |
2644 | /* | ||
2645 | if (context != null) | ||
2646 | { | ||
2647 | if (!m_fireAndForgetCallsMade.ContainsKey(context)) | ||
2648 | m_fireAndForgetCallsMade[context] = 1; | ||
2649 | else | ||
2650 | m_fireAndForgetCallsMade[context]++; | ||
2651 | |||
2652 | if (!m_fireAndForgetCallsInProgress.ContainsKey(context)) | ||
2653 | m_fireAndForgetCallsInProgress[context] = 1; | ||
2654 | else | ||
2655 | m_fireAndForgetCallsInProgress[context]++; | ||
2656 | } | ||
2657 | */ | ||
2658 | WaitCallback realCallback; | 2659 | WaitCallback realCallback; |
2659 | 2660 | ||
2660 | bool loggingEnabled = LogThreadPool > 0; | 2661 | bool loggingEnabled = LogThreadPool > 0; |
@@ -2670,9 +2671,6 @@ namespace OpenSim.Framework | |||
2670 | { | 2671 | { |
2671 | Culture.SetCurrentCulture(); | 2672 | Culture.SetCurrentCulture(); |
2672 | callback(o); | 2673 | callback(o); |
2673 | |||
2674 | // if (context != null) | ||
2675 | // m_fireAndForgetCallsInProgress[context]--; | ||
2676 | }; | 2674 | }; |
2677 | } | 2675 | } |
2678 | else | 2676 | else |
@@ -2693,7 +2691,6 @@ namespace OpenSim.Framework | |||
2693 | m_log.DebugFormat("Run threadfunc {0} (Queued {1}, Running {2})", threadFuncNum, numQueued1, numRunning1); | 2691 | m_log.DebugFormat("Run threadfunc {0} (Queued {1}, Running {2})", threadFuncNum, numQueued1, numRunning1); |
2694 | 2692 | ||
2695 | Culture.SetCurrentCulture(); | 2693 | Culture.SetCurrentCulture(); |
2696 | |||
2697 | callback(o); | 2694 | callback(o); |
2698 | } | 2695 | } |
2699 | catch (ThreadAbortException) | 2696 | catch (ThreadAbortException) |
@@ -2711,9 +2708,6 @@ namespace OpenSim.Framework | |||
2711 | activeThreads.TryRemove(threadFuncNum, out dummy); | 2708 | activeThreads.TryRemove(threadFuncNum, out dummy); |
2712 | if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread) | 2709 | if ((loggingEnabled || (threadFuncOverloadMode == 1)) && threadInfo.LogThread) |
2713 | m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed())); | 2710 | m_log.DebugFormat("Exit threadfunc {0} ({1})", threadFuncNum, FormatDuration(threadInfo.Elapsed())); |
2714 | |||
2715 | // if (context != null) | ||
2716 | // m_fireAndForgetCallsInProgress[context]--; | ||
2717 | } | 2711 | } |
2718 | }; | 2712 | }; |
2719 | } | 2713 | } |
@@ -2721,45 +2715,7 @@ namespace OpenSim.Framework | |||
2721 | long numQueued = Interlocked.Increment(ref numQueuedThreadFuncs); | 2715 | long numQueued = Interlocked.Increment(ref numQueuedThreadFuncs); |
2722 | try | 2716 | try |
2723 | { | 2717 | { |
2724 | /* | 2718 | threadInfo.LogThread = false; |
2725 | long numRunning = numRunningThreadFuncs; | ||
2726 | |||
2727 | if (m_ThreadPool != null && LogOverloads) | ||
2728 | { | ||
2729 | if ((threadFuncOverloadMode == 0) && (numRunning >= m_ThreadPool.MaxThreads)) | ||
2730 | { | ||
2731 | if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 1, 0) == 0) | ||
2732 | m_log.DebugFormat("Threadfunc: enable overload mode (Queued {0}, Running {1})", numQueued, numRunning); | ||
2733 | } | ||
2734 | else if ((threadFuncOverloadMode == 1) && (numRunning <= (m_ThreadPool.MaxThreads * 2) / 3)) | ||
2735 | { | ||
2736 | if (Interlocked.CompareExchange(ref threadFuncOverloadMode, 0, 1) == 1) | ||
2737 | m_log.DebugFormat("Threadfunc: disable overload mode (Queued {0}, Running {1})", numQueued, numRunning); | ||
2738 | } | ||
2739 | } | ||
2740 | |||
2741 | if (loggingEnabled || (threadFuncOverloadMode == 1)) | ||
2742 | { | ||
2743 | string full, partial; | ||
2744 | GetFireAndForgetStackTrace(out full, out partial); | ||
2745 | threadInfo.StackTrace = full; | ||
2746 | threadInfo.LogThread = ShouldLogThread(partial); | ||
2747 | |||
2748 | if (threadInfo.LogThread) | ||
2749 | { | ||
2750 | m_log.DebugFormat("Queue threadfunc {0} (Queued {1}, Running {2}) {3}{4}", | ||
2751 | threadFuncNum, numQueued, numRunningThreadFuncs, | ||
2752 | (context == null) ? "" : ("(" + context + ") "), | ||
2753 | (LogThreadPool >= 2) ? full : partial); | ||
2754 | } | ||
2755 | } | ||
2756 | else | ||
2757 | */ | ||
2758 | { | ||
2759 | // Since we didn't log "Queue threadfunc", don't log "Run threadfunc" or "End threadfunc" either. | ||
2760 | // Those log lines aren't useful when we don't know which function is running in the thread. | ||
2761 | threadInfo.LogThread = false; | ||
2762 | } | ||
2763 | 2719 | ||
2764 | switch (FireAndForgetMethod) | 2720 | switch (FireAndForgetMethod) |
2765 | { | 2721 | { |
@@ -2767,16 +2723,9 @@ namespace OpenSim.Framework | |||
2767 | case FireAndForgetMethod.None: | 2723 | case FireAndForgetMethod.None: |
2768 | realCallback.Invoke(obj); | 2724 | realCallback.Invoke(obj); |
2769 | break; | 2725 | break; |
2770 | case FireAndForgetMethod.UnsafeQueueUserWorkItem: | ||
2771 | ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj); | ||
2772 | break; | ||
2773 | case FireAndForgetMethod.QueueUserWorkItem: | 2726 | case FireAndForgetMethod.QueueUserWorkItem: |
2774 | ThreadPool.QueueUserWorkItem(realCallback, obj); | 2727 | ThreadPool.QueueUserWorkItem(realCallback, obj); |
2775 | break; | 2728 | break; |
2776 | case FireAndForgetMethod.BeginInvoke: | ||
2777 | FireAndForgetWrapper wrapper = FireAndForgetWrapper.Instance; | ||
2778 | wrapper.FireAndForget(realCallback, obj); | ||
2779 | break; | ||
2780 | case FireAndForgetMethod.SmartThreadPool: | 2729 | case FireAndForgetMethod.SmartThreadPool: |
2781 | if (m_ThreadPool == null) | 2730 | if (m_ThreadPool == null) |
2782 | InitThreadPool(2, 15); | 2731 | InitThreadPool(2, 15); |
@@ -2879,6 +2828,12 @@ namespace OpenSim.Framework | |||
2879 | /// <returns>The stack trace, or null if failed to get it</returns> | 2828 | /// <returns>The stack trace, or null if failed to get it</returns> |
2880 | private static StackTrace GetStackTrace(Thread targetThread) | 2829 | private static StackTrace GetStackTrace(Thread targetThread) |
2881 | { | 2830 | { |
2831 | |||
2832 | return null; | ||
2833 | /* | ||
2834 | not only this does not work on mono but it is not longer recomended on windows. | ||
2835 | can cause deadlocks etc. | ||
2836 | |||
2882 | if (IsPlatformMono) | 2837 | if (IsPlatformMono) |
2883 | { | 2838 | { |
2884 | // This doesn't work in Mono | 2839 | // This doesn't work in Mono |
@@ -2941,6 +2896,7 @@ namespace OpenSim.Framework | |||
2941 | // Signal the fallack-thread to stop | 2896 | // Signal the fallack-thread to stop |
2942 | exitedSafely.Set(); | 2897 | exitedSafely.Set(); |
2943 | } | 2898 | } |
2899 | */ | ||
2944 | } | 2900 | } |
2945 | #pragma warning restore 0618 | 2901 | #pragma warning restore 0618 |
2946 | 2902 | ||
@@ -3038,16 +2994,37 @@ namespace OpenSim.Framework | |||
3038 | return tcA - tcB; | 2994 | return tcA - tcB; |
3039 | } | 2995 | } |
3040 | 2996 | ||
2997 | public static long GetPhysicalMemUse() | ||
2998 | { | ||
2999 | using (Process p = System.Diagnostics.Process.GetCurrentProcess()) | ||
3000 | return p.WorkingSet64; | ||
3001 | } | ||
3002 | |||
3041 | // returns a timestamp in ms as double | 3003 | // returns a timestamp in ms as double |
3042 | // using the time resolution avaiable to StopWatch | 3004 | // using the time resolution avaiable to StopWatch |
3005 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
3043 | public static double GetTimeStamp() | 3006 | public static double GetTimeStamp() |
3044 | { | 3007 | { |
3045 | return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriod; | 3008 | return Stopwatch.GetTimestamp() * TimeStampClockPeriod; |
3046 | } | 3009 | } |
3047 | 3010 | ||
3011 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
3048 | public static double GetTimeStampMS() | 3012 | public static double GetTimeStampMS() |
3049 | { | 3013 | { |
3050 | return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS; | 3014 | return Stopwatch.GetTimestamp() * TimeStampClockPeriodMS; |
3015 | } | ||
3016 | |||
3017 | // doing math in ticks is usefull to avoid loss of resolution | ||
3018 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
3019 | public static long GetTimeStampTicks() | ||
3020 | { | ||
3021 | return Stopwatch.GetTimestamp(); | ||
3022 | } | ||
3023 | |||
3024 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] | ||
3025 | public static double TimeStampTicksToMS(long ticks) | ||
3026 | { | ||
3027 | return ticks * TimeStampClockPeriodMS; | ||
3051 | } | 3028 | } |
3052 | 3029 | ||
3053 | /// <summary> | 3030 | /// <summary> |
@@ -3428,9 +3405,46 @@ namespace OpenSim.Framework | |||
3428 | if (length > 2000) | 3405 | if (length > 2000) |
3429 | xml = xml.Substring(0, 2000) + "..."; | 3406 | xml = xml.Substring(0, 2000) + "..."; |
3430 | 3407 | ||
3408 | for (int i = 0 ; i < xml.Length ; i++) | ||
3409 | { | ||
3410 | if (xml[i] < 0x20) | ||
3411 | { | ||
3412 | xml = "Unprintable binary data"; | ||
3413 | break; | ||
3414 | } | ||
3415 | } | ||
3416 | |||
3431 | m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml); | 3417 | m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml); |
3432 | } | 3418 | } |
3433 | 3419 | ||
3420 | /// <summary> | ||
3421 | /// Performs a high quality image resize | ||
3422 | /// </summary> | ||
3423 | /// <param name="image">Image to resize</param> | ||
3424 | /// <param name="width">New width</param> | ||
3425 | /// <param name="height">New height</param> | ||
3426 | /// <returns>Resized image</returns> | ||
3427 | public static Bitmap ResizeImageSolid(Image image, int width, int height) | ||
3428 | { | ||
3429 | Bitmap result = new Bitmap(width, height, PixelFormat.Format24bppRgb); | ||
3430 | |||
3431 | using (ImageAttributes atrib = new ImageAttributes()) | ||
3432 | using (Graphics graphics = Graphics.FromImage(result)) | ||
3433 | { | ||
3434 | atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY); | ||
3435 | atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY); | ||
3436 | graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; | ||
3437 | graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; | ||
3438 | graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; | ||
3439 | graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; | ||
3440 | |||
3441 | graphics.DrawImage(image,new Rectangle(0,0, result.Width, result.Height), | ||
3442 | 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, atrib); | ||
3443 | } | ||
3444 | |||
3445 | return result; | ||
3446 | } | ||
3447 | |||
3434 | } | 3448 | } |
3435 | 3449 | ||
3436 | /* don't like this code | 3450 | /* don't like this code |
@@ -3595,5 +3609,6 @@ namespace OpenSim.Framework | |||
3595 | { | 3609 | { |
3596 | rng.GetBytes(buff); | 3610 | rng.GetBytes(buff); |
3597 | } | 3611 | } |
3612 | |||
3598 | } | 3613 | } |
3599 | } | 3614 | } |
diff --git a/OpenSim/Framework/VersionInfo.cs b/OpenSim/Framework/VersionInfo.cs index 2250496..d2674a0 100644 --- a/OpenSim/Framework/VersionInfo.cs +++ b/OpenSim/Framework/VersionInfo.cs | |||
@@ -29,8 +29,8 @@ namespace OpenSim | |||
29 | { | 29 | { |
30 | public class VersionInfo | 30 | public class VersionInfo |
31 | { | 31 | { |
32 | public const string VersionNumber = "0.9.0.2"; | 32 | public const string VersionNumber = "0.9.1.1"; |
33 | public const string AssemblyVersionNumber = "0.9.0.*"; | 33 | public const string AssemblyVersionNumber = "0.9.1.1"; |
34 | public const string SC_BUILD_NUMBER = "0"; | 34 | public const string SC_BUILD_NUMBER = "0"; |
35 | 35 | ||
36 | public const Flavour VERSION_FLAVOUR = Flavour.Dev; | 36 | public const Flavour VERSION_FLAVOUR = Flavour.Dev; |
@@ -76,8 +76,12 @@ namespace OpenSim | |||
76 | /// <remarks> | 76 | /// <remarks> |
77 | /// The protocol version that we will use for outgoing transfers | 77 | /// The protocol version that we will use for outgoing transfers |
78 | /// Valid values are | 78 | /// Valid values are |
79 | /// "SIMULATION/0.8" | ||
80 | /// - up to 45 avatar textures - 11 baked | ||
81 | /// "SIMULATION/0.7" | ||
82 | /// TP uses call back again | ||
79 | /// "SIMULATION/0.3" | 83 | /// "SIMULATION/0.3" |
80 | /// - This is the latest, and it supports teleports to variable-sized regions | 84 | /// - supports teleports to variable-sized regions |
81 | /// - Older versions can teleport to this one, but only if the destination region | 85 | /// - Older versions can teleport to this one, but only if the destination region |
82 | /// is 256x256 | 86 | /// is 256x256 |
83 | /// "SIMULATION/0.2" | 87 | /// "SIMULATION/0.2" |
@@ -87,8 +91,8 @@ namespace OpenSim | |||
87 | /// - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. | 91 | /// - this is an older teleport protocol used in OpenSimulator 0.7.5 and before. |
88 | /// </remarks> | 92 | /// </remarks> |
89 | public readonly static float SimulationServiceVersionAcceptedMin = 0.3f; | 93 | public readonly static float SimulationServiceVersionAcceptedMin = 0.3f; |
90 | public readonly static float SimulationServiceVersionAcceptedMax = 0.6f; | 94 | public readonly static float SimulationServiceVersionAcceptedMax = 0.8f; |
91 | public readonly static float SimulationServiceVersionSupportedMin = 0.3f; | 95 | public readonly static float SimulationServiceVersionSupportedMin = 0.3f; |
92 | public readonly static float SimulationServiceVersionSupportedMax = 0.6f; | 96 | public readonly static float SimulationServiceVersionSupportedMax = 0.8f; |
93 | } | 97 | } |
94 | } | 98 | } |
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs index 427e149..f832ff9 100644 --- a/OpenSim/Framework/WearableCacheItem.cs +++ b/OpenSim/Framework/WearableCacheItem.cs | |||
@@ -128,31 +128,27 @@ namespace OpenSim.Framework | |||
128 | return arr; | 128 | return arr; |
129 | } | 129 | } |
130 | 130 | ||
131 | public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems) | 131 | public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems, int start, int end) |
132 | { | 132 | { |
133 | if (pcacheItems.Length < AvatarAppearance.BAKE_INDICES[AvatarAppearance.BAKE_INDICES.Length - 1]) | ||
134 | return null; | ||
135 | |||
136 | OSDArray arr = new OSDArray(); | 133 | OSDArray arr = new OSDArray(); |
134 | if(start < 0) | ||
135 | start = 0; | ||
136 | if (end < 0 || end > AvatarAppearance.BAKE_INDICES.Length) | ||
137 | end = AvatarAppearance.BAKE_INDICES.Length; | ||
138 | if (start > end) | ||
139 | return null; | ||
137 | 140 | ||
138 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 141 | for (int i = start; i < end; i++) |
139 | { | 142 | { |
140 | int idx = AvatarAppearance.BAKE_INDICES[i]; | 143 | int idx = AvatarAppearance.BAKE_INDICES[i]; |
141 | 144 | if(idx >= pcacheItems.Length) | |
145 | continue; | ||
142 | WearableCacheItem item = pcacheItems[idx]; | 146 | WearableCacheItem item = pcacheItems[idx]; |
143 | 147 | ||
144 | OSDMap itemmap = new OSDMap(); | 148 | OSDMap itemmap = new OSDMap(); |
145 | itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex)); | 149 | itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex)); |
146 | itemmap.Add("cacheid", OSD.FromUUID(item.CacheId)); | 150 | itemmap.Add("cacheid", OSD.FromUUID(item.CacheId)); |
147 | itemmap.Add("textureid", OSD.FromUUID(item.TextureID)); | 151 | 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); | 152 | arr.Add(itemmap); |
157 | } | 153 | } |
158 | return arr; | 154 | return arr; |
@@ -161,29 +157,17 @@ namespace OpenSim.Framework | |||
161 | public static WearableCacheItem[] BakedFromOSD(OSD pInput) | 157 | public static WearableCacheItem[] BakedFromOSD(OSD pInput) |
162 | { | 158 | { |
163 | WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem(); | 159 | WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem(); |
164 | |||
165 | if (pInput.Type == OSDType.Array) | 160 | if (pInput.Type == OSDType.Array) |
166 | { | 161 | { |
167 | OSDArray itemarray = (OSDArray)pInput; | 162 | OSDArray itemarray = (OSDArray)pInput; |
168 | foreach (OSDMap item in itemarray) | 163 | foreach (OSDMap item in itemarray) |
169 | { | 164 | { |
170 | int idx = (int)item["textureindex"].AsUInteger(); | 165 | int idx = item["textureindex"].AsInteger(); |
171 | if (idx < 0 || idx > pcache.Length) | 166 | if (idx < 0 || idx >= pcache.Length) |
172 | continue; | 167 | continue; |
173 | pcache[idx].CacheId = item["cacheid"].AsUUID(); | 168 | pcache[idx].CacheId = item["cacheid"].AsUUID(); |
174 | pcache[idx].TextureID = item["textureid"].AsUUID(); | 169 | pcache[idx].TextureID = item["textureid"].AsUUID(); |
175 | /* | 170 | pcache[idx].TextureAsset = null; |
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 | } | 171 | } |
188 | } | 172 | } |
189 | return pcache; | 173 | return pcache; |
@@ -217,6 +201,4 @@ namespace OpenSim.Framework | |||
217 | return null; | 201 | return null; |
218 | } | 202 | } |
219 | } | 203 | } |
220 | |||
221 | |||
222 | } | 204 | } |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 20d30b5..131ae50 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -33,7 +33,6 @@ using System.Globalization; | |||
33 | using System.IO; | 33 | using System.IO; |
34 | using System.IO.Compression; | 34 | using System.IO.Compression; |
35 | using System.Net; | 35 | using System.Net; |
36 | using System.Net.Security; | ||
37 | using System.Reflection; | 36 | using System.Reflection; |
38 | using System.Text; | 37 | using System.Text; |
39 | using System.Web; | 38 | using System.Web; |
@@ -43,9 +42,9 @@ using System.Xml.Linq; | |||
43 | using log4net; | 42 | using log4net; |
44 | using Nwc.XmlRpc; | 43 | using Nwc.XmlRpc; |
45 | using OpenMetaverse.StructuredData; | 44 | using OpenMetaverse.StructuredData; |
45 | using OpenSim.Framework.ServiceAuth; | ||
46 | using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; | 46 | using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper; |
47 | 47 | ||
48 | using OpenSim.Framework.ServiceAuth; | ||
49 | 48 | ||
50 | namespace OpenSim.Framework | 49 | namespace OpenSim.Framework |
51 | { | 50 | { |
@@ -177,7 +176,7 @@ namespace OpenSim.Framework | |||
177 | LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input); | 176 | LogOutgoingDetail(string.Format("RESPONSE {0}: ", reqnum), input); |
178 | } | 177 | } |
179 | 178 | ||
180 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) | 179 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc, bool keepalive = false) |
181 | { | 180 | { |
182 | int reqnum = RequestNumber++; | 181 | int reqnum = RequestNumber++; |
183 | 182 | ||
@@ -198,7 +197,7 @@ namespace OpenSim.Framework | |||
198 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); | 197 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
199 | request.Method = method; | 198 | request.Method = method; |
200 | request.Timeout = timeout; | 199 | request.Timeout = timeout; |
201 | request.KeepAlive = false; | 200 | request.KeepAlive = keepalive; |
202 | request.MaximumAutomaticRedirections = 10; | 201 | request.MaximumAutomaticRedirections = 10; |
203 | request.ReadWriteTimeout = timeout / 2; | 202 | request.ReadWriteTimeout = timeout / 2; |
204 | request.Headers[OSHeaderRequestID] = reqnum.ToString(); | 203 | request.Headers[OSHeaderRequestID] = reqnum.ToString(); |
@@ -1334,16 +1333,42 @@ namespace OpenSim.Framework | |||
1334 | public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength) | 1333 | public static TResponse LogAndDeserialize<TRequest, TResponse>(int reqnum, Stream respStream, long contentLength) |
1335 | { | 1334 | { |
1336 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 1335 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
1337 | |||
1338 | if (WebUtil.DebugLevel >= 5) | 1336 | if (WebUtil.DebugLevel >= 5) |
1339 | { | 1337 | { |
1340 | byte[] data = new byte[contentLength]; | 1338 | const int blockLength = 4096; |
1341 | Util.ReadStream(respStream, data); | 1339 | byte[] dataBuffer = new byte[blockLength]; |
1340 | int curcount; | ||
1341 | using (MemoryStream ms = new MemoryStream(4 * blockLength)) | ||
1342 | { | ||
1343 | if(contentLength == -1) | ||
1344 | { | ||
1345 | while (true) | ||
1346 | { | ||
1347 | curcount = respStream.Read(dataBuffer, 0, blockLength); | ||
1348 | if (curcount <= 0) | ||
1349 | break; | ||
1350 | ms.Write(dataBuffer, 0, curcount); | ||
1351 | } | ||
1352 | } | ||
1353 | else | ||
1354 | { | ||
1355 | int remaining = (int)contentLength; | ||
1356 | while (remaining > 0) | ||
1357 | { | ||
1358 | curcount = respStream.Read(dataBuffer, 0, remaining); | ||
1359 | if (curcount <= 0) | ||
1360 | throw new EndOfStreamException(String.Format("End of stream reached with {0} bytes left to read", remaining)); | ||
1361 | ms.Write(dataBuffer, 0, curcount); | ||
1362 | remaining -= curcount; | ||
1363 | } | ||
1364 | } | ||
1342 | 1365 | ||
1343 | WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(data)); | 1366 | dataBuffer = ms.ToArray(); |
1367 | WebUtil.LogResponseDetail(reqnum, System.Text.Encoding.UTF8.GetString(dataBuffer)); | ||
1344 | 1368 | ||
1345 | using (MemoryStream temp = new MemoryStream(data)) | 1369 | ms.Position = 0; |
1346 | return (TResponse)deserializer.Deserialize(temp); | 1370 | return (TResponse)deserializer.Deserialize(ms); |
1371 | } | ||
1347 | } | 1372 | } |
1348 | else | 1373 | else |
1349 | { | 1374 | { |
@@ -1427,6 +1452,5 @@ namespace OpenSim.Framework | |||
1427 | } | 1452 | } |
1428 | } | 1453 | } |
1429 | } | 1454 | } |
1430 | |||
1431 | } | 1455 | } |
1432 | } | 1456 | } |