diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs (renamed from OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs) | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs index a80c1f0..1f73a1d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -25,47 +25,49 @@ | |||
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 OpenMetaverse.Packets; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | 30 | ||
30 | namespace OpenSim.Region.ClientStack.LindenUDP | 31 | namespace OpenSim.Region.ClientStack.LindenUDP |
31 | { | 32 | { |
32 | /// <summary> | 33 | /// <summary> |
33 | /// When packetqueue dequeues this packet in the outgoing stream, it thread aborts | 34 | /// A circular buffer and hashset for tracking incoming packet sequence |
34 | /// Ensures that the thread abort happens from within the client thread | 35 | /// numbers |
35 | /// regardless of where the close method is called | ||
36 | /// </summary> | 36 | /// </summary> |
37 | class KillPacket : Packet | 37 | public sealed class IncomingPacketHistoryCollection |
38 | { | 38 | { |
39 | public override int Length | 39 | private readonly uint[] m_items; |
40 | { | 40 | private HashSet<uint> m_hashSet; |
41 | get { return 0; } | 41 | private int m_first; |
42 | } | 42 | private int m_next; |
43 | private int m_capacity; | ||
43 | 44 | ||
44 | public override void FromBytes(Header header, byte[] bytes, ref int i, ref int packetEnd) | 45 | public IncomingPacketHistoryCollection(int capacity) |
45 | { | 46 | { |
47 | this.m_capacity = capacity; | ||
48 | m_items = new uint[capacity]; | ||
49 | m_hashSet = new HashSet<uint>(); | ||
46 | } | 50 | } |
47 | 51 | ||
48 | public override void FromBytes(byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer) | 52 | public bool TryEnqueue(uint ack) |
49 | { | 53 | { |
50 | } | 54 | lock (m_hashSet) |
55 | { | ||
56 | if (m_hashSet.Add(ack)) | ||
57 | { | ||
58 | m_items[m_next] = ack; | ||
59 | m_next = (m_next + 1) % m_capacity; | ||
60 | if (m_next == m_first) | ||
61 | { | ||
62 | m_hashSet.Remove(m_items[m_first]); | ||
63 | m_first = (m_first + 1) % m_capacity; | ||
64 | } | ||
51 | 65 | ||
52 | public override byte[] ToBytes() | 66 | return true; |
53 | { | 67 | } |
54 | return new byte[0]; | 68 | } |
55 | } | ||
56 | 69 | ||
57 | public override byte[][] ToBytesMultiple() | 70 | return false; |
58 | { | ||
59 | return new byte[][] { new byte[0] }; | ||
60 | } | ||
61 | |||
62 | public KillPacket() | ||
63 | { | ||
64 | Type = PacketType.UseCircuitCode; | ||
65 | Header = new Header(); | ||
66 | Header.Frequency = OpenMetaverse.PacketFrequency.Low; | ||
67 | Header.ID = 65531; | ||
68 | Header.Reliable = true; | ||
69 | } | 71 | } |
70 | } | 72 | } |
71 | } | 73 | } |