diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Cache.cs | 83 | ||||
-rw-r--r-- | OpenSim/Framework/IClientAPI.cs | 15 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/Watchdog.cs | 15 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 42 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 6 |
5 files changed, 127 insertions, 34 deletions
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/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 6be2bd7..91f36a5 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/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/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 4bde7be..fcf1896 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -122,7 +122,9 @@ 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; |
@@ -287,11 +289,21 @@ namespace OpenSim.Framework | |||
287 | set { m_windlight = value; } | 289 | set { m_windlight = value; } |
288 | } | 290 | } |
289 | 291 | ||
292 | public float NonphysPrimMin | ||
293 | { | ||
294 | get { return m_nonphysPrimMin; } | ||
295 | } | ||
296 | |||
290 | public int NonphysPrimMax | 297 | public int NonphysPrimMax |
291 | { | 298 | { |
292 | get { return m_nonphysPrimMax; } | 299 | get { return m_nonphysPrimMax; } |
293 | } | 300 | } |
294 | 301 | ||
302 | public float PhysPrimMin | ||
303 | { | ||
304 | get { return m_physPrimMin; } | ||
305 | } | ||
306 | |||
295 | public int PhysPrimMax | 307 | public int PhysPrimMax |
296 | { | 308 | { |
297 | get { return m_physPrimMax; } | 309 | get { return m_physPrimMax; } |
@@ -625,16 +637,28 @@ namespace OpenSim.Framework | |||
625 | m_regionType = config.GetString("RegionType", String.Empty); | 637 | m_regionType = config.GetString("RegionType", String.Empty); |
626 | allKeys.Remove("RegionType"); | 638 | allKeys.Remove("RegionType"); |
627 | 639 | ||
628 | // Prim stuff | 640 | #region Prim stuff |
629 | // | 641 | |
642 | m_nonphysPrimMin = config.GetFloat("NonphysicalPrimMin", 0); | ||
643 | allKeys.Remove("NonphysicalPrimMin"); | ||
644 | |||
630 | m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); | 645 | m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); |
631 | allKeys.Remove("NonphysicalPrimMax"); | 646 | allKeys.Remove("NonphysicalPrimMax"); |
647 | |||
648 | m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); | ||
649 | allKeys.Remove("PhysicalPrimMin"); | ||
650 | |||
632 | m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); | 651 | m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); |
633 | allKeys.Remove("PhysicalPrimMax"); | 652 | allKeys.Remove("PhysicalPrimMax"); |
653 | |||
634 | m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); | 654 | m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); |
635 | allKeys.Remove("ClampPrimSize"); | 655 | allKeys.Remove("ClampPrimSize"); |
656 | |||
636 | m_objectCapacity = config.GetInt("MaxPrims", 15000); | 657 | m_objectCapacity = config.GetInt("MaxPrims", 15000); |
637 | allKeys.Remove("MaxPrims"); | 658 | allKeys.Remove("MaxPrims"); |
659 | |||
660 | #endregion | ||
661 | |||
638 | m_agentCapacity = config.GetInt("MaxAgents", 100); | 662 | m_agentCapacity = config.GetInt("MaxAgents", 100); |
639 | allKeys.Remove("MaxAgents"); | 663 | allKeys.Remove("MaxAgents"); |
640 | 664 | ||
@@ -673,10 +697,18 @@ namespace OpenSim.Framework | |||
673 | 697 | ||
674 | config.Set("ExternalHostName", m_externalHostName); | 698 | config.Set("ExternalHostName", m_externalHostName); |
675 | 699 | ||
700 | if (m_nonphysPrimMin != 0) | ||
701 | config.Set("NonphysicalPrimMax", m_nonphysPrimMin); | ||
702 | |||
676 | if (m_nonphysPrimMax != 0) | 703 | if (m_nonphysPrimMax != 0) |
677 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); | 704 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); |
705 | |||
706 | if (m_physPrimMin != 0) | ||
707 | config.Set("PhysicalPrimMax", m_physPrimMin); | ||
708 | |||
678 | if (m_physPrimMax != 0) | 709 | if (m_physPrimMax != 0) |
679 | config.Set("PhysicalPrimMax", m_physPrimMax); | 710 | config.Set("PhysicalPrimMax", m_physPrimMax); |
711 | |||
680 | config.Set("ClampPrimSize", m_clampPrimSize.ToString()); | 712 | config.Set("ClampPrimSize", m_clampPrimSize.ToString()); |
681 | 713 | ||
682 | if (m_objectCapacity != 0) | 714 | if (m_objectCapacity != 0) |
@@ -759,9 +791,15 @@ namespace OpenSim.Framework | |||
759 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 791 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
760 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); | 792 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); |
761 | 793 | ||
794 | configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
795 | "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); | ||
796 | |||
762 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 797 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
763 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); | 798 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); |
764 | 799 | ||
800 | configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, | ||
801 | "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); | ||
802 | |||
765 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 803 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
766 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); | 804 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); |
767 | 805 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 384f716..1a383ae 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -862,6 +862,12 @@ namespace OpenSim.Framework | |||
862 | return Math.Min(Math.Max(x, min), max); | 862 | return Math.Min(Math.Max(x, min), max); |
863 | } | 863 | } |
864 | 864 | ||
865 | public static Vector3 Clip(Vector3 vec, float min, float max) | ||
866 | { | ||
867 | return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max), | ||
868 | Clip(vec.Z, min, max)); | ||
869 | } | ||
870 | |||
865 | /// <summary> | 871 | /// <summary> |
866 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. | 872 | /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. |
867 | /// </summary> | 873 | /// </summary> |