aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP
diff options
context:
space:
mode:
authorMelanie2012-10-17 23:50:48 +0100
committerMelanie2012-10-17 23:50:48 +0100
commit9b684468113cf4933816adae3a53d8ac6d94b173 (patch)
treeea622759f04cd81746b597398f6c66a4f219ea87 /OpenSim/Region/ClientStack/Linden/UDP
parentMerge branch 'avination' into careminster (diff)
parentExplicitly return only the incoming AgentUpdate packet as this is the only on... (diff)
downloadopensim-SC-9b684468113cf4933816adae3a53d8ac6d94b173.zip
opensim-SC-9b684468113cf4933816adae3a53d8ac6d94b173.tar.gz
opensim-SC-9b684468113cf4933816adae3a53d8ac6d94b173.tar.bz2
opensim-SC-9b684468113cf4933816adae3a53d8ac6d94b173.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs7
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs11
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs48
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs10
4 files changed, 62 insertions, 14 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs
index 1b8535c..e22670b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs
@@ -45,7 +45,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
45 public Packet Packet; 45 public Packet Packet;
46 46
47 /// <summary> 47 /// <summary>
48 /// Default constructor 48 /// No arg constructor.
49 /// </summary>
50 public IncomingPacket() {}
51
52 /// <summary>
53 /// Constructor
49 /// </summary> 54 /// </summary>
50 /// <param name="client">Reference to the client this packet came from</param> 55 /// <param name="client">Reference to the client this packet came from</param>
51 /// <param name="packet">Packet data</param> 56 /// <param name="packet">Packet data</param>
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 7686b94..78f5ac9 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5522,16 +5522,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5522 5522
5523 #region Scene/Avatar 5523 #region Scene/Avatar
5524 5524
5525 private bool HandleAgentUpdate(IClientAPI sener, Packet Pack) 5525 private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
5526 { 5526 {
5527 if (OnAgentUpdate != null) 5527 if (OnAgentUpdate != null)
5528 { 5528 {
5529 bool update = false; 5529 bool update = false;
5530 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; 5530 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)packet;
5531 5531
5532 #region Packet Session and User Check 5532 #region Packet Session and User Check
5533 if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId) 5533 if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
5534 {
5535 PacketPool.Instance.ReturnPacket(packet);
5534 return false; 5536 return false;
5537 }
5535 #endregion 5538 #endregion
5536 5539
5537 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData; 5540 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
@@ -5597,6 +5600,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5597 } 5600 }
5598 } 5601 }
5599 5602
5603 PacketPool.Instance.ReturnPacket(packet);
5604
5600 return true; 5605 return true;
5601 } 5606 }
5602 5607
@@ -12041,8 +12046,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12041 12046
12042 if (!ProcessPacketMethod(packet)) 12047 if (!ProcessPacketMethod(packet))
12043 m_log.Warn("[CLIENT]: unhandled packet " + packet.Type); 12048 m_log.Warn("[CLIENT]: unhandled packet " + packet.Type);
12044
12045 PacketPool.Instance.ReturnPacket(packet);
12046 } 12049 }
12047 12050
12048 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 12051 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 7820caf..df4bbb3 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -171,6 +171,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
171 protected bool m_sendPing; 171 protected bool m_sendPing;
172 172
173 private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); 173 private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
174 private Pool<IncomingPacket> m_incomingPacketPool;
174 175
175 private int m_defaultRTO = 0; 176 private int m_defaultRTO = 0;
176 private int m_maxRTO = 0; 177 private int m_maxRTO = 0;
@@ -278,6 +279,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
278 279
279 m_throttle = new TokenBucket(null, sceneThrottleBps); 280 m_throttle = new TokenBucket(null, sceneThrottleBps);
280 ThrottleRates = new ThrottleRates(configSource); 281 ThrottleRates = new ThrottleRates(configSource);
282
283 if (UsePools)
284 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
281 } 285 }
282 286
283 public void Start() 287 public void Start()
@@ -313,7 +317,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
313 317
314 base.StartOutbound(); 318 base.StartOutbound();
315 319
316 // This thread will process the packets received that are placed on the packetInbox
317 Watchdog.StartThread( 320 Watchdog.StartThread(
318 OutgoingPacketHandler, 321 OutgoingPacketHandler,
319 string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName), 322 string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName),
@@ -957,6 +960,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
957 // Handle appended ACKs 960 // Handle appended ACKs
958 if (packet.Header.AppendedAcks && packet.Header.AckList != null) 961 if (packet.Header.AppendedAcks && packet.Header.AckList != null)
959 { 962 {
963// m_log.DebugFormat(
964// "[LLUDPSERVER]: Handling {0} appended acks from {1} in {2}",
965// packet.Header.AckList.Length, client.Name, m_scene.Name);
966
960 for (int i = 0; i < packet.Header.AckList.Length; i++) 967 for (int i = 0; i < packet.Header.AckList.Length; i++)
961 udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent); 968 udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent);
962 } 969 }
@@ -966,6 +973,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
966 { 973 {
967 PacketAckPacket ackPacket = (PacketAckPacket)packet; 974 PacketAckPacket ackPacket = (PacketAckPacket)packet;
968 975
976// m_log.DebugFormat(
977// "[LLUDPSERVER]: Handling {0} packet acks for {1} in {2}",
978// ackPacket.Packets.Length, client.Name, m_scene.Name);
979
969 for (int i = 0; i < ackPacket.Packets.Length; i++) 980 for (int i = 0; i < ackPacket.Packets.Length; i++)
970 udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent); 981 udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent);
971 982
@@ -979,6 +990,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
979 990
980 if (packet.Header.Reliable) 991 if (packet.Header.Reliable)
981 { 992 {
993// m_log.DebugFormat(
994// "[LLUDPSERVER]: Adding ack request for {0} {1} from {2} in {3}",
995// packet.Type, packet.Header.Sequence, client.Name, m_scene.Name);
996
982 udpClient.PendingAcks.Enqueue(packet.Header.Sequence); 997 udpClient.PendingAcks.Enqueue(packet.Header.Sequence);
983 998
984 // This is a somewhat odd sequence of steps to pull the client.BytesSinceLastACK value out, 999 // This is a somewhat odd sequence of steps to pull the client.BytesSinceLastACK value out,
@@ -1025,6 +1040,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1025 1040
1026 if (packet.Type == PacketType.StartPingCheck) 1041 if (packet.Type == PacketType.StartPingCheck)
1027 { 1042 {
1043// m_log.DebugFormat("[LLUDPSERVER]: Handling ping from {0} in {1}", client.Name, m_scene.Name);
1044
1028 // We don't need to do anything else with ping checks 1045 // We don't need to do anything else with ping checks
1029 StartPingCheckPacket startPing = (StartPingCheckPacket)packet; 1046 StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
1030 CompletePing(udpClient, startPing.PingID.PingID); 1047 CompletePing(udpClient, startPing.PingID.PingID);
@@ -1044,13 +1061,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1044 1061
1045 #endregion Ping Check Handling 1062 #endregion Ping Check Handling
1046 1063
1064 IncomingPacket incomingPacket;
1065
1047 // Inbox insertion 1066 // Inbox insertion
1048 if (packet.Type == PacketType.AgentUpdate || 1067 if (UsePools)
1049 packet.Type == PacketType.ChatFromViewer) 1068 {
1050 packetInbox.EnqueueHigh(new IncomingPacket((LLClientView)client, packet)); 1069 incomingPacket = m_incomingPacketPool.GetObject();
1070 incomingPacket.Client = (LLClientView)client;
1071 incomingPacket.Packet = packet;
1072 }
1051 else 1073 else
1052 packetInbox.EnqueueLow(new IncomingPacket((LLClientView)client, packet)); 1074 {
1053// packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet)); 1075 incomingPacket = new IncomingPacket((LLClientView)client, packet);
1076 }
1077
1078 if (incomingPacket.Packet.Type == PacketType.AgentUpdate ||
1079 incomingPacket.Packet.Type == PacketType.ChatFromViewer)
1080 packetInbox.EnqueueHigh(incomingPacket);
1081 else
1082 packetInbox.EnqueueLow(incomingPacket);
1054 } 1083 }
1055 1084
1056 #region BinaryStats 1085 #region BinaryStats
@@ -1333,7 +1362,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1333 // on to en-US to avoid number parsing issues 1362 // on to en-US to avoid number parsing issues
1334 Culture.SetCurrentCulture(); 1363 Culture.SetCurrentCulture();
1335 1364
1336 while (base.IsRunningInbound) 1365 while (IsRunningInbound)
1337 { 1366 {
1338 m_scene.ThreadAlive(1); 1367 m_scene.ThreadAlive(1);
1339 try 1368 try
@@ -1349,7 +1378,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1349 } 1378 }
1350 1379
1351 if (packetInbox.Dequeue(100, ref incomingPacket)) 1380 if (packetInbox.Dequeue(100, ref incomingPacket))
1381 {
1352 ProcessInPacket(incomingPacket);//, incomingPacket); Util.FireAndForget(ProcessInPacket, incomingPacket); 1382 ProcessInPacket(incomingPacket);//, incomingPacket); Util.FireAndForget(ProcessInPacket, incomingPacket);
1383
1384 if (UsePools)
1385 m_incomingPacketPool.ReturnObject(incomingPacket);
1386 }
1353 } 1387 }
1354 catch (Exception ex) 1388 catch (Exception ex)
1355 { 1389 {
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
index 71f6fe1..2a3d14f 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
@@ -108,15 +108,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
108 { 108 {
109 if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0) 109 if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0)
110 { 110 {
111// m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
112
111 // Creating a new packet if we cannot reuse an old package 113 // Creating a new packet if we cannot reuse an old package
112 packet = Packet.BuildPacket(type); 114 packet = Packet.BuildPacket(type);
113 } 115 }
114 else 116 else
115 { 117 {
118// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
119
116 // Recycle old packages 120 // Recycle old packages
117 m_packetsReusedStat.Antecedent++; 121 m_packetsReusedStat.Antecedent++;
118 122
119 packet = (pool[type]).Pop(); 123 packet = pool[type].Pop();
120 } 124 }
121 } 125 }
122 126
@@ -227,7 +231,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
227 231
228 if ((pool[type]).Count < 50) 232 if ((pool[type]).Count < 50)
229 { 233 {
230 (pool[type]).Push(packet); 234// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
235
236 pool[type].Push(packet);
231 } 237 }
232 } 238 }
233 break; 239 break;