aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-21 13:47:16 -0700
committerJohn Hurliman2009-10-21 13:47:16 -0700
commit7ee422a344ff22cf988aea2355628d2dee831983 (patch)
treeb0ee8d6004b501f940ecfcc2d00a52a74cabfa25 /OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
parent* Replaced the UnackedPacketCollection with a lockless implementation. The ti... (diff)
downloadopensim-SC-7ee422a344ff22cf988aea2355628d2dee831983.zip
opensim-SC-7ee422a344ff22cf988aea2355628d2dee831983.tar.gz
opensim-SC-7ee422a344ff22cf988aea2355628d2dee831983.tar.bz2
opensim-SC-7ee422a344ff22cf988aea2355628d2dee831983.tar.xz
* Handle UseCircuitCode packets asynchronously. Adding an agent to a scene can take several seconds, and was blocking up packet handling in the meantime
* Clamp retransmission timeout values between three and 10 seconds * Log outgoing time for a packet right after it is sent instead of well before * Loop through the entire UnackedPacketCollection when looking for expired packets
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs47
1 files changed, 39 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index a8ce102..209c0e0 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -381,7 +381,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
381 381
382 // Disconnect an agent if no packets are received for some time 382 // Disconnect an agent if no packets are received for some time
383 //FIXME: Make 60 an .ini setting 383 //FIXME: Make 60 an .ini setting
384 if (Environment.TickCount - udpClient.TickLastPacketReceived > 1000 * 60) 384 if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
385 { 385 {
386 m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); 386 m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
387 387
@@ -439,9 +439,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
439 if (!udpClient.IsConnected) 439 if (!udpClient.IsConnected)
440 return; 440 return;
441 441
442 // Keep track of when this packet was sent out (right now)
443 outgoingPacket.TickCount = Environment.TickCount;
444
445 #region ACK Appending 442 #region ACK Appending
446 443
447 int dataLength = buffer.DataLength; 444 int dataLength = buffer.DataLength;
@@ -494,6 +491,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
494 491
495 // Put the UDP payload on the wire 492 // Put the UDP payload on the wire
496 AsyncBeginSend(buffer); 493 AsyncBeginSend(buffer);
494
495 // Keep track of when this packet was sent out (right now)
496 outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
497 } 497 }
498 498
499 protected override void PacketReceived(UDPPacketBuffer buffer) 499 protected override void PacketReceived(UDPPacketBuffer buffer)
@@ -536,7 +536,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
536 // UseCircuitCode handling 536 // UseCircuitCode handling
537 if (packet.Type == PacketType.UseCircuitCode) 537 if (packet.Type == PacketType.UseCircuitCode)
538 { 538 {
539 AddNewClient((UseCircuitCodePacket)packet, (IPEndPoint)buffer.RemoteEndPoint); 539 Util.FireAndForget(
540 delegate(object o)
541 {
542 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
543
544 // Begin the process of adding the client to the simulator
545 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
546
547 // Acknowledge the UseCircuitCode packet
548 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
549 }
550 );
551 return;
540 } 552 }
541 553
542 // Determine which agent this packet came from 554 // Determine which agent this packet came from
@@ -558,11 +570,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
558 // Stats tracking 570 // Stats tracking
559 Interlocked.Increment(ref udpClient.PacketsReceived); 571 Interlocked.Increment(ref udpClient.PacketsReceived);
560 572
561 #region ACK Receiving 573 int now = Environment.TickCount & Int32.MaxValue;
562
563 int now = Environment.TickCount;
564 udpClient.TickLastPacketReceived = now; 574 udpClient.TickLastPacketReceived = now;
565 575
576 #region ACK Receiving
577
566 // Handle appended ACKs 578 // Handle appended ACKs
567 if (packet.Header.AppendedAcks && packet.Header.AckList != null) 579 if (packet.Header.AppendedAcks && packet.Header.AckList != null)
568 { 580 {
@@ -650,6 +662,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
650 { 662 {
651 } 663 }
652 664
665 private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
666 {
667 PacketAckPacket ack = new PacketAckPacket();
668 ack.Header.Reliable = false;
669 ack.Packets = new PacketAckPacket.PacketsBlock[1];
670 ack.Packets[0] = new PacketAckPacket.PacketsBlock();
671 ack.Packets[0].ID = sequenceNumber;
672
673 byte[] packetData = ack.ToBytes();
674 int length = packetData.Length;
675
676 UDPPacketBuffer buffer = new UDPPacketBuffer(remoteEndpoint, length);
677 buffer.DataLength = length;
678
679 Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
680
681 AsyncBeginSend(buffer);
682 }
683
653 private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) 684 private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo)
654 { 685 {
655 UUID agentID = useCircuitCode.CircuitCode.ID; 686 UUID agentID = useCircuitCode.CircuitCode.ID;