aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs85
1 files changed, 59 insertions, 26 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index be6f7ef..4bdf132 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -125,6 +125,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
125 /// whether or not to sleep</summary> 125 /// whether or not to sleep</summary>
126 private bool m_packetSent; 126 private bool m_packetSent;
127 127
128 /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
129 private int m_tickLastOutgoingPacketHandler;
130 /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
131 private int m_elapsedMSOutgoingPacketHandler;
132 /// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed</summary>
133 private int m_elapsed100MSOutgoingPacketHandler;
134 /// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed</summary>
135 private int m_elapsed500MSOutgoingPacketHandler;
136
137 /// <summary>Flag to signal when clients should check for resends</summary>
138 private bool m_resendUnacked;
139 /// <summary>Flag to signal when clients should send ACKs</summary>
140 private bool m_sendAcks;
141 /// <summary>Flag to signal when clients should send pings</summary>
142 private bool m_sendPing;
143
128 public Socket Server { get { return null; } } 144 public Socket Server { get { return null; } }
129 145
130 public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) 146 public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
@@ -786,6 +802,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP
786 { 802 {
787 m_packetSent = false; 803 m_packetSent = false;
788 804
805 #region Update Timers
806
807 m_resendUnacked = false;
808 m_sendAcks = false;
809 m_sendPing = false;
810
811 // Update elapsed time
812 int thisTick = Environment.TickCount & Int32.MaxValue;
813 if (m_tickLastOutgoingPacketHandler > thisTick)
814 m_elapsedMSOutgoingPacketHandler += ((Int32.MaxValue - m_tickLastOutgoingPacketHandler) + thisTick);
815 else
816 m_elapsedMSOutgoingPacketHandler += (thisTick - m_tickLastOutgoingPacketHandler);
817
818 m_tickLastOutgoingPacketHandler = thisTick;
819
820 // Check for pending outgoing resends every 100ms
821 if (m_elapsedMSOutgoingPacketHandler >= 100)
822 {
823 m_resendUnacked = true;
824 m_elapsedMSOutgoingPacketHandler = 0;
825 m_elapsed100MSOutgoingPacketHandler += 1;
826 }
827
828 // Check for pending outgoing ACKs every 500ms
829 if (m_elapsed100MSOutgoingPacketHandler >= 5)
830 {
831 m_sendAcks = true;
832 m_elapsed100MSOutgoingPacketHandler = 0;
833 m_elapsed500MSOutgoingPacketHandler += 1;
834 }
835
836 // Send pings to clients every 5000ms
837 if (m_elapsed500MSOutgoingPacketHandler >= 10)
838 {
839 m_sendPing = true;
840 m_elapsed500MSOutgoingPacketHandler = 0;
841 }
842
843 #endregion Update Timers
844
789 // Handle outgoing packets, resends, acknowledgements, and pings for each 845 // Handle outgoing packets, resends, acknowledgements, and pings for each
790 // client. m_packetSent will be set to true if a packet is sent 846 // client. m_packetSent will be set to true if a packet is sent
791 m_scene.ClientManager.ForEachSync(ClientOutgoingPacketHandler); 847 m_scene.ClientManager.ForEachSync(ClientOutgoingPacketHandler);
@@ -810,44 +866,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
810 { 866 {
811 LLUDPClient udpClient = ((LLClientView)client).UDPClient; 867 LLUDPClient udpClient = ((LLClientView)client).UDPClient;
812 868
813 // Update ElapsedMSOutgoingPacketHandler
814 int thisTick = Environment.TickCount & Int32.MaxValue;
815 if (udpClient.TickLastOutgoingPacketHandler > thisTick)
816 udpClient.ElapsedMSOutgoingPacketHandler += ((Int32.MaxValue - udpClient.TickLastOutgoingPacketHandler) + thisTick);
817 else
818 udpClient.ElapsedMSOutgoingPacketHandler += (thisTick - udpClient.TickLastOutgoingPacketHandler);
819
820 if (udpClient.IsConnected) 869 if (udpClient.IsConnected)
821 { 870 {
822 // Check for pending outgoing resends every 100ms 871 if (m_resendUnacked)
823 if (udpClient.ElapsedMSOutgoingPacketHandler >= 100)
824 {
825 ResendUnacked(udpClient); 872 ResendUnacked(udpClient);
826 udpClient.ElapsedMSOutgoingPacketHandler = 0;
827 udpClient.Elapsed100MSOutgoingPacketHandler += 1;
828 }
829 873
830 // Check for pending outgoing ACKs every 500ms 874 if (m_sendAcks)
831 if (udpClient.Elapsed100MSOutgoingPacketHandler >= 5)
832 {
833 SendAcks(udpClient); 875 SendAcks(udpClient);
834 udpClient.Elapsed100MSOutgoingPacketHandler = 0;
835 udpClient.Elapsed500MSOutgoingPacketHandler += 1;
836 }
837 876
838 // Send pings to clients every 5000ms 877 if (m_sendPing)
839 if (udpClient.Elapsed500MSOutgoingPacketHandler >= 10)
840 {
841 SendPing(udpClient); 878 SendPing(udpClient);
842 udpClient.Elapsed500MSOutgoingPacketHandler = 0;
843 }
844 879
845 // Dequeue any outgoing packets that are within the throttle limits 880 // Dequeue any outgoing packets that are within the throttle limits
846 if (udpClient.DequeueOutgoing()) 881 if (udpClient.DequeueOutgoing())
847 m_packetSent = true; 882 m_packetSent = true;
848 } 883 }
849
850 udpClient.TickLastOutgoingPacketHandler = thisTick;
851 } 884 }
852 } 885 }
853 catch (Exception ex) 886 catch (Exception ex)