aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
diff options
context:
space:
mode:
authorJeff Ames2008-07-23 13:24:25 +0000
committerJeff Ames2008-07-23 13:24:25 +0000
commit80d8e2889e62d8900837d37a800a4eeaae5ffc5a (patch)
tree47bdf0f48ae8ace3bb7cd10ab91d91b52b96f80e /OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
parentget rid of some LLQuaternion == null checks. Because LLQuaternion is (diff)
downloadopensim-SC-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.zip
opensim-SC-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.gz
opensim-SC-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.bz2
opensim-SC-80d8e2889e62d8900837d37a800a4eeaae5ffc5a.tar.xz
Update svn properties. Formatting cleanup. Remove a compiler warning.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs122
1 files changed, 61 insertions, 61 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
index c09da9b..11abf87 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs
@@ -57,9 +57,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
57 void InPacket(Packet packet); 57 void InPacket(Packet packet);
58 void ProcessInPacket(Packet packet); 58 void ProcessInPacket(Packet packet);
59 void OutPacket(Packet NewPack, 59 void OutPacket(Packet NewPack,
60 ThrottleOutPacketType throttlePacketType); 60 ThrottleOutPacketType throttlePacketType);
61 void OutPacket(Packet NewPack, 61 void OutPacket(Packet NewPack,
62 ThrottleOutPacketType throttlePacketType, Object id); 62 ThrottleOutPacketType throttlePacketType, Object id);
63 LLPacketQueue PacketQueue { get; } 63 LLPacketQueue PacketQueue { get; }
64 void Stop(); 64 void Stop();
65 void Flush(); 65 void Flush();
@@ -136,7 +136,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
136 // time for a linear scan. 136 // time for a linear scan.
137 // 137 //
138 private Dictionary<uint, int> m_DupeTracker = 138 private Dictionary<uint, int> m_DupeTracker =
139 new Dictionary<uint, int>(); 139 new Dictionary<uint, int>();
140 private uint m_DupeTrackerWindow = 30; 140 private uint m_DupeTrackerWindow = 30;
141 141
142 // Values for the SimStatsReporter 142 // Values for the SimStatsReporter
@@ -207,14 +207,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
207 // notifier. 207 // notifier.
208 // 208 //
209 public void OutPacket( 209 public void OutPacket(
210 Packet packet, ThrottleOutPacketType throttlePacketType) 210 Packet packet, ThrottleOutPacketType throttlePacketType)
211 { 211 {
212 OutPacket(packet, throttlePacketType, null); 212 OutPacket(packet, throttlePacketType, null);
213 } 213 }
214 214
215 public void OutPacket( 215 public void OutPacket(
216 Packet packet, ThrottleOutPacketType throttlePacketType, 216 Packet packet, ThrottleOutPacketType throttlePacketType,
217 Object id) 217 Object id)
218 { 218 {
219 // Call the load balancer's hook. If this is not active here 219 // Call the load balancer's hook. If this is not active here
220 // we defer to the sim server this client is actually connected 220 // we defer to the sim server this client is actually connected
@@ -224,20 +224,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
224 if ((m_SynchronizeClient != null) && (!m_Client.IsActive)) 224 if ((m_SynchronizeClient != null) && (!m_Client.IsActive))
225 { 225 {
226 if (m_SynchronizeClient(m_Client.Scene, packet, 226 if (m_SynchronizeClient(m_Client.Scene, packet,
227 m_Client.AgentId, throttlePacketType)) 227 m_Client.AgentId, throttlePacketType))
228 return; 228 return;
229 } 229 }
230 230
231 packet.Header.Sequence = NextPacketSequenceNumber(); 231 packet.Header.Sequence = NextPacketSequenceNumber();
232 232
233 lock(m_NeedAck) 233 lock (m_NeedAck)
234 { 234 {
235 DropResend(id); 235 DropResend(id);
236 236
237 QueuePacket(packet, throttlePacketType, id); 237 QueuePacket(packet, throttlePacketType, id);
238 238
239 // We want to see that packet arrive if it's reliable 239 // We want to see that packet arrive if it's reliable
240 if(packet.Header.Reliable) 240 if (packet.Header.Reliable)
241 { 241 {
242 m_UnackedBytes += packet.ToBytes().Length; 242 m_UnackedBytes += packet.ToBytes().Length;
243 m_NeedAck[packet.Header.Sequence] = new AckData(packet, id); 243 m_NeedAck[packet.Header.Sequence] = new AckData(packet, id);
@@ -251,24 +251,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
251 { 251 {
252 // Add acks to outgoing packets 252 // Add acks to outgoing packets
253 // 253 //
254 if(m_PendingAcks.Count > 0) 254 if (m_PendingAcks.Count > 0)
255 { 255 {
256 int count = m_PendingAcks.Count; 256 int count = m_PendingAcks.Count;
257 if(count > 10) 257 if (count > 10)
258 count = 10; 258 count = 10;
259 packet.Header.AckList = new uint[count]; 259 packet.Header.AckList = new uint[count];
260 260
261 int i = 0; 261 int i = 0;
262 262
263 foreach (uint ack in new List<uint>(m_PendingAcks.Keys)) 263 foreach (uint ack in new List<uint>(m_PendingAcks.Keys))
264 { 264 {
265 packet.Header.AckList[i] = ack; 265 packet.Header.AckList[i] = ack;
266 i++; 266 i++;
267 m_PendingAcks.Remove(ack); 267 m_PendingAcks.Remove(ack);
268 if (i >= 10) // That is how much space there is 268 if (i >= 10) // That is how much space there is
269 break; 269 break;
270 } 270 }
271 } 271 }
272 272
273 packet.TickCount = System.Environment.TickCount; 273 packet.TickCount = System.Environment.TickCount;
274 274
@@ -291,14 +291,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
291 // anything. There may not be a client there, don't clog up the 291 // anything. There may not be a client there, don't clog up the
292 // pipes. 292 // pipes.
293 // 293 //
294 if(lastAck == 0) 294 if (lastAck == 0)
295 return; 295 return;
296 296
297 lock (m_NeedAck) 297 lock (m_NeedAck)
298 { 298 {
299 // Nothing to do 299 // Nothing to do
300 // 300 //
301 if(m_NeedAck.Count == 0) 301 if (m_NeedAck.Count == 0)
302 return; 302 return;
303 303
304 // If we have seen no acks in <SilenceLimit> s but are 304 // If we have seen no acks in <SilenceLimit> s but are
@@ -307,7 +307,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
307 // then it will be dropped. 307 // then it will be dropped.
308 // 308 //
309 if ((((now - lastAck) > m_SilenceLimit) && 309 if ((((now - lastAck) > m_SilenceLimit) &&
310 m_NeedAck.Count > 0) || m_NeedAck.Count == 0) 310 m_NeedAck.Count > 0) || m_NeedAck.Count == 0)
311 { 311 {
312 return; 312 return;
313 } 313 }
@@ -336,7 +336,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
336 // 336 //
337 if ((now - packet.TickCount) > m_DiscardTimeout) 337 if ((now - packet.TickCount) > m_DiscardTimeout)
338 { 338 {
339 if(!m_ImportantPackets.Contains(packet.Type)) 339 if (!m_ImportantPackets.Contains(packet.Type))
340 m_NeedAck.Remove(packet.Header.Sequence); 340 m_NeedAck.Remove(packet.Header.Sequence);
341 341
342 TriggerOnPacketDrop(packet, data.Identifier); 342 TriggerOnPacketDrop(packet, data.Identifier);
@@ -364,8 +364,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
364 // the counter reaches 250. So there is a good chance another 364 // the counter reaches 250. So there is a good chance another
365 // packet with 250 blocks exists. 365 // packet with 250 blocks exists.
366 // 366 //
367 if(acks.Packets == null || 367 if (acks.Packets == null ||
368 acks.Packets.Length != m_PendingAcks.Count) 368 acks.Packets.Length != m_PendingAcks.Count)
369 acks.Packets = new PacketAckPacket.PacketsBlock[m_PendingAcks.Count]; 369 acks.Packets = new PacketAckPacket.PacketsBlock[m_PendingAcks.Count];
370 int i = 0; 370 int i = 0;
371 foreach (uint ack in new List<uint>(m_PendingAcks.Keys)) 371 foreach (uint ack in new List<uint>(m_PendingAcks.Keys))
@@ -389,11 +389,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
389 { 389 {
390 lock (m_PendingAcks) 390 lock (m_PendingAcks)
391 { 391 {
392 if(m_PendingAcks.Count < 250) 392 if (m_PendingAcks.Count < 250)
393 { 393 {
394 if(!m_PendingAcks.ContainsKey(packet.Header.Sequence)) 394 if (!m_PendingAcks.ContainsKey(packet.Header.Sequence))
395 m_PendingAcks.Add(packet.Header.Sequence, 395 m_PendingAcks.Add(packet.Header.Sequence,
396 packet.Header.Sequence); 396 packet.Header.Sequence);
397 return; 397 return;
398 } 398 }
399 } 399 }
@@ -405,11 +405,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
405 // If this is still full we have a truly exceptional 405 // If this is still full we have a truly exceptional
406 // condition (means, can't happen) 406 // condition (means, can't happen)
407 // 407 //
408 if(m_PendingAcks.Count < 250) 408 if (m_PendingAcks.Count < 250)
409 { 409 {
410 if(!m_PendingAcks.ContainsKey(packet.Header.Sequence)) 410 if (!m_PendingAcks.ContainsKey(packet.Header.Sequence))
411 m_PendingAcks.Add(packet.Header.Sequence, 411 m_PendingAcks.Add(packet.Header.Sequence,
412 packet.Header.Sequence); 412 packet.Header.Sequence);
413 return; 413 return;
414 } 414 }
415 } 415 }
@@ -433,9 +433,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
433 if (handlerPacketStats != null) 433 if (handlerPacketStats != null)
434 { 434 {
435 handlerPacketStats( 435 handlerPacketStats(
436 m_PacketsReceived - m_PacketsReceivedReported, 436 m_PacketsReceived - m_PacketsReceivedReported,
437 m_PacketsSent - m_PacketsSentReported, 437 m_PacketsSent - m_PacketsSentReported,
438 m_UnackedBytes); 438 m_UnackedBytes);
439 439
440 m_PacketsReceivedReported = m_PacketsReceived; 440 m_PacketsReceivedReported = m_PacketsReceived;
441 m_PacketsSentReported = m_PacketsSent; 441 m_PacketsSentReported = m_PacketsSent;
@@ -450,12 +450,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
450 lock (m_DupeTracker) 450 lock (m_DupeTracker)
451 { 451 {
452 Dictionary<uint, int> packs = 452 Dictionary<uint, int> packs =
453 new Dictionary<uint, int>(m_DupeTracker); 453 new Dictionary<uint, int>(m_DupeTracker);
454 454
455 foreach (uint pack in packs.Keys) 455 foreach (uint pack in packs.Keys)
456 { 456 {
457 if(Util.UnixTimeSinceEpoch() - m_DupeTracker[pack] > 457 if (Util.UnixTimeSinceEpoch() - m_DupeTracker[pack] >
458 m_DupeTrackerWindow) 458 m_DupeTrackerWindow)
459 m_DupeTracker.Remove(pack); 459 m_DupeTracker.Remove(pack);
460 } 460 }
461 } 461 }
@@ -463,13 +463,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
463 463
464 public void InPacket(Packet packet) 464 public void InPacket(Packet packet)
465 { 465 {
466 if(packet == null) 466 if (packet == null)
467 return; 467 return;
468 468
469 // If this client is on another partial instance, no need 469 // If this client is on another partial instance, no need
470 // to handle packets 470 // to handle packets
471 // 471 //
472 if(!m_Client.IsActive && packet.Type != PacketType.LogoutRequest) 472 if (!m_Client.IsActive && packet.Type != PacketType.LogoutRequest)
473 { 473 {
474 PacketPool.Instance.ReturnPacket(packet); 474 PacketPool.Instance.ReturnPacket(packet);
475 return; 475 return;
@@ -478,9 +478,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
478 // Any packet can have some packet acks in the header. 478 // Any packet can have some packet acks in the header.
479 // Process them here 479 // Process them here
480 // 480 //
481 if(packet.Header.AppendedAcks) 481 if (packet.Header.AppendedAcks)
482 { 482 {
483 foreach(uint id in packet.Header.AckList) 483 foreach (uint id in packet.Header.AckList)
484 { 484 {
485 ProcessAck(id); 485 ProcessAck(id);
486 } 486 }
@@ -489,12 +489,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
489 // When too many acks are needed to be sent, the client sends 489 // When too many acks are needed to be sent, the client sends
490 // a packet consisting of acks only 490 // a packet consisting of acks only
491 // 491 //
492 if(packet.Type == PacketType.PacketAck) 492 if (packet.Type == PacketType.PacketAck)
493 { 493 {
494 PacketAckPacket ackPacket = (PacketAckPacket)packet; 494 PacketAckPacket ackPacket = (PacketAckPacket)packet;
495 495
496 foreach (PacketAckPacket.PacketsBlock block in 496 foreach (PacketAckPacket.PacketsBlock block in
497 ackPacket.Packets) 497 ackPacket.Packets)
498 { 498 {
499 ProcessAck(block.ID); 499 ProcessAck(block.ID);
500 } 500 }
@@ -502,7 +502,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
502 PacketPool.Instance.ReturnPacket(packet); 502 PacketPool.Instance.ReturnPacket(packet);
503 return; 503 return;
504 } 504 }
505 else if(packet.Type == PacketType.StartPingCheck) 505 else if (packet.Type == PacketType.StartPingCheck)
506 { 506 {
507 StartPingCheckPacket startPing = (StartPingCheckPacket)packet; 507 StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
508 CompletePingCheckPacket endPing = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck); 508 CompletePingCheckPacket endPing = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck);
@@ -537,7 +537,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
537 return; 537 return;
538 538
539 m_DupeTracker.Add(packet.Header.Sequence, 539 m_DupeTracker.Add(packet.Header.Sequence,
540 Util.UnixTimeSinceEpoch()); 540 Util.UnixTimeSinceEpoch());
541 } 541 }
542 542
543 m_Client.ProcessInPacket(packet); 543 m_Client.ProcessInPacket(packet);
@@ -560,9 +560,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
560 AckData data; 560 AckData data;
561 Packet packet; 561 Packet packet;
562 562
563 lock(m_NeedAck) 563 lock (m_NeedAck)
564 { 564 {
565 if(!m_NeedAck.TryGetValue(id, out data)) 565 if (!m_NeedAck.TryGetValue(id, out data))
566 return; 566 return;
567 567
568 packet = data.Packet; 568 packet = data.Packet;
@@ -650,7 +650,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
650 650
651 public void AddImportantPacket(PacketType type) 651 public void AddImportantPacket(PacketType type)
652 { 652 {
653 if(m_ImportantPackets.Contains(type)) 653 if (m_ImportantPackets.Contains(type))
654 return; 654 return;
655 655
656 m_ImportantPackets.Add(type); 656 m_ImportantPackets.Add(type);
@@ -658,7 +658,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
658 658
659 public void RemoveImportantPacket(PacketType type) 659 public void RemoveImportantPacket(PacketType type)
660 { 660 {
661 if(!m_ImportantPackets.Contains(type)) 661 if (!m_ImportantPackets.Contains(type))
662 return; 662 return;
663 663
664 m_ImportantPackets.Remove(type); 664 m_ImportantPackets.Remove(type);
@@ -668,7 +668,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
668 { 668 {
669 foreach (AckData data in new List<AckData>(m_NeedAck.Values)) 669 foreach (AckData data in new List<AckData>(m_NeedAck.Values))
670 { 670 {
671 if(data.Identifier != null && data.Identifier == id) 671 if (data.Identifier != null && data.Identifier == id)
672 { 672 {
673 m_NeedAck.Remove(data.Packet.Header.Sequence); 673 m_NeedAck.Remove(data.Packet.Header.Sequence);
674 return; 674 return;
@@ -680,7 +680,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
680 { 680 {
681 PacketDrop handlerPacketDrop = OnPacketDrop; 681 PacketDrop handlerPacketDrop = OnPacketDrop;
682 682
683 if(handlerPacketDrop == null) 683 if (handlerPacketDrop == null)
684 return; 684 return;
685 685
686 handlerPacketDrop(packet, id); 686 handlerPacketDrop(packet, id);