diff options
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 85 |
3 files changed, 63 insertions, 41 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 997f38c..91afa4d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -3558,7 +3558,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3558 | ProcessTextureRequests(); | 3558 | ProcessTextureRequests(); |
3559 | break; | 3559 | break; |
3560 | case ThrottleOutPacketType.Task: | 3560 | case ThrottleOutPacketType.Task: |
3561 | if (Monitor.TryEnter(m_avatarTerseUpdates.SyncRoot, 1)) | 3561 | if (Monitor.TryEnter(m_avatarTerseUpdates.SyncRoot)) |
3562 | { | 3562 | { |
3563 | try | 3563 | try |
3564 | { | 3564 | { |
@@ -3573,7 +3573,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3573 | } | 3573 | } |
3574 | break; | 3574 | break; |
3575 | case ThrottleOutPacketType.State: | 3575 | case ThrottleOutPacketType.State: |
3576 | if (Monitor.TryEnter(m_primFullUpdates.SyncRoot, 1)) | 3576 | if (Monitor.TryEnter(m_primFullUpdates.SyncRoot)) |
3577 | { | 3577 | { |
3578 | try | 3578 | try |
3579 | { | 3579 | { |
@@ -3586,7 +3586,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3586 | finally { Monitor.Exit(m_primFullUpdates.SyncRoot); } | 3586 | finally { Monitor.Exit(m_primFullUpdates.SyncRoot); } |
3587 | } | 3587 | } |
3588 | 3588 | ||
3589 | if (Monitor.TryEnter(m_primTerseUpdates.SyncRoot, 1)) | 3589 | if (Monitor.TryEnter(m_primTerseUpdates.SyncRoot)) |
3590 | { | 3590 | { |
3591 | try | 3591 | try |
3592 | { | 3592 | { |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index de67ca7..0a090b4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | |||
@@ -103,14 +103,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
103 | public bool IsPaused; | 103 | public bool IsPaused; |
104 | /// <summary>Environment.TickCount when the last packet was received for this client</summary> | 104 | /// <summary>Environment.TickCount when the last packet was received for this client</summary> |
105 | public int TickLastPacketReceived; | 105 | public int TickLastPacketReceived; |
106 | /// <summary>Environment.TickCount of the last time the outgoing packet handler executed for this client</summary> | ||
107 | public int TickLastOutgoingPacketHandler; | ||
108 | /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler executed for this client</summary> | ||
109 | public int ElapsedMSOutgoingPacketHandler; | ||
110 | /// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed for this client</summary> | ||
111 | public int Elapsed100MSOutgoingPacketHandler; | ||
112 | /// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed for this client</summary> | ||
113 | public int Elapsed500MSOutgoingPacketHandler; | ||
114 | 106 | ||
115 | /// <summary>Smoothed round-trip time. A smoothed average of the round-trip time for sending a | 107 | /// <summary>Smoothed round-trip time. A smoothed average of the round-trip time for sending a |
116 | /// reliable packet to the client and receiving an ACK</summary> | 108 | /// reliable packet to the client and receiving an ACK</summary> |
@@ -191,9 +183,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
191 | 183 | ||
192 | // Initialize this to a sane value to prevent early disconnects | 184 | // Initialize this to a sane value to prevent early disconnects |
193 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; | 185 | TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; |
194 | ElapsedMSOutgoingPacketHandler = 0; | ||
195 | Elapsed100MSOutgoingPacketHandler = 0; | ||
196 | Elapsed500MSOutgoingPacketHandler = 0; | ||
197 | } | 186 | } |
198 | 187 | ||
199 | /// <summary> | 188 | /// <summary> |
@@ -553,7 +542,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
553 | } | 542 | } |
554 | 543 | ||
555 | // HACK: Try spending some extra time here to slow down OnQueueEmpty calls | 544 | // HACK: Try spending some extra time here to slow down OnQueueEmpty calls |
556 | System.Threading.Thread.Sleep(100); | 545 | //System.Threading.Thread.Sleep(100); |
557 | 546 | ||
558 | m_onQueueEmptyRunning[i] = false; | 547 | m_onQueueEmptyRunning[i] = false; |
559 | } | 548 | } |
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) |