diff options
Diffstat (limited to 'OpenSim/Framework')
20 files changed, 962 insertions, 449 deletions
diff --git a/OpenSim/Framework/AssetPermissions.cs b/OpenSim/Framework/AssetPermissions.cs new file mode 100644 index 0000000..4a905c2 --- /dev/null +++ b/OpenSim/Framework/AssetPermissions.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | |||
5 | using Nini.Config; | ||
6 | using log4net; | ||
7 | |||
8 | using OpenMetaverse; | ||
9 | |||
10 | namespace OpenSim.Framework | ||
11 | { | ||
12 | public class AssetPermissions | ||
13 | { | ||
14 | private static readonly ILog m_log = | ||
15 | LogManager.GetLogger( | ||
16 | MethodBase.GetCurrentMethod().DeclaringType); | ||
17 | |||
18 | private bool[] m_DisallowExport, m_DisallowImport; | ||
19 | private string[] m_AssetTypeNames; | ||
20 | |||
21 | public AssetPermissions(IConfig config) | ||
22 | { | ||
23 | Type enumType = typeof(AssetType); | ||
24 | m_AssetTypeNames = Enum.GetNames(enumType); | ||
25 | for (int i = 0; i < m_AssetTypeNames.Length; i++) | ||
26 | m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower(); | ||
27 | int n = Enum.GetValues(enumType).Length; | ||
28 | m_DisallowExport = new bool[n]; | ||
29 | m_DisallowImport = new bool[n]; | ||
30 | |||
31 | LoadPermsFromConfig(config, "DisallowExport", m_DisallowExport); | ||
32 | LoadPermsFromConfig(config, "DisallowImport", m_DisallowImport); | ||
33 | |||
34 | } | ||
35 | |||
36 | private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray) | ||
37 | { | ||
38 | if (assetConfig == null) | ||
39 | return; | ||
40 | |||
41 | string perms = assetConfig.GetString(variable, String.Empty); | ||
42 | string[] parts = perms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); | ||
43 | foreach (string s in parts) | ||
44 | { | ||
45 | int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower()); | ||
46 | if (index >= 0) | ||
47 | bitArray[index] = true; | ||
48 | else | ||
49 | m_log.WarnFormat("[Asset Permissions]: Invalid AssetType {0}", s); | ||
50 | } | ||
51 | |||
52 | } | ||
53 | |||
54 | public bool AllowedExport(sbyte type) | ||
55 | { | ||
56 | string assetTypeName = ((AssetType)type).ToString(); | ||
57 | |||
58 | int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); | ||
59 | if (index >= 0 && m_DisallowExport[index]) | ||
60 | { | ||
61 | m_log.DebugFormat("[Asset Permissions]: Export denied: configuration does not allow export of AssetType {0}", assetTypeName); | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | return true; | ||
66 | } | ||
67 | |||
68 | public bool AllowedImport(sbyte type) | ||
69 | { | ||
70 | string assetTypeName = ((AssetType)type).ToString(); | ||
71 | |||
72 | int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); | ||
73 | if (index >= 0 && m_DisallowImport[index]) | ||
74 | { | ||
75 | m_log.DebugFormat("[Asset Permissions]: Import denied: configuration does not allow import of AssetType {0}", assetTypeName); | ||
76 | return false; | ||
77 | } | ||
78 | |||
79 | return true; | ||
80 | } | ||
81 | |||
82 | |||
83 | } | ||
84 | } | ||
diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs index 79e20fc..31cab4a 100644 --- a/OpenSim/Framework/Cache.cs +++ b/OpenSim/Framework/Cache.cs | |||
@@ -199,7 +199,14 @@ namespace OpenSim.Framework | |||
199 | // | 199 | // |
200 | public class Cache | 200 | public class Cache |
201 | { | 201 | { |
202 | /// <summary> | ||
203 | /// Must only be accessed under lock. | ||
204 | /// </summary> | ||
202 | private List<CacheItemBase> m_Index = new List<CacheItemBase>(); | 205 | private List<CacheItemBase> m_Index = new List<CacheItemBase>(); |
206 | |||
207 | /// <summary> | ||
208 | /// Must only be accessed under m_Index lock. | ||
209 | /// </summary> | ||
203 | private Dictionary<string, CacheItemBase> m_Lookup = | 210 | private Dictionary<string, CacheItemBase> m_Lookup = |
204 | new Dictionary<string, CacheItemBase>(); | 211 | new Dictionary<string, CacheItemBase>(); |
205 | 212 | ||
@@ -320,19 +327,19 @@ namespace OpenSim.Framework | |||
320 | { | 327 | { |
321 | if (m_Lookup.ContainsKey(index)) | 328 | if (m_Lookup.ContainsKey(index)) |
322 | item = m_Lookup[index]; | 329 | item = m_Lookup[index]; |
323 | } | ||
324 | 330 | ||
325 | if (item == null) | 331 | if (item == null) |
326 | { | 332 | { |
333 | Expire(true); | ||
334 | return null; | ||
335 | } | ||
336 | |||
337 | item.hits++; | ||
338 | item.lastUsed = DateTime.Now; | ||
339 | |||
327 | Expire(true); | 340 | Expire(true); |
328 | return null; | ||
329 | } | 341 | } |
330 | 342 | ||
331 | item.hits++; | ||
332 | item.lastUsed = DateTime.Now; | ||
333 | |||
334 | Expire(true); | ||
335 | |||
336 | return item; | 343 | return item; |
337 | } | 344 | } |
338 | 345 | ||
@@ -385,7 +392,10 @@ namespace OpenSim.Framework | |||
385 | // | 392 | // |
386 | public Object Find(Predicate<CacheItemBase> d) | 393 | public Object Find(Predicate<CacheItemBase> d) |
387 | { | 394 | { |
388 | CacheItemBase item = m_Index.Find(d); | 395 | CacheItemBase item; |
396 | |||
397 | lock (m_Index) | ||
398 | item = m_Index.Find(d); | ||
389 | 399 | ||
390 | if (item == null) | 400 | if (item == null) |
391 | return null; | 401 | return null; |
@@ -419,12 +429,12 @@ namespace OpenSim.Framework | |||
419 | public virtual void Store(string index, Object data, Type container, | 429 | public virtual void Store(string index, Object data, Type container, |
420 | Object[] parameters) | 430 | Object[] parameters) |
421 | { | 431 | { |
422 | Expire(false); | ||
423 | |||
424 | CacheItemBase item; | 432 | CacheItemBase item; |
425 | 433 | ||
426 | lock (m_Index) | 434 | lock (m_Index) |
427 | { | 435 | { |
436 | Expire(false); | ||
437 | |||
428 | if (m_Index.Contains(new CacheItemBase(index))) | 438 | if (m_Index.Contains(new CacheItemBase(index))) |
429 | { | 439 | { |
430 | if ((m_Flags & CacheFlags.AllowUpdate) != 0) | 440 | if ((m_Flags & CacheFlags.AllowUpdate) != 0) |
@@ -450,9 +460,17 @@ namespace OpenSim.Framework | |||
450 | m_Index.Add(item); | 460 | m_Index.Add(item); |
451 | m_Lookup[index] = item; | 461 | m_Lookup[index] = item; |
452 | } | 462 | } |
463 | |||
453 | item.Store(data); | 464 | item.Store(data); |
454 | } | 465 | } |
455 | 466 | ||
467 | /// <summary> | ||
468 | /// Expire items as appropriate. | ||
469 | /// </summary> | ||
470 | /// <remarks> | ||
471 | /// Callers must lock m_Index. | ||
472 | /// </remarks> | ||
473 | /// <param name='getting'></param> | ||
456 | protected virtual void Expire(bool getting) | 474 | protected virtual void Expire(bool getting) |
457 | { | 475 | { |
458 | if (getting && (m_Strategy == CacheStrategy.Aggressive)) | 476 | if (getting && (m_Strategy == CacheStrategy.Aggressive)) |
@@ -475,12 +493,10 @@ namespace OpenSim.Framework | |||
475 | 493 | ||
476 | switch (m_Strategy) | 494 | switch (m_Strategy) |
477 | { | 495 | { |
478 | case CacheStrategy.Aggressive: | 496 | case CacheStrategy.Aggressive: |
479 | if (Count < Size) | 497 | if (Count < Size) |
480 | return; | 498 | return; |
481 | 499 | ||
482 | lock (m_Index) | ||
483 | { | ||
484 | m_Index.Sort(new SortLRU()); | 500 | m_Index.Sort(new SortLRU()); |
485 | m_Index.Reverse(); | 501 | m_Index.Reverse(); |
486 | 502 | ||
@@ -490,7 +506,7 @@ namespace OpenSim.Framework | |||
490 | 506 | ||
491 | ExpireDelegate doExpire = OnExpire; | 507 | ExpireDelegate doExpire = OnExpire; |
492 | 508 | ||
493 | if (doExpire != null) | 509 | if (doExpire != null) |
494 | { | 510 | { |
495 | List<CacheItemBase> candidates = | 511 | List<CacheItemBase> candidates = |
496 | m_Index.GetRange(target, Count - target); | 512 | m_Index.GetRange(target, Count - target); |
@@ -513,27 +529,34 @@ namespace OpenSim.Framework | |||
513 | foreach (CacheItemBase item in m_Index) | 529 | foreach (CacheItemBase item in m_Index) |
514 | m_Lookup[item.uuid] = item; | 530 | m_Lookup[item.uuid] = item; |
515 | } | 531 | } |
516 | } | 532 | |
517 | break; | 533 | break; |
518 | default: | 534 | |
519 | break; | 535 | default: |
536 | break; | ||
520 | } | 537 | } |
521 | } | 538 | } |
522 | 539 | ||
523 | public void Invalidate(string uuid) | 540 | public void Invalidate(string uuid) |
524 | { | 541 | { |
525 | if (!m_Lookup.ContainsKey(uuid)) | 542 | lock (m_Index) |
526 | return; | 543 | { |
544 | if (!m_Lookup.ContainsKey(uuid)) | ||
545 | return; | ||
527 | 546 | ||
528 | CacheItemBase item = m_Lookup[uuid]; | 547 | CacheItemBase item = m_Lookup[uuid]; |
529 | m_Lookup.Remove(uuid); | 548 | m_Lookup.Remove(uuid); |
530 | m_Index.Remove(item); | 549 | m_Index.Remove(item); |
550 | } | ||
531 | } | 551 | } |
532 | 552 | ||
533 | public void Clear() | 553 | public void Clear() |
534 | { | 554 | { |
535 | m_Index.Clear(); | 555 | lock (m_Index) |
536 | m_Lookup.Clear(); | 556 | { |
557 | m_Index.Clear(); | ||
558 | m_Lookup.Clear(); | ||
559 | } | ||
537 | } | 560 | } |
538 | } | 561 | } |
539 | } | 562 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs new file mode 100644 index 0000000..2612a50 --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -0,0 +1,114 @@ | |||
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.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | public class ConsoleUtil | ||
36 | { | ||
37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | |||
39 | public const string MinRawConsoleVectorValue = "-~"; | ||
40 | public const string MaxRawConsoleVectorValue = "~"; | ||
41 | |||
42 | public const string VectorSeparator = ","; | ||
43 | public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); | ||
44 | |||
45 | /// <summary> | ||
46 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | ||
47 | /// </summary> | ||
48 | /// <param name='rawConsoleVector'>/param> | ||
49 | /// <param name='vector'></param> | ||
50 | /// <returns></returns> | ||
51 | public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) | ||
52 | { | ||
53 | return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 | ||
58 | /// </summary> | ||
59 | /// <param name='rawConsoleVector'>/param> | ||
60 | /// <param name='vector'></param> | ||
61 | /// <returns></returns> | ||
62 | public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) | ||
63 | { | ||
64 | return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Convert a vector input from the console to an OpenMetaverse.Vector3 | ||
69 | /// </summary> | ||
70 | /// <param name='rawConsoleVector'> | ||
71 | /// A string in the form <x>,<y>,<z> where there is no space between values. | ||
72 | /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value | ||
73 | /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) | ||
74 | /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue | ||
75 | /// Other than that, component values must be numeric. | ||
76 | /// </param> | ||
77 | /// <param name='blankComponentFunc'></param> | ||
78 | /// <param name='vector'></param> | ||
79 | /// <returns></returns> | ||
80 | public static bool TryParseConsoleVector( | ||
81 | string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector) | ||
82 | { | ||
83 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); | ||
84 | |||
85 | if (components.Count < 1 || components.Count > 3) | ||
86 | { | ||
87 | vector = Vector3.Zero; | ||
88 | return false; | ||
89 | } | ||
90 | |||
91 | for (int i = components.Count; i < 3; i++) | ||
92 | components.Add(""); | ||
93 | |||
94 | List<string> semiDigestedComponents | ||
95 | = components.ConvertAll<string>( | ||
96 | c => | ||
97 | { | ||
98 | if (c == "") | ||
99 | return blankComponentFunc.Invoke(c); | ||
100 | else if (c == MaxRawConsoleVectorValue) | ||
101 | return float.MaxValue.ToString(); | ||
102 | else if (c == MinRawConsoleVectorValue) | ||
103 | return float.MinValue.ToString(); | ||
104 | else | ||
105 | return c; | ||
106 | }); | ||
107 | |||
108 | string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); | ||
109 | |||
110 | m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); | ||
111 | |||
112 | return Vector3.TryParse(semiDigestedConsoleVector, out vector); | ||
113 | } | ||
114 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index 1b1aaf2..a2eb5ee 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs | |||
@@ -31,6 +31,7 @@ namespace OpenSim.Framework | |||
31 | public class Constants | 31 | public class Constants |
32 | { | 32 | { |
33 | public const uint RegionSize = 256; | 33 | public const uint RegionSize = 256; |
34 | public const uint RegionHeight = 4096; | ||
34 | public const byte TerrainPatchSize = 16; | 35 | public const byte TerrainPatchSize = 16; |
35 | public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; | 36 | public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; |
36 | 37 | ||
diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs index a6bf6e3..6ae0488 100644 --- a/OpenSim/Framework/GridInstantMessage.cs +++ b/OpenSim/Framework/GridInstantMessage.cs | |||
@@ -44,7 +44,6 @@ namespace OpenSim.Framework | |||
44 | public Vector3 Position; | 44 | public Vector3 Position; |
45 | public byte[] binaryBucket; | 45 | public byte[] binaryBucket; |
46 | 46 | ||
47 | |||
48 | public uint ParentEstateID; | 47 | public uint ParentEstateID; |
49 | public Guid RegionID; | 48 | public Guid RegionID; |
50 | public uint timestamp; | 49 | public uint timestamp; |
@@ -58,7 +57,7 @@ namespace OpenSim.Framework | |||
58 | string _fromAgentName, UUID _toAgentID, | 57 | string _fromAgentName, UUID _toAgentID, |
59 | byte _dialog, bool _fromGroup, string _message, | 58 | byte _dialog, bool _fromGroup, string _message, |
60 | UUID _imSessionID, bool _offline, Vector3 _position, | 59 | UUID _imSessionID, bool _offline, Vector3 _position, |
61 | byte[] _binaryBucket) | 60 | byte[] _binaryBucket, bool addTimestamp) |
62 | { | 61 | { |
63 | fromAgentID = _fromAgentID.Guid; | 62 | fromAgentID = _fromAgentID.Guid; |
64 | fromAgentName = _fromAgentName; | 63 | fromAgentName = _fromAgentName; |
@@ -79,7 +78,9 @@ namespace OpenSim.Framework | |||
79 | ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; | 78 | ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; |
80 | RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; | 79 | RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; |
81 | } | 80 | } |
82 | timestamp = (uint)Util.UnixTimeSinceEpoch(); | 81 | |
82 | if (addTimestamp) | ||
83 | timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
83 | } | 84 | } |
84 | 85 | ||
85 | public GridInstantMessage(IScene scene, UUID _fromAgentID, | 86 | public GridInstantMessage(IScene scene, UUID _fromAgentID, |
@@ -87,7 +88,7 @@ namespace OpenSim.Framework | |||
87 | string _message, bool _offline, | 88 | string _message, bool _offline, |
88 | Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, | 89 | Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, |
89 | _toAgentID, _dialog, false, _message, | 90 | _toAgentID, _dialog, false, _message, |
90 | _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) | 91 | _fromAgentID ^ _toAgentID, _offline, _position, new byte[0], true) |
91 | { | 92 | { |
92 | } | 93 | } |
93 | } | 94 | } |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 5909ce1..4ae533e 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -1046,8 +1046,21 @@ namespace OpenSim.Framework | |||
1046 | 1046 | ||
1047 | void InPacket(object NewPack); | 1047 | void InPacket(object NewPack); |
1048 | void ProcessInPacket(Packet NewPack); | 1048 | void ProcessInPacket(Packet NewPack); |
1049 | |||
1050 | /// <summary> | ||
1051 | /// Close this client | ||
1052 | /// </summary> | ||
1049 | void Close(); | 1053 | void Close(); |
1050 | void Close(bool sendStop); | 1054 | |
1055 | /// <summary> | ||
1056 | /// Close this client | ||
1057 | /// </summary> | ||
1058 | /// <param name='force'> | ||
1059 | /// If true, attempts the close without checking active status. You do not want to try this except as a last | ||
1060 | /// ditch attempt where Active == false but the ScenePresence still exists. | ||
1061 | /// </param> | ||
1062 | void Close(bool sendStop, bool force); | ||
1063 | |||
1051 | void Kick(string message); | 1064 | void Kick(string message); |
1052 | 1065 | ||
1053 | /// <summary> | 1066 | /// <summary> |
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs index a12183c..b3457a6 100644 --- a/OpenSim/Framework/InventoryFolderBase.cs +++ b/OpenSim/Framework/InventoryFolderBase.cs | |||
@@ -73,33 +73,27 @@ namespace OpenSim.Framework | |||
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | public InventoryFolderBase(UUID id) | 76 | public InventoryFolderBase(UUID id) : this() |
77 | { | 77 | { |
78 | ID = id; | 78 | ID = id; |
79 | } | 79 | } |
80 | 80 | ||
81 | public InventoryFolderBase(UUID id, UUID owner) | 81 | public InventoryFolderBase(UUID id, UUID owner) : this(id) |
82 | { | 82 | { |
83 | ID = id; | ||
84 | Owner = owner; | 83 | Owner = owner; |
85 | } | 84 | } |
86 | 85 | ||
87 | public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) | 86 | public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) : this(id, owner) |
88 | { | 87 | { |
89 | ID = id; | ||
90 | Name = name; | 88 | Name = name; |
91 | Owner = owner; | ||
92 | ParentID = parent; | 89 | ParentID = parent; |
93 | } | 90 | } |
94 | 91 | ||
95 | public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) | 92 | public InventoryFolderBase( |
93 | UUID id, string name, UUID owner, short type, UUID parent, ushort version) : this(id, name, owner, parent) | ||
96 | { | 94 | { |
97 | ID = id; | ||
98 | Name = name; | ||
99 | Owner = owner; | ||
100 | Type = type; | 95 | Type = type; |
101 | ParentID = parent; | ||
102 | Version = version; | 96 | Version = version; |
103 | } | 97 | } |
104 | } | 98 | } |
105 | } | 99 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index cdd7cc7..8ac9090 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -355,10 +355,19 @@ Asset service request failures: {3}" + Environment.NewLine, | |||
355 | sb.Append(Environment.NewLine); | 355 | sb.Append(Environment.NewLine); |
356 | sb.Append( | 356 | sb.Append( |
357 | string.Format( | 357 | string.Format( |
358 | "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}", | 358 | "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n", |
359 | inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, | 359 | inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, |
360 | netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); | 360 | netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); |
361 | sb.Append(Environment.NewLine); | 361 | |
362 | foreach (KeyValuePair<string, Stat> kvp in StatsManager.RegisteredStats) | ||
363 | { | ||
364 | Stat stat = kvp.Value; | ||
365 | |||
366 | if (stat.Category == "scene" && stat.Verbosity == StatVerbosity.Info) | ||
367 | { | ||
368 | sb.AppendFormat("Slow frames ({0}): {1}\n", stat.Container, stat.Value); | ||
369 | } | ||
370 | } | ||
362 | 371 | ||
363 | /* | 372 | /* |
364 | sb.Append(Environment.NewLine); | 373 | sb.Append(Environment.NewLine); |
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index d78fa6a..b5dc24f 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -25,6 +25,9 @@ | |||
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 System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
28 | namespace OpenSim.Framework.Monitoring | 31 | namespace OpenSim.Framework.Monitoring |
29 | { | 32 | { |
30 | /// <summary> | 33 | /// <summary> |
@@ -32,6 +35,14 @@ namespace OpenSim.Framework.Monitoring | |||
32 | /// </summary> | 35 | /// </summary> |
33 | public class StatsManager | 36 | public class StatsManager |
34 | { | 37 | { |
38 | /// <summary> | ||
39 | /// Registered stats. | ||
40 | /// </summary> | ||
41 | /// <remarks> | ||
42 | /// Do not add or remove from this dictionary. | ||
43 | /// </remarks> | ||
44 | public static Dictionary<string, Stat> RegisteredStats = new Dictionary<string, Stat>(); | ||
45 | |||
35 | private static AssetStatsCollector assetStats; | 46 | private static AssetStatsCollector assetStats; |
36 | private static UserStatsCollector userStats; | 47 | private static UserStatsCollector userStats; |
37 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); | 48 | private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); |
@@ -61,5 +72,139 @@ namespace OpenSim.Framework.Monitoring | |||
61 | 72 | ||
62 | return userStats; | 73 | return userStats; |
63 | } | 74 | } |
75 | |||
76 | public static bool RegisterStat(Stat stat) | ||
77 | { | ||
78 | lock (RegisteredStats) | ||
79 | { | ||
80 | if (RegisteredStats.ContainsKey(stat.UniqueName)) | ||
81 | { | ||
82 | // XXX: For now just return false. This is to avoid problems in regression tests where all tests | ||
83 | // in a class are run in the same instance of the VM. | ||
84 | return false; | ||
85 | |||
86 | // throw new Exception( | ||
87 | // "StatsManager already contains stat with ShortName {0} in Category {1}", stat.ShortName, stat.Category); | ||
88 | } | ||
89 | |||
90 | // We take a replace-on-write approach here so that we don't need to generate a new Dictionary | ||
91 | Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats); | ||
92 | newRegisteredStats[stat.UniqueName] = stat; | ||
93 | RegisteredStats = newRegisteredStats; | ||
94 | } | ||
95 | |||
96 | return true; | ||
97 | } | ||
98 | |||
99 | public static bool DeregisterStat(Stat stat) | ||
100 | { | ||
101 | lock (RegisteredStats) | ||
102 | { | ||
103 | if (!RegisteredStats.ContainsKey(stat.UniqueName)) | ||
104 | return false; | ||
105 | |||
106 | Dictionary<string, Stat> newRegisteredStats = new Dictionary<string, Stat>(RegisteredStats); | ||
107 | newRegisteredStats.Remove(stat.UniqueName); | ||
108 | RegisteredStats = newRegisteredStats; | ||
109 | |||
110 | return true; | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Verbosity of stat. | ||
117 | /// </summary> | ||
118 | /// <remarks> | ||
119 | /// Info will always be displayed. | ||
120 | /// </remarks> | ||
121 | public enum StatVerbosity | ||
122 | { | ||
123 | Debug, | ||
124 | Info | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Holds individual static details | ||
129 | /// </summary> | ||
130 | public class Stat | ||
131 | { | ||
132 | /// <summary> | ||
133 | /// Unique stat name used for indexing. Each ShortName in a Category must be unique. | ||
134 | /// </summary> | ||
135 | public string UniqueName { get; private set; } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Category of this stat (e.g. cache, scene, etc). | ||
139 | /// </summary> | ||
140 | public string Category { get; private set; } | ||
141 | |||
142 | /// <summary> | ||
143 | /// Containing name for this stat. | ||
144 | /// FIXME: In the case of a scene, this is currently the scene name (though this leaves | ||
145 | /// us with a to-be-resolved problem of non-unique region names). | ||
146 | /// </summary> | ||
147 | /// <value> | ||
148 | /// The container. | ||
149 | /// </value> | ||
150 | public string Container { get; private set; } | ||
151 | |||
152 | public StatVerbosity Verbosity { get; private set; } | ||
153 | public string ShortName { get; private set; } | ||
154 | public string Name { get; private set; } | ||
155 | public string Description { get; private set; } | ||
156 | public virtual string UnitName { get; private set; } | ||
157 | |||
158 | public virtual double Value { get; set; } | ||
159 | |||
160 | public Stat( | ||
161 | string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) | ||
162 | { | ||
163 | ShortName = shortName; | ||
164 | Name = name; | ||
165 | UnitName = unitName; | ||
166 | Category = category; | ||
167 | Container = container; | ||
168 | Verbosity = verbosity; | ||
169 | Description = description; | ||
170 | |||
171 | UniqueName = GenUniqueName(Container, Category, ShortName); | ||
172 | } | ||
173 | |||
174 | public static string GenUniqueName(string container, string category, string shortName) | ||
175 | { | ||
176 | return string.Format("{0}+{1}+{2}", container, category, shortName); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | public class PercentageStat : Stat | ||
181 | { | ||
182 | public int Antecedent { get; set; } | ||
183 | public int Consequent { get; set; } | ||
184 | |||
185 | public override double Value | ||
186 | { | ||
187 | get | ||
188 | { | ||
189 | int c = Consequent; | ||
190 | |||
191 | // Avoid any chance of a multi-threaded divide-by-zero | ||
192 | if (c == 0) | ||
193 | return 0; | ||
194 | |||
195 | return (double)Antecedent / c; | ||
196 | } | ||
197 | |||
198 | set | ||
199 | { | ||
200 | throw new Exception("Cannot set value on a PercentageStat"); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | public PercentageStat( | ||
205 | string shortName, string name, string category, string container, StatVerbosity verbosity, string description) | ||
206 | : base(shortName, name, " %", category, container, verbosity, description) | ||
207 | { | ||
208 | } | ||
64 | } | 209 | } |
65 | } \ No newline at end of file | 210 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index b709baa..eaddb8c 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -89,6 +89,17 @@ namespace OpenSim.Framework.Monitoring | |||
89 | FirstTick = Environment.TickCount & Int32.MaxValue; | 89 | FirstTick = Environment.TickCount & Int32.MaxValue; |
90 | LastTick = FirstTick; | 90 | LastTick = FirstTick; |
91 | } | 91 | } |
92 | |||
93 | public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) | ||
94 | { | ||
95 | Thread = previousTwi.Thread; | ||
96 | FirstTick = previousTwi.FirstTick; | ||
97 | LastTick = previousTwi.LastTick; | ||
98 | Timeout = previousTwi.Timeout; | ||
99 | IsTimedOut = previousTwi.IsTimedOut; | ||
100 | AlarmIfTimeout = previousTwi.AlarmIfTimeout; | ||
101 | AlarmMethod = previousTwi.AlarmMethod; | ||
102 | } | ||
92 | } | 103 | } |
93 | 104 | ||
94 | /// <summary> | 105 | /// <summary> |
@@ -335,7 +346,9 @@ namespace OpenSim.Framework.Monitoring | |||
335 | if (callbackInfos == null) | 346 | if (callbackInfos == null) |
336 | callbackInfos = new List<ThreadWatchdogInfo>(); | 347 | callbackInfos = new List<ThreadWatchdogInfo>(); |
337 | 348 | ||
338 | callbackInfos.Add(threadInfo); | 349 | // Send a copy of the watchdog info to prevent race conditions where the watchdog |
350 | // thread updates the monitoring info after an alarm has been sent out. | ||
351 | callbackInfos.Add(new ThreadWatchdogInfo(threadInfo)); | ||
339 | } | 352 | } |
340 | } | 353 | } |
341 | } | 354 | } |
diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs deleted file mode 100644 index 41d17c5..0000000 --- a/OpenSim/Framework/PacketPool.cs +++ /dev/null | |||
@@ -1,247 +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.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using OpenMetaverse; | ||
32 | using OpenMetaverse.Packets; | ||
33 | using log4net; | ||
34 | |||
35 | namespace OpenSim.Framework | ||
36 | { | ||
37 | |||
38 | public sealed class PacketPool | ||
39 | { | ||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | private static readonly PacketPool instance = new PacketPool(); | ||
43 | |||
44 | private bool packetPoolEnabled = true; | ||
45 | private bool dataBlockPoolEnabled = true; | ||
46 | |||
47 | private readonly Dictionary<PacketType, Stack<Packet>> pool = new Dictionary<PacketType, Stack<Packet>>(); | ||
48 | |||
49 | private static Dictionary<Type, Stack<Object>> DataBlocks = | ||
50 | new Dictionary<Type, Stack<Object>>(); | ||
51 | |||
52 | static PacketPool() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | public static PacketPool Instance | ||
57 | { | ||
58 | get { return instance; } | ||
59 | } | ||
60 | |||
61 | public bool RecyclePackets | ||
62 | { | ||
63 | set { packetPoolEnabled = value; } | ||
64 | get { return packetPoolEnabled; } | ||
65 | } | ||
66 | |||
67 | public bool RecycleDataBlocks | ||
68 | { | ||
69 | set { dataBlockPoolEnabled = value; } | ||
70 | get { return dataBlockPoolEnabled; } | ||
71 | } | ||
72 | |||
73 | public Packet GetPacket(PacketType type) | ||
74 | { | ||
75 | Packet packet; | ||
76 | |||
77 | if (!packetPoolEnabled) | ||
78 | return Packet.BuildPacket(type); | ||
79 | |||
80 | lock (pool) | ||
81 | { | ||
82 | if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0) | ||
83 | { | ||
84 | // Creating a new packet if we cannot reuse an old package | ||
85 | packet = Packet.BuildPacket(type); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | // Recycle old packages | ||
90 | packet = (pool[type]).Pop(); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | return packet; | ||
95 | } | ||
96 | |||
97 | // private byte[] decoded_header = new byte[10]; | ||
98 | private static PacketType GetType(byte[] bytes) | ||
99 | { | ||
100 | byte[] decoded_header = new byte[10 + 8]; | ||
101 | ushort id; | ||
102 | PacketFrequency freq; | ||
103 | |||
104 | if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0) | ||
105 | { | ||
106 | Helpers.ZeroDecode(bytes, 16, decoded_header); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10); | ||
111 | } | ||
112 | |||
113 | if (decoded_header[6] == 0xFF) | ||
114 | { | ||
115 | if (decoded_header[7] == 0xFF) | ||
116 | { | ||
117 | id = (ushort) ((decoded_header[8] << 8) + decoded_header[9]); | ||
118 | freq = PacketFrequency.Low; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | id = decoded_header[7]; | ||
123 | freq = PacketFrequency.Medium; | ||
124 | } | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | id = decoded_header[6]; | ||
129 | freq = PacketFrequency.High; | ||
130 | } | ||
131 | |||
132 | return Packet.GetType(id, freq); | ||
133 | } | ||
134 | |||
135 | public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) | ||
136 | { | ||
137 | PacketType type = GetType(bytes); | ||
138 | |||
139 | Array.Clear(zeroBuffer, 0, zeroBuffer.Length); | ||
140 | |||
141 | int i = 0; | ||
142 | Packet packet = GetPacket(type); | ||
143 | if (packet == null) | ||
144 | m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type); | ||
145 | else | ||
146 | packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); | ||
147 | |||
148 | return packet; | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Return a packet to the packet pool | ||
153 | /// </summary> | ||
154 | /// <param name="packet"></param> | ||
155 | public void ReturnPacket(Packet packet) | ||
156 | { | ||
157 | if (dataBlockPoolEnabled) | ||
158 | { | ||
159 | switch (packet.Type) | ||
160 | { | ||
161 | case PacketType.ObjectUpdate: | ||
162 | ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; | ||
163 | |||
164 | foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) | ||
165 | ReturnDataBlock<ObjectUpdatePacket.ObjectDataBlock>(oupod); | ||
166 | |||
167 | oup.ObjectData = null; | ||
168 | break; | ||
169 | |||
170 | case PacketType.ImprovedTerseObjectUpdate: | ||
171 | ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; | ||
172 | |||
173 | foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) | ||
174 | ReturnDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(itoupod); | ||
175 | |||
176 | itoup.ObjectData = null; | ||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | if (packetPoolEnabled) | ||
182 | { | ||
183 | switch (packet.Type) | ||
184 | { | ||
185 | // List pooling packets here | ||
186 | case PacketType.PacketAck: | ||
187 | case PacketType.ObjectUpdate: | ||
188 | case PacketType.ImprovedTerseObjectUpdate: | ||
189 | lock (pool) | ||
190 | { | ||
191 | PacketType type = packet.Type; | ||
192 | |||
193 | if (!pool.ContainsKey(type)) | ||
194 | { | ||
195 | pool[type] = new Stack<Packet>(); | ||
196 | } | ||
197 | |||
198 | if ((pool[type]).Count < 50) | ||
199 | { | ||
200 | (pool[type]).Push(packet); | ||
201 | } | ||
202 | } | ||
203 | break; | ||
204 | |||
205 | // Other packets wont pool | ||
206 | default: | ||
207 | return; | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | public static T GetDataBlock<T>() where T: new() | ||
213 | { | ||
214 | lock (DataBlocks) | ||
215 | { | ||
216 | Stack<Object> s; | ||
217 | |||
218 | if (DataBlocks.TryGetValue(typeof(T), out s)) | ||
219 | { | ||
220 | if (s.Count > 0) | ||
221 | return (T)s.Pop(); | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | DataBlocks[typeof(T)] = new Stack<Object>(); | ||
226 | } | ||
227 | |||
228 | return new T(); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | public static void ReturnDataBlock<T>(T block) where T: new() | ||
233 | { | ||
234 | if (block == null) | ||
235 | return; | ||
236 | |||
237 | lock (DataBlocks) | ||
238 | { | ||
239 | if (!DataBlocks.ContainsKey(typeof(T))) | ||
240 | DataBlocks[typeof(T)] = new Stack<Object>(); | ||
241 | |||
242 | if (DataBlocks[typeof(T)].Count < 50) | ||
243 | DataBlocks[typeof(T)].Push(block); | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | } | ||
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 4bde7be..e7bed6a 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -122,10 +122,13 @@ namespace OpenSim.Framework | |||
122 | public UUID lastMapUUID = UUID.Zero; | 122 | public UUID lastMapUUID = UUID.Zero; |
123 | public string lastMapRefresh = "0"; | 123 | public string lastMapRefresh = "0"; |
124 | 124 | ||
125 | private float m_nonphysPrimMin = 0; | ||
125 | private int m_nonphysPrimMax = 0; | 126 | private int m_nonphysPrimMax = 0; |
127 | private float m_physPrimMin = 0; | ||
126 | private int m_physPrimMax = 0; | 128 | private int m_physPrimMax = 0; |
127 | private bool m_clampPrimSize = false; | 129 | private bool m_clampPrimSize = false; |
128 | private int m_objectCapacity = 0; | 130 | private int m_objectCapacity = 0; |
131 | private int m_linksetCapacity = 0; | ||
129 | private int m_agentCapacity = 0; | 132 | private int m_agentCapacity = 0; |
130 | private string m_regionType = String.Empty; | 133 | private string m_regionType = String.Empty; |
131 | private RegionLightShareData m_windlight = new RegionLightShareData(); | 134 | private RegionLightShareData m_windlight = new RegionLightShareData(); |
@@ -287,11 +290,21 @@ namespace OpenSim.Framework | |||
287 | set { m_windlight = value; } | 290 | set { m_windlight = value; } |
288 | } | 291 | } |
289 | 292 | ||
293 | public float NonphysPrimMin | ||
294 | { | ||
295 | get { return m_nonphysPrimMin; } | ||
296 | } | ||
297 | |||
290 | public int NonphysPrimMax | 298 | public int NonphysPrimMax |
291 | { | 299 | { |
292 | get { return m_nonphysPrimMax; } | 300 | get { return m_nonphysPrimMax; } |
293 | } | 301 | } |
294 | 302 | ||
303 | public float PhysPrimMin | ||
304 | { | ||
305 | get { return m_physPrimMin; } | ||
306 | } | ||
307 | |||
295 | public int PhysPrimMax | 308 | public int PhysPrimMax |
296 | { | 309 | { |
297 | get { return m_physPrimMax; } | 310 | get { return m_physPrimMax; } |
@@ -307,6 +320,11 @@ namespace OpenSim.Framework | |||
307 | get { return m_objectCapacity; } | 320 | get { return m_objectCapacity; } |
308 | } | 321 | } |
309 | 322 | ||
323 | public int LinksetCapacity | ||
324 | { | ||
325 | get { return m_linksetCapacity; } | ||
326 | } | ||
327 | |||
310 | public int AgentCapacity | 328 | public int AgentCapacity |
311 | { | 329 | { |
312 | get { return m_agentCapacity; } | 330 | get { return m_agentCapacity; } |
@@ -625,16 +643,31 @@ namespace OpenSim.Framework | |||
625 | m_regionType = config.GetString("RegionType", String.Empty); | 643 | m_regionType = config.GetString("RegionType", String.Empty); |
626 | allKeys.Remove("RegionType"); | 644 | allKeys.Remove("RegionType"); |
627 | 645 | ||
628 | // Prim stuff | 646 | #region Prim stuff |
629 | // | 647 | |
630 | m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); | 648 | m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0); |
631 | allKeys.Remove("NonphysicalPrimMax"); | 649 | allKeys.Remove("NonPhysicalPrimMin"); |
650 | |||
651 | m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0); | ||
652 | allKeys.Remove("NonPhysicalPrimMax"); | ||
653 | |||
654 | m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); | ||
655 | allKeys.Remove("PhysicalPrimMin"); | ||
656 | |||
632 | m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); | 657 | m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); |
633 | allKeys.Remove("PhysicalPrimMax"); | 658 | allKeys.Remove("PhysicalPrimMax"); |
659 | |||
634 | m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); | 660 | m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); |
635 | allKeys.Remove("ClampPrimSize"); | 661 | allKeys.Remove("ClampPrimSize"); |
662 | |||
636 | m_objectCapacity = config.GetInt("MaxPrims", 15000); | 663 | m_objectCapacity = config.GetInt("MaxPrims", 15000); |
637 | allKeys.Remove("MaxPrims"); | 664 | allKeys.Remove("MaxPrims"); |
665 | |||
666 | m_linksetCapacity = config.GetInt("LinksetPrims", 0); | ||
667 | allKeys.Remove("LinksetPrims"); | ||
668 | |||
669 | #endregion | ||
670 | |||
638 | m_agentCapacity = config.GetInt("MaxAgents", 100); | 671 | m_agentCapacity = config.GetInt("MaxAgents", 100); |
639 | allKeys.Remove("MaxAgents"); | 672 | allKeys.Remove("MaxAgents"); |
640 | 673 | ||
@@ -673,16 +706,27 @@ namespace OpenSim.Framework | |||
673 | 706 | ||
674 | config.Set("ExternalHostName", m_externalHostName); | 707 | config.Set("ExternalHostName", m_externalHostName); |
675 | 708 | ||
676 | if (m_nonphysPrimMax != 0) | 709 | if (m_nonphysPrimMin > 0) |
710 | config.Set("NonphysicalPrimMax", m_nonphysPrimMin); | ||
711 | |||
712 | if (m_nonphysPrimMax > 0) | ||
677 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); | 713 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); |
678 | if (m_physPrimMax != 0) | 714 | |
715 | if (m_physPrimMin > 0) | ||
716 | config.Set("PhysicalPrimMax", m_physPrimMin); | ||
717 | |||
718 | if (m_physPrimMax > 0) | ||
679 | config.Set("PhysicalPrimMax", m_physPrimMax); | 719 | config.Set("PhysicalPrimMax", m_physPrimMax); |
720 | |||
680 | config.Set("ClampPrimSize", m_clampPrimSize.ToString()); | 721 | config.Set("ClampPrimSize", m_clampPrimSize.ToString()); |
681 | 722 | ||
682 | if (m_objectCapacity != 0) | 723 | if (m_objectCapacity > 0) |
683 | config.Set("MaxPrims", m_objectCapacity); | 724 | config.Set("MaxPrims", m_objectCapacity); |
684 | 725 | ||
685 | if (m_agentCapacity != 0) | 726 | if (m_linksetCapacity > 0) |
727 | config.Set("LinksetPrims", m_linksetCapacity); | ||
728 | |||
729 | if (m_agentCapacity > 0) | ||
686 | config.Set("MaxAgents", m_agentCapacity); | 730 | config.Set("MaxAgents", m_agentCapacity); |
687 | 731 | ||
688 | if (ScopeID != UUID.Zero) | 732 | if (ScopeID != UUID.Zero) |
@@ -759,9 +803,15 @@ namespace OpenSim.Framework | |||
759 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 803 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
760 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); | 804 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); |
761 | 805 | ||
806 | configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
807 | "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); | ||
808 | |||
762 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 809 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
763 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); | 810 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); |
764 | 811 | ||
812 | configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
813 | "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); | ||
814 | |||
765 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 815 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
766 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); | 816 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); |
767 | 817 | ||
@@ -771,6 +821,9 @@ namespace OpenSim.Framework | |||
771 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 821 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
772 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); | 822 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); |
773 | 823 | ||
824 | configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | ||
825 | "Max prims an object will hold", m_linksetCapacity.ToString(), true); | ||
826 | |||
774 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 827 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
775 | "Max avatars this sim will hold", m_agentCapacity.ToString(), true); | 828 | "Max avatars this sim will hold", m_agentCapacity.ToString(), true); |
776 | 829 | ||
@@ -892,6 +945,9 @@ namespace OpenSim.Framework | |||
892 | case "object_capacity": | 945 | case "object_capacity": |
893 | m_objectCapacity = (int)configuration_result; | 946 | m_objectCapacity = (int)configuration_result; |
894 | break; | 947 | break; |
948 | case "linkset_capacity": | ||
949 | m_linksetCapacity = (int)configuration_result; | ||
950 | break; | ||
895 | case "agent_capacity": | 951 | case "agent_capacity": |
896 | m_agentCapacity = (int)configuration_result; | 952 | m_agentCapacity = (int)configuration_result; |
897 | break; | 953 | break; |
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 2c5e001..48f1c4f 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs | |||
@@ -53,6 +53,11 @@ namespace OpenSim.Framework.Serialization | |||
53 | public const string INVENTORY_PATH = "inventory/"; | 53 | public const string INVENTORY_PATH = "inventory/"; |
54 | 54 | ||
55 | /// <value> | 55 | /// <value> |
56 | /// Path for regions in a multi-region archive | ||
57 | /// </value> | ||
58 | public const string REGIONS_PATH = "regions/"; | ||
59 | |||
60 | /// <value> | ||
56 | /// Path for the prims file | 61 | /// Path for the prims file |
57 | /// </value> | 62 | /// </value> |
58 | public const string OBJECTS_PATH = "objects/"; | 63 | public const string OBJECTS_PATH = "objects/"; |
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs index d31d27c..fa7160f 100644 --- a/OpenSim/Framework/Serialization/External/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs | |||
@@ -65,9 +65,14 @@ namespace OpenSim.Framework.Serialization | |||
65 | 65 | ||
66 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); | 66 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); |
67 | if (account != null) | 67 | if (account != null) |
68 | { | ||
68 | return MakeOspa(account.FirstName, account.LastName); | 69 | return MakeOspa(account.FirstName, account.LastName); |
70 | } | ||
69 | // else | 71 | // else |
72 | // { | ||
70 | // m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); | 73 | // m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); |
74 | // System.Console.WriteLine("[OSP RESOLVER]: No user account for {0}", userId); | ||
75 | // } | ||
71 | 76 | ||
72 | return null; | 77 | return null; |
73 | } | 78 | } |
@@ -79,10 +84,13 @@ namespace OpenSim.Framework.Serialization | |||
79 | /// <returns></returns> | 84 | /// <returns></returns> |
80 | public static string MakeOspa(string firstName, string lastName) | 85 | public static string MakeOspa(string firstName, string lastName) |
81 | { | 86 | { |
82 | // m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName); | 87 | string ospa |
88 | = OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; | ||
89 | |||
90 | // m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); | ||
91 | // System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); | ||
83 | 92 | ||
84 | return | 93 | return ospa; |
85 | OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; | ||
86 | } | 94 | } |
87 | 95 | ||
88 | /// <summary> | 96 | /// <summary> |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 788a0b9..b3e31a6 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -54,8 +54,23 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); | 55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// Gets or sets the debug level. | ||
59 | /// </summary> | ||
60 | /// <value> | ||
61 | /// See MainServer.DebugLevel. | ||
62 | /// </value> | ||
57 | public int DebugLevel { get; set; } | 63 | public int DebugLevel { get; set; } |
58 | 64 | ||
65 | /// <summary> | ||
66 | /// Request number for diagnostic purposes. | ||
67 | /// </summary> | ||
68 | /// <remarks> | ||
69 | /// This is an internal number. In some debug situations an external number may also be supplied in the | ||
70 | /// opensim-request-id header but we are not currently logging this. | ||
71 | /// </remarks> | ||
72 | public int RequestNumber { get; private set; } | ||
73 | |||
59 | private volatile int NotSocketErrors = 0; | 74 | private volatile int NotSocketErrors = 0; |
60 | public volatile bool HTTPDRunning = false; | 75 | public volatile bool HTTPDRunning = false; |
61 | 76 | ||
@@ -67,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
67 | protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); | 82 | protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); |
68 | protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); | 83 | protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); |
69 | protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); | 84 | protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); |
70 | protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); | 85 | // protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); |
71 | protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = | 86 | protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = |
72 | new Dictionary<string, PollServiceEventArgs>(); | 87 | new Dictionary<string, PollServiceEventArgs>(); |
73 | 88 | ||
@@ -245,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
245 | return new List<string>(m_pollHandlers.Keys); | 260 | return new List<string>(m_pollHandlers.Keys); |
246 | } | 261 | } |
247 | 262 | ||
248 | // Note that the agent string is provided simply to differentiate | 263 | // // Note that the agent string is provided simply to differentiate |
249 | // the handlers - it is NOT required to be an actual agent header | 264 | // // the handlers - it is NOT required to be an actual agent header |
250 | // value. | 265 | // // value. |
251 | public bool AddAgentHandler(string agent, IHttpAgentHandler handler) | 266 | // public bool AddAgentHandler(string agent, IHttpAgentHandler handler) |
252 | { | 267 | // { |
253 | lock (m_agentHandlers) | 268 | // lock (m_agentHandlers) |
254 | { | 269 | // { |
255 | if (!m_agentHandlers.ContainsKey(agent)) | 270 | // if (!m_agentHandlers.ContainsKey(agent)) |
256 | { | 271 | // { |
257 | m_agentHandlers.Add(agent, handler); | 272 | // m_agentHandlers.Add(agent, handler); |
258 | return true; | 273 | // return true; |
259 | } | 274 | // } |
260 | } | 275 | // } |
261 | 276 | // | |
262 | //must already have a handler for that path so return false | 277 | // //must already have a handler for that path so return false |
263 | return false; | 278 | // return false; |
264 | } | 279 | // } |
265 | 280 | // | |
266 | public List<string> GetAgentHandlerKeys() | 281 | // public List<string> GetAgentHandlerKeys() |
267 | { | 282 | // { |
268 | lock (m_agentHandlers) | 283 | // lock (m_agentHandlers) |
269 | return new List<string>(m_agentHandlers.Keys); | 284 | // return new List<string>(m_agentHandlers.Keys); |
270 | } | 285 | // } |
271 | 286 | ||
272 | public bool AddLLSDHandler(string path, LLSDMethod handler) | 287 | public bool AddLLSDHandler(string path, LLSDMethod handler) |
273 | { | 288 | { |
@@ -296,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
296 | 311 | ||
297 | private void OnRequest(object source, RequestEventArgs args) | 312 | private void OnRequest(object source, RequestEventArgs args) |
298 | { | 313 | { |
314 | RequestNumber++; | ||
315 | |||
299 | try | 316 | try |
300 | { | 317 | { |
301 | IHttpClientContext context = (IHttpClientContext)source; | 318 | IHttpClientContext context = (IHttpClientContext)source; |
@@ -406,7 +423,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
406 | string requestMethod = request.HttpMethod; | 423 | string requestMethod = request.HttpMethod; |
407 | string uriString = request.RawUrl; | 424 | string uriString = request.RawUrl; |
408 | 425 | ||
409 | // string reqnum = "unknown"; | ||
410 | int requestStartTick = Environment.TickCount; | 426 | int requestStartTick = Environment.TickCount; |
411 | 427 | ||
412 | // Will be adjusted later on. | 428 | // Will be adjusted later on. |
@@ -423,22 +439,22 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
423 | 439 | ||
424 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); | 440 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); |
425 | 441 | ||
426 | // This is the REST agent interface. We require an agent to properly identify | 442 | // // This is the REST agent interface. We require an agent to properly identify |
427 | // itself. If the REST handler recognizes the prefix it will attempt to | 443 | // // itself. If the REST handler recognizes the prefix it will attempt to |
428 | // satisfy the request. If it is not recognizable, and no damage has occurred | 444 | // // satisfy the request. If it is not recognizable, and no damage has occurred |
429 | // the request can be passed through to the other handlers. This is a low | 445 | // // the request can be passed through to the other handlers. This is a low |
430 | // probability event; if a request is matched it is normally expected to be | 446 | // // probability event; if a request is matched it is normally expected to be |
431 | // handled | 447 | // // handled |
432 | IHttpAgentHandler agentHandler; | 448 | // IHttpAgentHandler agentHandler; |
433 | 449 | // | |
434 | if (TryGetAgentHandler(request, response, out agentHandler)) | 450 | // if (TryGetAgentHandler(request, response, out agentHandler)) |
435 | { | 451 | // { |
436 | if (HandleAgentRequest(agentHandler, request, response)) | 452 | // if (HandleAgentRequest(agentHandler, request, response)) |
437 | { | 453 | // { |
438 | requestEndTick = Environment.TickCount; | 454 | // requestEndTick = Environment.TickCount; |
439 | return; | 455 | // return; |
440 | } | 456 | // } |
441 | } | 457 | // } |
442 | 458 | ||
443 | //response.KeepAlive = true; | 459 | //response.KeepAlive = true; |
444 | response.SendChunked = false; | 460 | response.SendChunked = false; |
@@ -450,9 +466,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
450 | if (TryGetStreamHandler(handlerKey, out requestHandler)) | 466 | if (TryGetStreamHandler(handlerKey, out requestHandler)) |
451 | { | 467 | { |
452 | if (DebugLevel >= 3) | 468 | if (DebugLevel >= 3) |
453 | m_log.DebugFormat( | 469 | LogIncomingToStreamHandler(request, requestHandler); |
454 | "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", | ||
455 | request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); | ||
456 | 470 | ||
457 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. | 471 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. |
458 | 472 | ||
@@ -532,8 +546,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
532 | 546 | ||
533 | if (DebugLevel >= 3) | 547 | if (DebugLevel >= 3) |
534 | m_log.DebugFormat( | 548 | m_log.DebugFormat( |
535 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | 549 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", |
536 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | 550 | RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); |
537 | 551 | ||
538 | buffer = HandleHTTPRequest(request, response); | 552 | buffer = HandleHTTPRequest(request, response); |
539 | break; | 553 | break; |
@@ -544,8 +558,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
544 | 558 | ||
545 | if (DebugLevel >= 3) | 559 | if (DebugLevel >= 3) |
546 | m_log.DebugFormat( | 560 | m_log.DebugFormat( |
547 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | 561 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", |
548 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | 562 | RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); |
549 | 563 | ||
550 | buffer = HandleLLSDRequests(request, response); | 564 | buffer = HandleLLSDRequests(request, response); |
551 | break; | 565 | break; |
@@ -564,9 +578,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
564 | if (DoWeHaveALLSDHandler(request.RawUrl)) | 578 | if (DoWeHaveALLSDHandler(request.RawUrl)) |
565 | { | 579 | { |
566 | if (DebugLevel >= 3) | 580 | if (DebugLevel >= 3) |
567 | m_log.DebugFormat( | 581 | LogIncomingToContentTypeHandler(request); |
568 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
569 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
570 | 582 | ||
571 | buffer = HandleLLSDRequests(request, response); | 583 | buffer = HandleLLSDRequests(request, response); |
572 | } | 584 | } |
@@ -574,18 +586,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
574 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) | 586 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) |
575 | { | 587 | { |
576 | if (DebugLevel >= 3) | 588 | if (DebugLevel >= 3) |
577 | m_log.DebugFormat( | 589 | LogIncomingToContentTypeHandler(request); |
578 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
579 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
580 | 590 | ||
581 | buffer = HandleHTTPRequest(request, response); | 591 | buffer = HandleHTTPRequest(request, response); |
582 | } | 592 | } |
583 | else | 593 | else |
584 | { | 594 | { |
585 | if (DebugLevel >= 3) | 595 | if (DebugLevel >= 3) |
586 | m_log.DebugFormat( | 596 | LogIncomingToXmlRpcHandler(request); |
587 | "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", | ||
588 | request.HttpMethod, request.Url.PathAndQuery); | ||
589 | 597 | ||
590 | // generic login request. | 598 | // generic login request. |
591 | buffer = HandleXmlRpcRequests(request, response); | 599 | buffer = HandleXmlRpcRequests(request, response); |
@@ -629,11 +637,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
629 | } | 637 | } |
630 | catch (IOException e) | 638 | catch (IOException e) |
631 | { | 639 | { |
632 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); | 640 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); |
633 | } | 641 | } |
634 | catch (Exception e) | 642 | catch (Exception e) |
635 | { | 643 | { |
636 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); | 644 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); |
637 | SendHTML500(response); | 645 | SendHTML500(response); |
638 | } | 646 | } |
639 | finally | 647 | finally |
@@ -644,17 +652,93 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
644 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) | 652 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
645 | { | 653 | { |
646 | m_log.InfoFormat( | 654 | m_log.InfoFormat( |
647 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", | 655 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
656 | RequestNumber, | ||
648 | requestMethod, | 657 | requestMethod, |
649 | uriString, | 658 | uriString, |
650 | requestHandler != null ? requestHandler.Name : "", | 659 | requestHandler != null ? requestHandler.Name : "", |
651 | requestHandler != null ? requestHandler.Description : "", | 660 | requestHandler != null ? requestHandler.Description : "", |
652 | request.RemoteIPEndPoint.ToString(), | 661 | request.RemoteIPEndPoint, |
662 | tickdiff); | ||
663 | } | ||
664 | else if (DebugLevel >= 4) | ||
665 | { | ||
666 | m_log.DebugFormat( | ||
667 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms", | ||
668 | RequestNumber, | ||
669 | Port, | ||
653 | tickdiff); | 670 | tickdiff); |
654 | } | 671 | } |
655 | } | 672 | } |
656 | } | 673 | } |
657 | 674 | ||
675 | private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) | ||
676 | { | ||
677 | m_log.DebugFormat( | ||
678 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}", | ||
679 | RequestNumber, | ||
680 | Port, | ||
681 | request.HttpMethod, | ||
682 | request.Url.PathAndQuery, | ||
683 | requestHandler.Name, | ||
684 | requestHandler.Description, | ||
685 | request.RemoteIPEndPoint); | ||
686 | |||
687 | if (DebugLevel >= 5) | ||
688 | LogIncomingInDetail(request); | ||
689 | } | ||
690 | |||
691 | private void LogIncomingToContentTypeHandler(OSHttpRequest request) | ||
692 | { | ||
693 | m_log.DebugFormat( | ||
694 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", | ||
695 | RequestNumber, | ||
696 | Port, | ||
697 | request.ContentType, | ||
698 | request.HttpMethod, | ||
699 | request.Url.PathAndQuery, | ||
700 | request.RemoteIPEndPoint); | ||
701 | |||
702 | if (DebugLevel >= 5) | ||
703 | LogIncomingInDetail(request); | ||
704 | } | ||
705 | |||
706 | private void LogIncomingToXmlRpcHandler(OSHttpRequest request) | ||
707 | { | ||
708 | m_log.DebugFormat( | ||
709 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}", | ||
710 | RequestNumber, | ||
711 | Port, | ||
712 | request.HttpMethod, | ||
713 | request.Url.PathAndQuery, | ||
714 | request.RemoteIPEndPoint); | ||
715 | |||
716 | if (DebugLevel >= 5) | ||
717 | LogIncomingInDetail(request); | ||
718 | } | ||
719 | |||
720 | private void LogIncomingInDetail(OSHttpRequest request) | ||
721 | { | ||
722 | using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8)) | ||
723 | { | ||
724 | string output; | ||
725 | |||
726 | if (DebugLevel == 5) | ||
727 | { | ||
728 | const int sampleLength = 80; | ||
729 | char[] sampleChars = new char[sampleLength]; | ||
730 | reader.Read(sampleChars, 0, sampleLength); | ||
731 | output = new string(sampleChars); | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | output = reader.ReadToEnd(); | ||
736 | } | ||
737 | |||
738 | m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); | ||
739 | } | ||
740 | } | ||
741 | |||
658 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) | 742 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) |
659 | { | 743 | { |
660 | string bestMatch = null; | 744 | string bestMatch = null; |
@@ -747,24 +831,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
747 | } | 831 | } |
748 | } | 832 | } |
749 | 833 | ||
750 | private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) | 834 | // private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) |
751 | { | 835 | // { |
752 | agentHandler = null; | 836 | // agentHandler = null; |
753 | 837 | // | |
754 | lock (m_agentHandlers) | 838 | // lock (m_agentHandlers) |
755 | { | 839 | // { |
756 | foreach (IHttpAgentHandler handler in m_agentHandlers.Values) | 840 | // foreach (IHttpAgentHandler handler in m_agentHandlers.Values) |
757 | { | 841 | // { |
758 | if (handler.Match(request, response)) | 842 | // if (handler.Match(request, response)) |
759 | { | 843 | // { |
760 | agentHandler = handler; | 844 | // agentHandler = handler; |
761 | return true; | 845 | // return true; |
762 | } | 846 | // } |
763 | } | 847 | // } |
764 | } | 848 | // } |
765 | 849 | // | |
766 | return false; | 850 | // return false; |
767 | } | 851 | // } |
768 | 852 | ||
769 | /// <summary> | 853 | /// <summary> |
770 | /// Try all the registered xmlrpc handlers when an xmlrpc request is received. | 854 | /// Try all the registered xmlrpc handlers when an xmlrpc request is received. |
@@ -1737,21 +1821,21 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1737 | m_pollHandlers.Remove(path); | 1821 | m_pollHandlers.Remove(path); |
1738 | } | 1822 | } |
1739 | 1823 | ||
1740 | public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) | 1824 | // public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) |
1741 | { | 1825 | // { |
1742 | lock (m_agentHandlers) | 1826 | // lock (m_agentHandlers) |
1743 | { | 1827 | // { |
1744 | IHttpAgentHandler foundHandler; | 1828 | // IHttpAgentHandler foundHandler; |
1745 | 1829 | // | |
1746 | if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) | 1830 | // if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) |
1747 | { | 1831 | // { |
1748 | m_agentHandlers.Remove(agent); | 1832 | // m_agentHandlers.Remove(agent); |
1749 | return true; | 1833 | // return true; |
1750 | } | 1834 | // } |
1751 | } | 1835 | // } |
1752 | 1836 | // | |
1753 | return false; | 1837 | // return false; |
1754 | } | 1838 | // } |
1755 | 1839 | ||
1756 | public void RemoveXmlRPCHandler(string method) | 1840 | public void RemoveXmlRPCHandler(string method) |
1757 | { | 1841 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index db58f6f..0bd3aae 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | |||
@@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
41 | uint Port { get; } | 41 | uint Port { get; } |
42 | bool UseSSL { get; } | 42 | bool UseSSL { get; } |
43 | 43 | ||
44 | // Note that the agent string is provided simply to differentiate | 44 | // // Note that the agent string is provided simply to differentiate |
45 | // the handlers - it is NOT required to be an actual agent header | 45 | // // the handlers - it is NOT required to be an actual agent header |
46 | // value. | 46 | // // value. |
47 | bool AddAgentHandler(string agent, IHttpAgentHandler handler); | 47 | // bool AddAgentHandler(string agent, IHttpAgentHandler handler); |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Add a handler for an HTTP request. | 50 | /// Add a handler for an HTTP request. |
@@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
106 | 106 | ||
107 | bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); | 107 | bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); |
108 | 108 | ||
109 | /// <summary> | 109 | // /// <summary> |
110 | /// Remove the agent if it is registered. | 110 | // /// Remove the agent if it is registered. |
111 | /// </summary> | 111 | // /// </summary> |
112 | /// <param name="agent"></param> | 112 | // /// <param name="agent"></param> |
113 | /// <param name="handler"></param> | 113 | // /// <param name="handler"></param> |
114 | /// <returns></returns> | 114 | // /// <returns></returns> |
115 | bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); | 115 | // bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); |
116 | 116 | ||
117 | /// <summary> | 117 | /// <summary> |
118 | /// Remove an HTTP handler | 118 | /// Remove an HTTP handler |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 8dc0e3a..ae7d515 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Text; | ||
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
@@ -47,9 +48,12 @@ namespace OpenSim.Framework.Servers | |||
47 | /// Control the printing of certain debug messages. | 48 | /// Control the printing of certain debug messages. |
48 | /// </summary> | 49 | /// </summary> |
49 | /// <remarks> | 50 | /// <remarks> |
50 | /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. | 51 | /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. |
51 | /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. | 52 | /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. |
52 | /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. | 53 | /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. |
54 | /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. | ||
55 | /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. | ||
56 | /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. | ||
53 | /// </remarks> | 57 | /// </remarks> |
54 | public static int DebugLevel | 58 | public static int DebugLevel |
55 | { | 59 | { |
@@ -101,17 +105,28 @@ namespace OpenSim.Framework.Servers | |||
101 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } | 105 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } |
102 | } | 106 | } |
103 | 107 | ||
104 | |||
105 | public static void RegisterHttpConsoleCommands(ICommandConsole console) | 108 | public static void RegisterHttpConsoleCommands(ICommandConsole console) |
106 | { | 109 | { |
107 | console.Commands.AddCommand( | 110 | console.Commands.AddCommand( |
108 | "Debug", false, "debug http", "debug http [<level>]", | 111 | "Comms", false, "show http-handlers", |
109 | "Turn on inbound non-poll http request debugging.", | 112 | "show http-handlers", |
110 | "If level <= 0, then no extra logging is done.\n" | 113 | "Show all registered http handlers", HandleShowHttpHandlersCommand); |
111 | + "If level >= 1, then short warnings are logged when receiving bad input data.\n" | 114 | |
112 | + "If level >= 2, then long warnings are logged when receiving bad input data.\n" | 115 | console.Commands.AddCommand( |
113 | + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" | 116 | "Debug", false, "debug http", "debug http <in|out|all> [<level>]", |
114 | + "If no level is specified then the current level is returned.", | 117 | "Turn on http request logging.", |
118 | "If in or all and\n" | ||
119 | + " level <= 0 then no extra logging is done.\n" | ||
120 | + " level >= 1 then short warnings are logged when receiving bad input data.\n" | ||
121 | + " level >= 2 then long warnings are logged when receiving bad input data.\n" | ||
122 | + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" | ||
123 | + " level >= 4 then the time taken to fulfill the request is logged.\n" | ||
124 | + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" | ||
125 | + " level >= 6 then the entire incoming data is logged.\n" | ||
126 | + " no level is specified then the current level is returned.\n\n" | ||
127 | + "If out or all and\n" | ||
128 | + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" | ||
129 | + " level >= 4 then the time taken to fulfill the request is logged.\n", | ||
115 | HandleDebugHttpCommand); | 130 | HandleDebugHttpCommand); |
116 | } | 131 | } |
117 | 132 | ||
@@ -119,25 +134,120 @@ namespace OpenSim.Framework.Servers | |||
119 | /// Turn on some debugging values for OpenSim. | 134 | /// Turn on some debugging values for OpenSim. |
120 | /// </summary> | 135 | /// </summary> |
121 | /// <param name="args"></param> | 136 | /// <param name="args"></param> |
122 | private static void HandleDebugHttpCommand(string module, string[] args) | 137 | private static void HandleDebugHttpCommand(string module, string[] cmdparams) |
123 | { | 138 | { |
124 | if (args.Length == 3) | 139 | if (cmdparams.Length < 3) |
140 | { | ||
141 | MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..6"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | bool inReqs = false; | ||
146 | bool outReqs = false; | ||
147 | bool allReqs = false; | ||
148 | |||
149 | string subCommand = cmdparams[2]; | ||
150 | |||
151 | if (subCommand.ToLower() == "in") | ||
152 | { | ||
153 | inReqs = true; | ||
154 | } | ||
155 | else if (subCommand.ToLower() == "out") | ||
156 | { | ||
157 | outReqs = true; | ||
158 | } | ||
159 | else if (subCommand.ToLower() == "all") | ||
160 | { | ||
161 | allReqs = true; | ||
162 | } | ||
163 | else | ||
125 | { | 164 | { |
165 | MainConsole.Instance.Output("You must specify in, out or all"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | if (cmdparams.Length >= 4) | ||
170 | { | ||
171 | string rawNewDebug = cmdparams[3]; | ||
126 | int newDebug; | 172 | int newDebug; |
127 | if (int.TryParse(args[2], out newDebug)) | 173 | |
174 | if (!int.TryParse(rawNewDebug, out newDebug)) | ||
175 | { | ||
176 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | if (newDebug < 0 || newDebug > 6) | ||
181 | { | ||
182 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | if (allReqs || inReqs) | ||
128 | { | 187 | { |
129 | MainServer.DebugLevel = newDebug; | 188 | MainServer.DebugLevel = newDebug; |
130 | MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); | 189 | MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); |
190 | } | ||
191 | |||
192 | if (allReqs || outReqs) | ||
193 | { | ||
194 | WebUtil.DebugLevel = newDebug; | ||
195 | MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); | ||
131 | } | 196 | } |
132 | } | 197 | } |
133 | else if (args.Length == 2) | 198 | else |
134 | { | 199 | { |
135 | MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); | 200 | if (allReqs || inReqs) |
201 | MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); | ||
202 | |||
203 | if (allReqs || outReqs) | ||
204 | MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); | ||
136 | } | 205 | } |
137 | else | 206 | } |
207 | |||
208 | private static void HandleShowHttpHandlersCommand(string module, string[] args) | ||
209 | { | ||
210 | if (args.Length != 2) | ||
211 | { | ||
212 | MainConsole.Instance.Output("Usage: show http-handlers"); | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | StringBuilder handlers = new StringBuilder(); | ||
217 | |||
218 | lock (m_Servers) | ||
138 | { | 219 | { |
139 | MainConsole.Instance.Output("Usage: debug http 0..3"); | 220 | foreach (BaseHttpServer httpServer in m_Servers.Values) |
221 | { | ||
222 | handlers.AppendFormat( | ||
223 | "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); | ||
224 | |||
225 | handlers.AppendFormat("* XMLRPC:\n"); | ||
226 | foreach (String s in httpServer.GetXmlRpcHandlerKeys()) | ||
227 | handlers.AppendFormat("\t{0}\n", s); | ||
228 | |||
229 | handlers.AppendFormat("* HTTP:\n"); | ||
230 | List<String> poll = httpServer.GetPollServiceHandlerKeys(); | ||
231 | foreach (String s in httpServer.GetHTTPHandlerKeys()) | ||
232 | handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); | ||
233 | |||
234 | // handlers.AppendFormat("* Agent:\n"); | ||
235 | // foreach (String s in httpServer.GetAgentHandlerKeys()) | ||
236 | // handlers.AppendFormat("\t{0}\n", s); | ||
237 | |||
238 | handlers.AppendFormat("* LLSD:\n"); | ||
239 | foreach (String s in httpServer.GetLLSDHandlerKeys()) | ||
240 | handlers.AppendFormat("\t{0}\n", s); | ||
241 | |||
242 | handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); | ||
243 | foreach (String s in httpServer.GetStreamHandlerKeys()) | ||
244 | handlers.AppendFormat("\t{0}\n", s); | ||
245 | |||
246 | handlers.Append("\n"); | ||
247 | } | ||
140 | } | 248 | } |
249 | |||
250 | MainConsole.Instance.Output(handlers.ToString()); | ||
141 | } | 251 | } |
142 | 252 | ||
143 | /// <summary> | 253 | /// <summary> |
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 016a174..bb094ed 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs | |||
@@ -29,7 +29,7 @@ namespace OpenSim | |||
29 | { | 29 | { |
30 | public class VersionInfo | 30 | public class VersionInfo |
31 | { | 31 | { |
32 | private const string VERSION_NUMBER = "0.7.4CM"; | 32 | private const string VERSION_NUMBER = "0.7.5CM"; |
33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; | 33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; |
34 | 34 | ||
35 | public enum Flavour | 35 | public enum Flavour |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 384f716..74551ea 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -546,6 +546,19 @@ namespace OpenSim.Framework | |||
546 | } | 546 | } |
547 | 547 | ||
548 | /// <summary> | 548 | /// <summary> |
549 | /// Determines whether a point is inside a bounding box. | ||
550 | /// </summary> | ||
551 | /// <param name='v'>/param> | ||
552 | /// <param name='min'></param> | ||
553 | /// <param name='max'></param> | ||
554 | /// <returns></returns> | ||
555 | public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) | ||
556 | { | ||
557 | return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z | ||
558 | && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; | ||
559 | } | ||
560 | |||
561 | /// <summary> | ||
549 | /// Are the co-ordinates of the new region visible from the old region? | 562 | /// Are the co-ordinates of the new region visible from the old region? |
550 | /// </summary> | 563 | /// </summary> |
551 | /// <param name="oldx">Old region x-coord</param> | 564 | /// <param name="oldx">Old region x-coord</param> |
@@ -862,6 +875,12 @@ namespace OpenSim.Framework | |||
862 | return Math.Min(Math.Max(x, min), max); | 875 | return Math.Min(Math.Max(x, min), max); |
863 | } | 876 | } |
864 | 877 | ||
878 | public static Vector3 Clip(Vector3 vec, float min, float max) | ||
879 | { | ||
880 | return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max), | ||
881 | Clip(vec.Z, min, max)); | ||
882 | } | ||
883 | |||
865 | /// <summary> | 884 | /// <summary> |
866 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. | 885 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. |
867 | /// </summary> | 886 | /// </summary> |
@@ -1013,6 +1032,38 @@ namespace OpenSim.Framework | |||
1013 | } | 1032 | } |
1014 | } | 1033 | } |
1015 | 1034 | ||
1035 | /// <summary> | ||
1036 | /// Copy data from one stream to another, leaving the read position of both streams at the beginning. | ||
1037 | /// </summary> | ||
1038 | /// <param name='inputStream'> | ||
1039 | /// Input stream. Must be seekable. | ||
1040 | /// </param> | ||
1041 | /// <exception cref='ArgumentException'> | ||
1042 | /// Thrown if the input stream is not seekable. | ||
1043 | /// </exception> | ||
1044 | public static Stream Copy(Stream inputStream) | ||
1045 | { | ||
1046 | if (!inputStream.CanSeek) | ||
1047 | throw new ArgumentException("Util.Copy(Stream inputStream) must receive an inputStream that can seek"); | ||
1048 | |||
1049 | const int readSize = 256; | ||
1050 | byte[] buffer = new byte[readSize]; | ||
1051 | MemoryStream ms = new MemoryStream(); | ||
1052 | |||
1053 | int count = inputStream.Read(buffer, 0, readSize); | ||
1054 | |||
1055 | while (count > 0) | ||
1056 | { | ||
1057 | ms.Write(buffer, 0, count); | ||
1058 | count = inputStream.Read(buffer, 0, readSize); | ||
1059 | } | ||
1060 | |||
1061 | ms.Position = 0; | ||
1062 | inputStream.Position = 0; | ||
1063 | |||
1064 | return ms; | ||
1065 | } | ||
1066 | |||
1016 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) | 1067 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) |
1017 | { | 1068 | { |
1018 | return SendXmlRpcCommand(url, methodName, args); | 1069 | return SendXmlRpcCommand(url, methodName, args); |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 8094b6d..a03d626 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -54,9 +54,17 @@ namespace OpenSim.Framework | |||
54 | MethodBase.GetCurrentMethod().DeclaringType); | 54 | MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
57 | /// Control the printing of certain debug messages. | ||
58 | /// </summary> | ||
59 | /// <remarks> | ||
60 | /// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged. | ||
61 | /// </remarks> | ||
62 | public static int DebugLevel { get; set; } | ||
63 | |||
64 | /// <summary> | ||
57 | /// Request number for diagnostic purposes. | 65 | /// Request number for diagnostic purposes. |
58 | /// </summary> | 66 | /// </summary> |
59 | public static int RequestNumber = 0; | 67 | public static int RequestNumber { get; internal set; } |
60 | 68 | ||
61 | /// <summary> | 69 | /// <summary> |
62 | /// this is the header field used to communicate the local request id | 70 | /// this is the header field used to communicate the local request id |
@@ -146,7 +154,11 @@ namespace OpenSim.Framework | |||
146 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | 154 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) |
147 | { | 155 | { |
148 | int reqnum = RequestNumber++; | 156 | int reqnum = RequestNumber++; |
149 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 157 | |
158 | if (DebugLevel >= 3) | ||
159 | m_log.DebugFormat( | ||
160 | "[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})", | ||
161 | reqnum, method, url, timeout, compressed); | ||
150 | 162 | ||
151 | string errorMessage = "unknown error"; | 163 | string errorMessage = "unknown error"; |
152 | int tickstart = Util.EnvironmentTickCount(); | 164 | int tickstart = Util.EnvironmentTickCount(); |
@@ -230,7 +242,7 @@ namespace OpenSim.Framework | |||
230 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 242 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
231 | if (tickdiff > LongCallTime) | 243 | if (tickdiff > LongCallTime) |
232 | m_log.InfoFormat( | 244 | m_log.InfoFormat( |
233 | "[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 245 | "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
234 | reqnum, | 246 | reqnum, |
235 | method, | 247 | method, |
236 | url, | 248 | url, |
@@ -239,10 +251,14 @@ namespace OpenSim.Framework | |||
239 | strBuffer != null | 251 | strBuffer != null |
240 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | 252 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) |
241 | : ""); | 253 | : ""); |
254 | else if (DebugLevel >= 4) | ||
255 | m_log.DebugFormat( | ||
256 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
257 | reqnum, tickdiff, tickdata); | ||
242 | } | 258 | } |
243 | 259 | ||
244 | m_log.DebugFormat( | 260 | m_log.DebugFormat( |
245 | "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | 261 | "[WEB UTIL]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage); |
246 | 262 | ||
247 | return ErrorResponseMap(errorMessage); | 263 | return ErrorResponseMap(errorMessage); |
248 | } | 264 | } |
@@ -318,7 +334,11 @@ namespace OpenSim.Framework | |||
318 | { | 334 | { |
319 | int reqnum = RequestNumber++; | 335 | int reqnum = RequestNumber++; |
320 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 336 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
321 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); | 337 | |
338 | if (DebugLevel >= 3) | ||
339 | m_log.DebugFormat( | ||
340 | "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", | ||
341 | reqnum, method, url, timeout); | ||
322 | 342 | ||
323 | string errorMessage = "unknown error"; | 343 | string errorMessage = "unknown error"; |
324 | int tickstart = Util.EnvironmentTickCount(); | 344 | int tickstart = Util.EnvironmentTickCount(); |
@@ -381,7 +401,7 @@ namespace OpenSim.Framework | |||
381 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 401 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
382 | if (tickdiff > LongCallTime) | 402 | if (tickdiff > LongCallTime) |
383 | m_log.InfoFormat( | 403 | m_log.InfoFormat( |
384 | "[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 404 | "[WEB UTIL]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
385 | reqnum, | 405 | reqnum, |
386 | method, | 406 | method, |
387 | url, | 407 | url, |
@@ -390,9 +410,13 @@ namespace OpenSim.Framework | |||
390 | queryString != null | 410 | queryString != null |
391 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString | 411 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString |
392 | : ""); | 412 | : ""); |
413 | else if (DebugLevel >= 4) | ||
414 | m_log.DebugFormat( | ||
415 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
416 | reqnum, tickdiff, tickdata); | ||
393 | } | 417 | } |
394 | 418 | ||
395 | m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); | 419 | m_log.WarnFormat("[WEB UTIL]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage); |
396 | 420 | ||
397 | return ErrorResponseMap(errorMessage); | 421 | return ErrorResponseMap(errorMessage); |
398 | } | 422 | } |
@@ -644,7 +668,6 @@ namespace OpenSim.Framework | |||
644 | /// <returns></returns> | 668 | /// <returns></returns> |
645 | public static string[] GetPreferredImageTypes(string accept) | 669 | public static string[] GetPreferredImageTypes(string accept) |
646 | { | 670 | { |
647 | |||
648 | if (accept == null || accept == string.Empty) | 671 | if (accept == null || accept == string.Empty) |
649 | return new string[0]; | 672 | return new string[0]; |
650 | 673 | ||
@@ -703,13 +726,15 @@ namespace OpenSim.Framework | |||
703 | int maxConnections) | 726 | int maxConnections) |
704 | { | 727 | { |
705 | int reqnum = WebUtil.RequestNumber++; | 728 | int reqnum = WebUtil.RequestNumber++; |
706 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 729 | |
730 | if (WebUtil.DebugLevel >= 3) | ||
731 | m_log.DebugFormat( | ||
732 | "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}", | ||
733 | reqnum, verb, requestUrl); | ||
707 | 734 | ||
708 | int tickstart = Util.EnvironmentTickCount(); | 735 | int tickstart = Util.EnvironmentTickCount(); |
709 | int tickdata = 0; | 736 | int tickdata = 0; |
710 | 737 | ||
711 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); | ||
712 | |||
713 | Type type = typeof(TRequest); | 738 | Type type = typeof(TRequest); |
714 | 739 | ||
715 | WebRequest request = WebRequest.Create(requestUrl); | 740 | WebRequest request = WebRequest.Create(requestUrl); |
@@ -866,7 +891,7 @@ namespace OpenSim.Framework | |||
866 | } | 891 | } |
867 | 892 | ||
868 | m_log.InfoFormat( | 893 | m_log.InfoFormat( |
869 | "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 894 | "[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
870 | reqnum, | 895 | reqnum, |
871 | verb, | 896 | verb, |
872 | requestUrl, | 897 | requestUrl, |
@@ -874,6 +899,12 @@ namespace OpenSim.Framework | |||
874 | tickdata, | 899 | tickdata, |
875 | originalRequest); | 900 | originalRequest); |
876 | } | 901 | } |
902 | else if (WebUtil.DebugLevel >= 4) | ||
903 | { | ||
904 | m_log.DebugFormat( | ||
905 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
906 | reqnum, tickdiff, tickdata); | ||
907 | } | ||
877 | } | 908 | } |
878 | } | 909 | } |
879 | 910 | ||
@@ -894,7 +925,11 @@ namespace OpenSim.Framework | |||
894 | public static string MakeRequest(string verb, string requestUrl, string obj) | 925 | public static string MakeRequest(string verb, string requestUrl, string obj) |
895 | { | 926 | { |
896 | int reqnum = WebUtil.RequestNumber++; | 927 | int reqnum = WebUtil.RequestNumber++; |
897 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 928 | |
929 | if (WebUtil.DebugLevel >= 3) | ||
930 | m_log.DebugFormat( | ||
931 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}", | ||
932 | reqnum, verb, requestUrl); | ||
898 | 933 | ||
899 | int tickstart = Util.EnvironmentTickCount(); | 934 | int tickstart = Util.EnvironmentTickCount(); |
900 | int tickdata = 0; | 935 | int tickdata = 0; |
@@ -979,13 +1014,17 @@ namespace OpenSim.Framework | |||
979 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 1014 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
980 | if (tickdiff > WebUtil.LongCallTime) | 1015 | if (tickdiff > WebUtil.LongCallTime) |
981 | m_log.InfoFormat( | 1016 | m_log.InfoFormat( |
982 | "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 1017 | "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
983 | reqnum, | 1018 | reqnum, |
984 | verb, | 1019 | verb, |
985 | requestUrl, | 1020 | requestUrl, |
986 | tickdiff, | 1021 | tickdiff, |
987 | tickdata, | 1022 | tickdata, |
988 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1023 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1024 | else if (WebUtil.DebugLevel >= 4) | ||
1025 | m_log.DebugFormat( | ||
1026 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1027 | reqnum, tickdiff, tickdata); | ||
989 | 1028 | ||
990 | return respstring; | 1029 | return respstring; |
991 | } | 1030 | } |
@@ -1020,7 +1059,11 @@ namespace OpenSim.Framework | |||
1020 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) | 1059 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) |
1021 | { | 1060 | { |
1022 | int reqnum = WebUtil.RequestNumber++; | 1061 | int reqnum = WebUtil.RequestNumber++; |
1023 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 1062 | |
1063 | if (WebUtil.DebugLevel >= 3) | ||
1064 | m_log.DebugFormat( | ||
1065 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}", | ||
1066 | reqnum, verb, requestUrl); | ||
1024 | 1067 | ||
1025 | int tickstart = Util.EnvironmentTickCount(); | 1068 | int tickstart = Util.EnvironmentTickCount(); |
1026 | int tickdata = 0; | 1069 | int tickdata = 0; |
@@ -1139,7 +1182,7 @@ namespace OpenSim.Framework | |||
1139 | } | 1182 | } |
1140 | 1183 | ||
1141 | m_log.InfoFormat( | 1184 | m_log.InfoFormat( |
1142 | "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 1185 | "[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
1143 | reqnum, | 1186 | reqnum, |
1144 | verb, | 1187 | verb, |
1145 | requestUrl, | 1188 | requestUrl, |
@@ -1147,6 +1190,12 @@ namespace OpenSim.Framework | |||
1147 | tickdata, | 1190 | tickdata, |
1148 | originalRequest); | 1191 | originalRequest); |
1149 | } | 1192 | } |
1193 | else if (WebUtil.DebugLevel >= 4) | ||
1194 | { | ||
1195 | m_log.DebugFormat( | ||
1196 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1197 | reqnum, tickdiff, tickdata); | ||
1198 | } | ||
1150 | 1199 | ||
1151 | return deserial; | 1200 | return deserial; |
1152 | } | 1201 | } |