diff options
author | Sean McNamara | 2011-05-02 02:23:18 -0400 |
---|---|---|
committer | Sean McNamara | 2011-05-02 02:23:18 -0400 |
commit | fffd42f5cbbb9e59b6fde3247aeb0d80d990319f (patch) | |
tree | 034b3e8da351954bc1124d91ec1f28e29e6a68c6 /OpenSim/Framework | |
parent | First pass at fixing justincc's feedback v2 ( http://opensimulator.org/mantis... (diff) | |
parent | Fixed confusing OSDMap that comes as the response of QueryAccess in the case ... (diff) | |
download | opensim-SC_OLD-fffd42f5cbbb9e59b6fde3247aeb0d80d990319f.zip opensim-SC_OLD-fffd42f5cbbb9e59b6fde3247aeb0d80d990319f.tar.gz opensim-SC_OLD-fffd42f5cbbb9e59b6fde3247aeb0d80d990319f.tar.bz2 opensim-SC_OLD-fffd42f5cbbb9e59b6fde3247aeb0d80d990319f.tar.xz |
Merge git://opensimulator.org/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AgentCircuitData.cs | 69 | ||||
-rw-r--r-- | OpenSim/Framework/ChildAgentDataUpdate.cs | 57 | ||||
-rw-r--r-- | OpenSim/Framework/ClientInfo.cs | 3 | ||||
-rw-r--r-- | OpenSim/Framework/IClientAPI.cs | 59 | ||||
-rw-r--r-- | OpenSim/Framework/PriorityQueue.cs (renamed from OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs) | 132 | ||||
-rw-r--r-- | OpenSim/Framework/Tests/MundaneFrameworkTests.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 17 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 12 |
8 files changed, 229 insertions, 122 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 3dbc215..dbd47d3 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs | |||
@@ -152,27 +152,6 @@ namespace OpenSim.Framework | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /// <summary> | 154 | /// <summary> |
155 | /// Create AgentCircuitData from a Serializable AgentCircuitData | ||
156 | /// </summary> | ||
157 | /// <param name="cAgent"></param> | ||
158 | public AgentCircuitData(sAgentCircuitData cAgent) | ||
159 | { | ||
160 | AgentID = new UUID(cAgent.AgentID); | ||
161 | SessionID = new UUID(cAgent.SessionID); | ||
162 | SecureSessionID = new UUID(cAgent.SecureSessionID); | ||
163 | startpos = new Vector3(cAgent.startposx, cAgent.startposy, cAgent.startposz); | ||
164 | firstname = cAgent.firstname; | ||
165 | lastname = cAgent.lastname; | ||
166 | circuitcode = cAgent.circuitcode; | ||
167 | child = cAgent.child; | ||
168 | InventoryFolder = new UUID(cAgent.InventoryFolder); | ||
169 | BaseFolder = new UUID(cAgent.BaseFolder); | ||
170 | CapsPath = cAgent.CapsPath; | ||
171 | ChildrenCapSeeds = cAgent.ChildrenCapSeeds; | ||
172 | Viewer = cAgent.Viewer; | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json | 155 | /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json |
177 | /// </summary> | 156 | /// </summary> |
178 | /// <returns>map of the agent circuit data</returns> | 157 | /// <returns>map of the agent circuit data</returns> |
@@ -369,52 +348,4 @@ namespace OpenSim.Framework | |||
369 | } | 348 | } |
370 | 349 | ||
371 | 350 | ||
372 | /// <summary> | ||
373 | /// Serializable Agent Circuit Data | ||
374 | /// </summary> | ||
375 | [Serializable] | ||
376 | public class sAgentCircuitData | ||
377 | { | ||
378 | public Guid AgentID; | ||
379 | public Guid BaseFolder; | ||
380 | public string CapsPath = String.Empty; | ||
381 | public Dictionary<ulong, string> ChildrenCapSeeds; | ||
382 | public bool child; | ||
383 | public uint circuitcode; | ||
384 | public string firstname; | ||
385 | public Guid InventoryFolder; | ||
386 | public string lastname; | ||
387 | public Guid SecureSessionID; | ||
388 | public Guid SessionID; | ||
389 | public float startposx; | ||
390 | public float startposy; | ||
391 | public float startposz; | ||
392 | public string Viewer; | ||
393 | public string Channel; | ||
394 | public string Mac; | ||
395 | public string Id0; | ||
396 | |||
397 | public sAgentCircuitData() | ||
398 | { | ||
399 | } | ||
400 | |||
401 | public sAgentCircuitData(AgentCircuitData cAgent) | ||
402 | { | ||
403 | AgentID = cAgent.AgentID.Guid; | ||
404 | SessionID = cAgent.SessionID.Guid; | ||
405 | SecureSessionID = cAgent.SecureSessionID.Guid; | ||
406 | startposx = cAgent.startpos.X; | ||
407 | startposy = cAgent.startpos.Y; | ||
408 | startposz = cAgent.startpos.Z; | ||
409 | firstname = cAgent.firstname; | ||
410 | lastname = cAgent.lastname; | ||
411 | circuitcode = cAgent.circuitcode; | ||
412 | child = cAgent.child; | ||
413 | InventoryFolder = cAgent.InventoryFolder.Guid; | ||
414 | BaseFolder = cAgent.BaseFolder.Guid; | ||
415 | CapsPath = cAgent.CapsPath; | ||
416 | ChildrenCapSeeds = cAgent.ChildrenCapSeeds; | ||
417 | Viewer = cAgent.Viewer; | ||
418 | } | ||
419 | } | ||
420 | } | 351 | } |
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index ce0b2fb..28fe3ba 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Framework | |||
62 | UUID AgentID { get; set; } | 62 | UUID AgentID { get; set; } |
63 | 63 | ||
64 | OSDMap Pack(); | 64 | OSDMap Pack(); |
65 | void Unpack(OSDMap map); | 65 | void Unpack(OSDMap map, IScene scene); |
66 | } | 66 | } |
67 | 67 | ||
68 | /// <summary> | 68 | /// <summary> |
@@ -122,7 +122,7 @@ namespace OpenSim.Framework | |||
122 | return args; | 122 | return args; |
123 | } | 123 | } |
124 | 124 | ||
125 | public void Unpack(OSDMap args) | 125 | public void Unpack(OSDMap args, IScene scene) |
126 | { | 126 | { |
127 | if (args.ContainsKey("region_handle")) | 127 | if (args.ContainsKey("region_handle")) |
128 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); | 128 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); |
@@ -329,6 +329,10 @@ namespace OpenSim.Framework | |||
329 | 329 | ||
330 | public string CallbackURI; | 330 | public string CallbackURI; |
331 | 331 | ||
332 | // These two must have the same Count | ||
333 | public List<ISceneObject> AttachmentObjects; | ||
334 | public List<string> AttachmentObjectStates; | ||
335 | |||
332 | public virtual OSDMap Pack() | 336 | public virtual OSDMap Pack() |
333 | { | 337 | { |
334 | m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); | 338 | m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); |
@@ -441,7 +445,30 @@ namespace OpenSim.Framework | |||
441 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) | 445 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) |
442 | args["callback_uri"] = OSD.FromString(CallbackURI); | 446 | args["callback_uri"] = OSD.FromString(CallbackURI); |
443 | 447 | ||
448 | // Attachment objects for fatpack messages | ||
449 | if (AttachmentObjects != null) | ||
450 | { | ||
451 | int i = 0; | ||
452 | OSDArray attObjs = new OSDArray(AttachmentObjects.Count); | ||
453 | foreach (ISceneObject so in AttachmentObjects) | ||
454 | { | ||
455 | OSDMap info = new OSDMap(4); | ||
456 | info["sog"] = OSD.FromString(so.ToXml2()); | ||
457 | info["extra"] = OSD.FromString(so.ExtraToXmlString()); | ||
458 | info["modified"] = OSD.FromBoolean(so.HasGroupChanged); | ||
459 | try | ||
460 | { | ||
461 | info["state"] = OSD.FromString(AttachmentObjectStates[i++]); | ||
462 | } | ||
463 | catch (IndexOutOfRangeException e) | ||
464 | { | ||
465 | m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list."); | ||
466 | } | ||
444 | 467 | ||
468 | attObjs.Add(info); | ||
469 | } | ||
470 | args["attach_objects"] = attObjs; | ||
471 | } | ||
445 | return args; | 472 | return args; |
446 | } | 473 | } |
447 | 474 | ||
@@ -450,7 +477,7 @@ namespace OpenSim.Framework | |||
450 | /// Avoiding reflection makes it painful to write, but that's the price! | 477 | /// Avoiding reflection makes it painful to write, but that's the price! |
451 | /// </summary> | 478 | /// </summary> |
452 | /// <param name="hash"></param> | 479 | /// <param name="hash"></param> |
453 | public virtual void Unpack(OSDMap args) | 480 | public virtual void Unpack(OSDMap args, IScene scene) |
454 | { | 481 | { |
455 | m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); | 482 | m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); |
456 | 483 | ||
@@ -628,6 +655,26 @@ namespace OpenSim.Framework | |||
628 | 655 | ||
629 | if (args["callback_uri"] != null) | 656 | if (args["callback_uri"] != null) |
630 | CallbackURI = args["callback_uri"].AsString(); | 657 | CallbackURI = args["callback_uri"].AsString(); |
658 | |||
659 | // Attachment objects | ||
660 | if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array) | ||
661 | { | ||
662 | OSDArray attObjs = (OSDArray)(args["attach_objects"]); | ||
663 | AttachmentObjects = new List<ISceneObject>(); | ||
664 | AttachmentObjectStates = new List<string>(); | ||
665 | foreach (OSD o in attObjs) | ||
666 | { | ||
667 | if (o.Type == OSDType.Map) | ||
668 | { | ||
669 | OSDMap info = (OSDMap)o; | ||
670 | ISceneObject so = scene.DeserializeObject(info["sog"].AsString()); | ||
671 | so.ExtraFromXmlString(info["extra"].AsString()); | ||
672 | so.HasGroupChanged = info["modified"].AsBoolean(); | ||
673 | AttachmentObjects.Add(so); | ||
674 | AttachmentObjectStates.Add(info["state"].AsString()); | ||
675 | } | ||
676 | } | ||
677 | } | ||
631 | } | 678 | } |
632 | 679 | ||
633 | public AgentData() | 680 | public AgentData() |
@@ -655,9 +702,9 @@ namespace OpenSim.Framework | |||
655 | return base.Pack(); | 702 | return base.Pack(); |
656 | } | 703 | } |
657 | 704 | ||
658 | public override void Unpack(OSDMap map) | 705 | public override void Unpack(OSDMap map, IScene scene) |
659 | { | 706 | { |
660 | base.Unpack(map); | 707 | base.Unpack(map, scene); |
661 | } | 708 | } |
662 | } | 709 | } |
663 | } | 710 | } |
diff --git a/OpenSim/Framework/ClientInfo.cs b/OpenSim/Framework/ClientInfo.cs index fbd18b5..62acb70 100644 --- a/OpenSim/Framework/ClientInfo.cs +++ b/OpenSim/Framework/ClientInfo.cs | |||
@@ -31,10 +31,9 @@ using System.Net; | |||
31 | 31 | ||
32 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
33 | { | 33 | { |
34 | [Serializable] | ||
35 | public class ClientInfo | 34 | public class ClientInfo |
36 | { | 35 | { |
37 | public sAgentCircuitData agentcircuit; | 36 | public AgentCircuitData agentcircuit; |
38 | 37 | ||
39 | public Dictionary<uint, byte[]> needAck; | 38 | public Dictionary<uint, byte[]> needAck; |
40 | 39 | ||
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f573c32..069987b 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -572,34 +572,69 @@ namespace OpenSim.Framework | |||
572 | 572 | ||
573 | public class IEntityUpdate | 573 | public class IEntityUpdate |
574 | { | 574 | { |
575 | public ISceneEntity Entity; | 575 | private ISceneEntity m_entity; |
576 | public uint Flags; | 576 | private uint m_flags; |
577 | private int m_updateTime; | ||
578 | |||
579 | public ISceneEntity Entity | ||
580 | { | ||
581 | get { return m_entity; } | ||
582 | } | ||
583 | |||
584 | public uint Flags | ||
585 | { | ||
586 | get { return m_flags; } | ||
587 | } | ||
588 | |||
589 | public int UpdateTime | ||
590 | { | ||
591 | get { return m_updateTime; } | ||
592 | } | ||
577 | 593 | ||
578 | public virtual void Update(IEntityUpdate update) | 594 | public virtual void Update(IEntityUpdate update) |
579 | { | 595 | { |
580 | this.Flags |= update.Flags; | 596 | m_flags |= update.Flags; |
597 | |||
598 | // Use the older of the updates as the updateTime | ||
599 | if (Util.EnvironmentTickCountCompare(UpdateTime, update.UpdateTime) > 0) | ||
600 | m_updateTime = update.UpdateTime; | ||
581 | } | 601 | } |
582 | 602 | ||
583 | public IEntityUpdate(ISceneEntity entity, uint flags) | 603 | public IEntityUpdate(ISceneEntity entity, uint flags) |
584 | { | 604 | { |
585 | Entity = entity; | 605 | m_entity = entity; |
586 | Flags = flags; | 606 | m_flags = flags; |
607 | m_updateTime = Util.EnvironmentTickCount(); | ||
608 | } | ||
609 | |||
610 | public IEntityUpdate(ISceneEntity entity, uint flags, Int32 updateTime) | ||
611 | { | ||
612 | m_entity = entity; | ||
613 | m_flags = flags; | ||
614 | m_updateTime = updateTime; | ||
587 | } | 615 | } |
588 | } | 616 | } |
589 | |||
590 | 617 | ||
591 | public class EntityUpdate : IEntityUpdate | 618 | public class EntityUpdate : IEntityUpdate |
592 | { | 619 | { |
593 | // public ISceneEntity Entity; | 620 | private float m_timeDilation; |
594 | // public PrimUpdateFlags Flags; | 621 | |
595 | public float TimeDilation; | 622 | public float TimeDilation |
623 | { | ||
624 | get { return m_timeDilation; } | ||
625 | } | ||
596 | 626 | ||
597 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, float timedilation) | 627 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, float timedilation) |
598 | : base(entity,(uint)flags) | 628 | : base(entity, (uint)flags) |
599 | { | 629 | { |
600 | //Entity = entity; | ||
601 | // Flags = flags; | 630 | // Flags = flags; |
602 | TimeDilation = timedilation; | 631 | m_timeDilation = timedilation; |
632 | } | ||
633 | |||
634 | public EntityUpdate(ISceneEntity entity, PrimUpdateFlags flags, float timedilation, Int32 updateTime) | ||
635 | : base(entity,(uint)flags,updateTime) | ||
636 | { | ||
637 | m_timeDilation = timedilation; | ||
603 | } | 638 | } |
604 | } | 639 | } |
605 | 640 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs index b62ec07..3e6fdaa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs +++ b/OpenSim/Framework/PriorityQueue.cs | |||
@@ -34,50 +34,81 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Client; | 34 | using OpenSim.Framework.Client; |
35 | using log4net; | 35 | using log4net; |
36 | 36 | ||
37 | namespace OpenSim.Region.ClientStack.LindenUDP | 37 | namespace OpenSim.Framework |
38 | { | 38 | { |
39 | public class PriorityQueue | 39 | public class PriorityQueue |
40 | { | 40 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); | 43 | public delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); |
44 | 44 | ||
45 | // Heap[0] for self updates | 45 | /// <summary> |
46 | // Heap[1..12] for entity updates | 46 | /// Total number of queues (priorities) available |
47 | /// </summary> | ||
48 | public const uint NumberOfQueues = 12; | ||
47 | 49 | ||
48 | internal const uint m_numberOfQueues = 12; | 50 | /// <summary> |
51 | /// Number of queuest (priorities) that are processed immediately | ||
52 | /// </summary. | ||
53 | public const uint NumberOfImmediateQueues = 2; | ||
49 | 54 | ||
50 | private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[m_numberOfQueues]; | 55 | private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[NumberOfQueues]; |
51 | private Dictionary<uint, LookupItem> m_lookupTable; | 56 | private Dictionary<uint, LookupItem> m_lookupTable; |
57 | |||
58 | // internal state used to ensure the deqeues are spread across the priority | ||
59 | // queues "fairly". queuecounts is the amount to pull from each queue in | ||
60 | // each pass. weighted towards the higher priority queues | ||
52 | private uint m_nextQueue = 0; | 61 | private uint m_nextQueue = 0; |
62 | private uint m_countFromQueue = 0; | ||
63 | private uint[] m_queueCounts = { 8, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; | ||
64 | |||
65 | // next request is a counter of the number of updates queued, it provides | ||
66 | // a total ordering on the updates coming through the queue and is more | ||
67 | // lightweight (and more discriminating) than tick count | ||
53 | private UInt64 m_nextRequest = 0; | 68 | private UInt64 m_nextRequest = 0; |
54 | 69 | ||
70 | /// <summary> | ||
71 | /// Lock for enqueue and dequeue operations on the priority queue | ||
72 | /// </summary> | ||
55 | private object m_syncRoot = new object(); | 73 | private object m_syncRoot = new object(); |
56 | public object SyncRoot { | 74 | public object SyncRoot { |
57 | get { return this.m_syncRoot; } | 75 | get { return this.m_syncRoot; } |
58 | } | 76 | } |
59 | 77 | ||
60 | internal PriorityQueue() : this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY) { } | 78 | #region constructor |
79 | public PriorityQueue() : this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY) { } | ||
61 | 80 | ||
62 | internal PriorityQueue(int capacity) | 81 | public PriorityQueue(int capacity) |
63 | { | 82 | { |
64 | m_lookupTable = new Dictionary<uint, LookupItem>(capacity); | 83 | m_lookupTable = new Dictionary<uint, LookupItem>(capacity); |
65 | 84 | ||
66 | for (int i = 0; i < m_heaps.Length; ++i) | 85 | for (int i = 0; i < m_heaps.Length; ++i) |
67 | m_heaps[i] = new MinHeap<MinHeapItem>(capacity); | 86 | m_heaps[i] = new MinHeap<MinHeapItem>(capacity); |
87 | |||
88 | m_nextQueue = NumberOfImmediateQueues; | ||
89 | m_countFromQueue = m_queueCounts[m_nextQueue]; | ||
68 | } | 90 | } |
91 | #endregion Constructor | ||
69 | 92 | ||
70 | internal int Count | 93 | #region PublicMethods |
94 | /// <summary> | ||
95 | /// Return the number of items in the queues | ||
96 | /// </summary> | ||
97 | public int Count | ||
71 | { | 98 | { |
72 | get | 99 | get |
73 | { | 100 | { |
74 | int count = 0; | 101 | int count = 0; |
75 | for (int i = 0; i < m_heaps.Length; ++i) | 102 | for (int i = 0; i < m_heaps.Length; ++i) |
76 | count += m_heaps[i].Count; | 103 | count += m_heaps[i].Count; |
104 | |||
77 | return count; | 105 | return count; |
78 | } | 106 | } |
79 | } | 107 | } |
80 | 108 | ||
109 | /// <summary> | ||
110 | /// Enqueue an item into the specified priority queue | ||
111 | /// </summary> | ||
81 | public bool Enqueue(uint pqueue, IEntityUpdate value) | 112 | public bool Enqueue(uint pqueue, IEntityUpdate value) |
82 | { | 113 | { |
83 | LookupItem lookup; | 114 | LookupItem lookup; |
@@ -91,7 +122,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
91 | lookup.Heap.Remove(lookup.Handle); | 122 | lookup.Heap.Remove(lookup.Handle); |
92 | } | 123 | } |
93 | 124 | ||
94 | pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1); | 125 | pqueue = Util.Clamp<uint>(pqueue, 0, NumberOfQueues - 1); |
95 | lookup.Heap = m_heaps[pqueue]; | 126 | lookup.Heap = m_heaps[pqueue]; |
96 | lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); | 127 | lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); |
97 | m_lookupTable[localid] = lookup; | 128 | m_lookupTable[localid] = lookup; |
@@ -99,20 +130,62 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
99 | return true; | 130 | return true; |
100 | } | 131 | } |
101 | 132 | ||
102 | internal bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) | 133 | /// <summary> |
134 | /// Remove an item from one of the queues. Specifically, it removes the | ||
135 | /// oldest item from the next queue in order to provide fair access to | ||
136 | /// all of the queues | ||
137 | /// </summary> | ||
138 | public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) | ||
103 | { | 139 | { |
104 | for (int i = 0; i < m_numberOfQueues; ++i) | 140 | // If there is anything in priority queue 0, return it first no |
141 | // matter what else. Breaks fairness. But very useful. | ||
142 | for (int iq = 0; iq < NumberOfImmediateQueues; iq++) | ||
105 | { | 143 | { |
106 | // To get the fair queing, we cycle through each of the | 144 | if (m_heaps[iq].Count > 0) |
107 | // queues when finding an element to dequeue, this code | ||
108 | // assumes that the distribution of updates in the queues | ||
109 | // is polynomial, probably quadractic (eg distance of PI * R^2) | ||
110 | uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); | ||
111 | if (m_heaps[h].Count > 0) | ||
112 | { | 145 | { |
113 | m_nextQueue = (uint)((h + 1) % m_numberOfQueues); | 146 | MinHeapItem item = m_heaps[iq].RemoveMin(); |
147 | m_lookupTable.Remove(item.Value.Entity.LocalId); | ||
148 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
149 | value = item.Value; | ||
114 | 150 | ||
115 | MinHeapItem item = m_heaps[h].RemoveMin(); | 151 | return true; |
152 | } | ||
153 | } | ||
154 | |||
155 | // To get the fair queing, we cycle through each of the | ||
156 | // queues when finding an element to dequeue. | ||
157 | // We pull (NumberOfQueues - QueueIndex) items from each queue in order | ||
158 | // to give lower numbered queues a higher priority and higher percentage | ||
159 | // of the bandwidth. | ||
160 | |||
161 | // Check for more items to be pulled from the current queue | ||
162 | if (m_heaps[m_nextQueue].Count > 0 && m_countFromQueue > 0) | ||
163 | { | ||
164 | m_countFromQueue--; | ||
165 | |||
166 | MinHeapItem item = m_heaps[m_nextQueue].RemoveMin(); | ||
167 | m_lookupTable.Remove(item.Value.Entity.LocalId); | ||
168 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | ||
169 | value = item.Value; | ||
170 | |||
171 | return true; | ||
172 | } | ||
173 | |||
174 | // Find the next non-immediate queue with updates in it | ||
175 | for (int i = 0; i < NumberOfQueues; ++i) | ||
176 | { | ||
177 | m_nextQueue = (uint)((m_nextQueue + 1) % NumberOfQueues); | ||
178 | m_countFromQueue = m_queueCounts[m_nextQueue]; | ||
179 | |||
180 | // if this is one of the immediate queues, just skip it | ||
181 | if (m_nextQueue < NumberOfImmediateQueues) | ||
182 | continue; | ||
183 | |||
184 | if (m_heaps[m_nextQueue].Count > 0) | ||
185 | { | ||
186 | m_countFromQueue--; | ||
187 | |||
188 | MinHeapItem item = m_heaps[m_nextQueue].RemoveMin(); | ||
116 | m_lookupTable.Remove(item.Value.Entity.LocalId); | 189 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
117 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | 190 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); |
118 | value = item.Value; | 191 | value = item.Value; |
@@ -126,7 +199,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
126 | return false; | 199 | return false; |
127 | } | 200 | } |
128 | 201 | ||
129 | internal void Reprioritize(UpdatePriorityHandler handler) | 202 | /// <summary> |
203 | /// Reapply the prioritization function to each of the updates currently | ||
204 | /// stored in the priority queues. | ||
205 | /// </summary | ||
206 | public void Reprioritize(UpdatePriorityHandler handler) | ||
130 | { | 207 | { |
131 | MinHeapItem item; | 208 | MinHeapItem item; |
132 | foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values)) | 209 | foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values)) |
@@ -140,7 +217,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
140 | { | 217 | { |
141 | // unless the priority queue has changed, there is no need to modify | 218 | // unless the priority queue has changed, there is no need to modify |
142 | // the entry | 219 | // the entry |
143 | pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1); | 220 | pqueue = Util.Clamp<uint>(pqueue, 0, NumberOfQueues - 1); |
144 | if (pqueue != item.PriorityQueue) | 221 | if (pqueue != item.PriorityQueue) |
145 | { | 222 | { |
146 | lookup.Heap.Remove(lookup.Handle); | 223 | lookup.Heap.Remove(lookup.Handle); |
@@ -161,17 +238,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
161 | } | 238 | } |
162 | } | 239 | } |
163 | 240 | ||
241 | /// <summary> | ||
242 | /// </summary> | ||
164 | public override string ToString() | 243 | public override string ToString() |
165 | { | 244 | { |
166 | string s = ""; | 245 | string s = ""; |
167 | for (int i = 0; i < m_numberOfQueues; i++) | 246 | for (int i = 0; i < NumberOfQueues; i++) |
168 | { | 247 | s += String.Format("{0,7} ",m_heaps[i].Count); |
169 | if (s != "") s += ","; | ||
170 | s += m_heaps[i].Count.ToString(); | ||
171 | } | ||
172 | return s; | 248 | return s; |
173 | } | 249 | } |
174 | 250 | ||
251 | #endregion PublicMethods | ||
252 | |||
175 | #region MinHeapItem | 253 | #region MinHeapItem |
176 | private struct MinHeapItem : IComparable<MinHeapItem> | 254 | private struct MinHeapItem : IComparable<MinHeapItem> |
177 | { | 255 | { |
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index e7f8bfc..76de6be 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -115,7 +115,7 @@ namespace OpenSim.Framework.Tests | |||
115 | position2 = new AgentPosition(); | 115 | position2 = new AgentPosition(); |
116 | 116 | ||
117 | Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); | 117 | Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); |
118 | position2.Unpack(position1.Pack()); | 118 | position2.Unpack(position1.Pack(), null); |
119 | 119 | ||
120 | Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); | 120 | Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); |
121 | Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); | 121 | Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5a5046e..aaa2724 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1537,6 +1537,23 @@ namespace OpenSim.Framework | |||
1537 | return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); | 1537 | return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount | ||
1541 | // Assumes both tcA and tcB came from previous calls to Util.EnvironmentTickCount(). | ||
1542 | // A positive return value indicates A occured later than B | ||
1543 | public static Int32 EnvironmentTickCountCompare(Int32 tcA, Int32 tcB) | ||
1544 | { | ||
1545 | // A, B and TC are all between 0 and 0x3fffffff | ||
1546 | int tc = EnvironmentTickCount(); | ||
1547 | |||
1548 | if (tc - tcA >= 0) | ||
1549 | tcA += EnvironmentTickCountMask + 1; | ||
1550 | |||
1551 | if (tc - tcB >= 0) | ||
1552 | tcB += EnvironmentTickCountMask + 1; | ||
1553 | |||
1554 | return tcA - tcB; | ||
1555 | } | ||
1556 | |||
1540 | /// <summary> | 1557 | /// <summary> |
1541 | /// Prints the call stack at any given point. Useful for debugging. | 1558 | /// Prints the call stack at any given point. Useful for debugging. |
1542 | /// </summary> | 1559 | /// </summary> |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 9d70f63..ac0828b 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -142,17 +142,17 @@ namespace OpenSim.Framework | |||
142 | /// </summary> | 142 | /// </summary> |
143 | public static OSDMap PutToService(string url, OSDMap data) | 143 | public static OSDMap PutToService(string url, OSDMap data) |
144 | { | 144 | { |
145 | return ServiceOSDRequest(url,data,"PUT",10000); | 145 | return ServiceOSDRequest(url,data,"PUT",30000); |
146 | } | 146 | } |
147 | 147 | ||
148 | public static OSDMap PostToService(string url, OSDMap data) | 148 | public static OSDMap PostToService(string url, OSDMap data) |
149 | { | 149 | { |
150 | return ServiceOSDRequest(url,data,"POST",10000); | 150 | return ServiceOSDRequest(url,data,"POST",30000); |
151 | } | 151 | } |
152 | 152 | ||
153 | public static OSDMap GetFromService(string url) | 153 | public static OSDMap GetFromService(string url) |
154 | { | 154 | { |
155 | return ServiceOSDRequest(url,null,"GET",10000); | 155 | return ServiceOSDRequest(url,null,"GET",30000); |
156 | } | 156 | } |
157 | 157 | ||
158 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout) | 158 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout) |
@@ -171,15 +171,15 @@ namespace OpenSim.Framework | |||
171 | request.Timeout = timeout; | 171 | request.Timeout = timeout; |
172 | request.KeepAlive = false; | 172 | request.KeepAlive = false; |
173 | request.MaximumAutomaticRedirections = 10; | 173 | request.MaximumAutomaticRedirections = 10; |
174 | request.ReadWriteTimeout = timeout / 4; | 174 | request.ReadWriteTimeout = timeout * 8; |
175 | request.Headers[OSHeaderRequestID] = reqnum.ToString(); | 175 | request.Headers[OSHeaderRequestID] = reqnum.ToString(); |
176 | 176 | ||
177 | // If there is some input, write it into the request | 177 | // If there is some input, write it into the request |
178 | if (data != null) | 178 | if (data != null) |
179 | { | 179 | { |
180 | string strBuffer = OSDParser.SerializeJsonString(data); | 180 | string strBuffer = OSDParser.SerializeJsonString(data); |
181 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); | 181 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); |
182 | 182 | ||
183 | request.ContentType = "application/json"; | 183 | request.ContentType = "application/json"; |
184 | request.ContentLength = buffer.Length; //Count bytes to send | 184 | request.ContentLength = buffer.Length; //Count bytes to send |
185 | using (Stream requestStream = request.GetRequestStream()) | 185 | using (Stream requestStream = request.GetRequestStream()) |