diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 116 |
1 files changed, 110 insertions, 6 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index b4ac021..7a4c6f4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -69,9 +69,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
69 | 69 | ||
70 | StatsManager.RegisterStat( | 70 | StatsManager.RegisterStat( |
71 | new Stat( | 71 | new Stat( |
72 | "IncomingUDPReceivesCount", | ||
73 | "Number of UDP receives performed", | ||
74 | "Number of UDP receives performed", | ||
75 | "", | ||
76 | "clientstack", | ||
77 | scene.Name, | ||
78 | StatType.Pull, | ||
79 | MeasuresOfInterest.AverageChangeOverTime, | ||
80 | stat => stat.Value = m_udpServer.UdpReceives, | ||
81 | StatVerbosity.Debug)); | ||
82 | |||
83 | StatsManager.RegisterStat( | ||
84 | new Stat( | ||
72 | "IncomingPacketsProcessedCount", | 85 | "IncomingPacketsProcessedCount", |
73 | "Number of inbound UDP packets processed", | 86 | "Number of inbound LL protocol packets processed", |
74 | "Number of inbound UDP packets processed", | 87 | "Number of inbound LL protocol packets processed", |
75 | "", | 88 | "", |
76 | "clientstack", | 89 | "clientstack", |
77 | scene.Name, | 90 | scene.Name, |
@@ -79,6 +92,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
79 | MeasuresOfInterest.AverageChangeOverTime, | 92 | MeasuresOfInterest.AverageChangeOverTime, |
80 | stat => stat.Value = m_udpServer.IncomingPacketsProcessed, | 93 | stat => stat.Value = m_udpServer.IncomingPacketsProcessed, |
81 | StatVerbosity.Debug)); | 94 | StatVerbosity.Debug)); |
95 | |||
96 | StatsManager.RegisterStat( | ||
97 | new Stat( | ||
98 | "OutgoingUDPSendsCount", | ||
99 | "Number of UDP sends performed", | ||
100 | "Number of UDP sends performed", | ||
101 | "", | ||
102 | "clientstack", | ||
103 | scene.Name, | ||
104 | StatType.Pull, | ||
105 | MeasuresOfInterest.AverageChangeOverTime, | ||
106 | stat => stat.Value = m_udpServer.UdpSends, | ||
107 | StatVerbosity.Debug)); | ||
108 | |||
109 | StatsManager.RegisterStat( | ||
110 | new Stat( | ||
111 | "AverageUDPProcessTime", | ||
112 | "Average number of milliseconds taken to process each incoming UDP packet in a sample.", | ||
113 | "This is for initial receive processing which is separate from the later client LL packet processing stage.", | ||
114 | "ms", | ||
115 | "clientstack", | ||
116 | scene.Name, | ||
117 | StatType.Pull, | ||
118 | MeasuresOfInterest.None, | ||
119 | stat => stat.Value = m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond, | ||
120 | // stat => | ||
121 | // stat.Value = Math.Round(m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond, 7), | ||
122 | StatVerbosity.Debug)); | ||
82 | } | 123 | } |
83 | 124 | ||
84 | public bool HandlesRegion(Location x) | 125 | public bool HandlesRegion(Location x) |
@@ -185,6 +226,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
185 | protected bool m_sendPing; | 226 | protected bool m_sendPing; |
186 | 227 | ||
187 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); | 228 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); |
229 | |||
230 | /// <summary> | ||
231 | /// Event used to signal when queued packets are available for sending. | ||
232 | /// </summary> | ||
233 | /// <remarks> | ||
234 | /// This allows the outbound loop to only operate when there is data to send rather than continuously polling. | ||
235 | /// Some data is sent immediately and not queued. That data would not trigger this event. | ||
236 | /// </remarks> | ||
237 | private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); | ||
238 | |||
188 | private Pool<IncomingPacket> m_incomingPacketPool; | 239 | private Pool<IncomingPacket> m_incomingPacketPool; |
189 | 240 | ||
190 | /// <summary> | 241 | /// <summary> |
@@ -462,6 +513,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
462 | m_scene = (Scene)scene; | 513 | m_scene = (Scene)scene; |
463 | m_location = new Location(m_scene.RegionInfo.RegionHandle); | 514 | m_location = new Location(m_scene.RegionInfo.RegionHandle); |
464 | 515 | ||
516 | StatsManager.RegisterStat( | ||
517 | new Stat( | ||
518 | "InboxPacketsCount", | ||
519 | "Number of LL protocol packets waiting for the second stage of processing after initial receive.", | ||
520 | "Number of LL protocol packets waiting for the second stage of processing after initial receive.", | ||
521 | "", | ||
522 | "clientstack", | ||
523 | scene.Name, | ||
524 | StatType.Pull, | ||
525 | MeasuresOfInterest.AverageChangeOverTime, | ||
526 | stat => stat.Value = packetInbox.Count, | ||
527 | StatVerbosity.Debug)); | ||
528 | |||
465 | // XXX: These stats are also pool stats but we register them separately since they are currently not | 529 | // XXX: These stats are also pool stats but we register them separately since they are currently not |
466 | // turned on and off by EnablePools()/DisablePools() | 530 | // turned on and off by EnablePools()/DisablePools() |
467 | StatsManager.RegisterStat( | 531 | StatsManager.RegisterStat( |
@@ -575,6 +639,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
575 | "debug lludp status", | 639 | "debug lludp status", |
576 | "Return status of LLUDP packet processing.", | 640 | "Return status of LLUDP packet processing.", |
577 | HandleStatusCommand); | 641 | HandleStatusCommand); |
642 | |||
643 | MainConsole.Instance.Commands.AddCommand( | ||
644 | "Debug", | ||
645 | false, | ||
646 | "debug lludp toggle agentupdate", | ||
647 | "debug lludp toggle agentupdate", | ||
648 | "Toggle whether agentupdate packets are processed or simply discarded.", | ||
649 | HandleAgentUpdateCommand); | ||
578 | } | 650 | } |
579 | 651 | ||
580 | private void HandlePacketCommand(string module, string[] args) | 652 | private void HandlePacketCommand(string module, string[] args) |
@@ -709,6 +781,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
709 | } | 781 | } |
710 | } | 782 | } |
711 | 783 | ||
784 | bool m_discardAgentUpdates; | ||
785 | |||
786 | private void HandleAgentUpdateCommand(string module, string[] args) | ||
787 | { | ||
788 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
789 | return; | ||
790 | |||
791 | m_discardAgentUpdates = !m_discardAgentUpdates; | ||
792 | |||
793 | MainConsole.Instance.OutputFormat( | ||
794 | "Discard AgentUpdates now {0} for {1}", m_discardAgentUpdates, m_scene.Name); | ||
795 | } | ||
796 | |||
712 | private void HandleStatusCommand(string module, string[] args) | 797 | private void HandleStatusCommand(string module, string[] args) |
713 | { | 798 | { |
714 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | 799 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
@@ -809,12 +894,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
809 | } | 894 | } |
810 | 895 | ||
811 | PacketPool.Instance.ReturnPacket(packet); | 896 | PacketPool.Instance.ReturnPacket(packet); |
812 | m_dataPresentEvent.Set(); | ||
813 | 897 | ||
898 | m_dataPresentEvent.Set(); | ||
814 | } | 899 | } |
815 | 900 | ||
816 | private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); | ||
817 | |||
818 | /// <summary> | 901 | /// <summary> |
819 | /// Start the process of sending a packet to the client. | 902 | /// Start the process of sending a packet to the client. |
820 | /// </summary> | 903 | /// </summary> |
@@ -1325,6 +1408,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1325 | LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); | 1408 | LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); |
1326 | #endregion BinaryStats | 1409 | #endregion BinaryStats |
1327 | 1410 | ||
1411 | if (packet.Type == PacketType.AgentUpdate) | ||
1412 | { | ||
1413 | if (m_discardAgentUpdates) | ||
1414 | return; | ||
1415 | |||
1416 | ((LLClientView)client).TotalAgentUpdates++; | ||
1417 | |||
1418 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; | ||
1419 | |||
1420 | LLClientView llClient = client as LLClientView; | ||
1421 | if (agentUpdate.AgentData.SessionID != client.SessionId | ||
1422 | || agentUpdate.AgentData.AgentID != client.AgentId | ||
1423 | || !(llClient == null || llClient.CheckAgentUpdateSignificance(agentUpdate.AgentData)) ) | ||
1424 | { | ||
1425 | PacketPool.Instance.ReturnPacket(packet); | ||
1426 | return; | ||
1427 | } | ||
1428 | } | ||
1429 | |||
1328 | #region Ping Check Handling | 1430 | #region Ping Check Handling |
1329 | 1431 | ||
1330 | if (packet.Type == PacketType.StartPingCheck) | 1432 | if (packet.Type == PacketType.StartPingCheck) |
@@ -1734,7 +1836,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1734 | // Action generic every round | 1836 | // Action generic every round |
1735 | Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler; | 1837 | Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler; |
1736 | 1838 | ||
1737 | // while (true) | ||
1738 | while (base.IsRunningOutbound) | 1839 | while (base.IsRunningOutbound) |
1739 | { | 1840 | { |
1740 | m_scene.ThreadAlive(2); | 1841 | m_scene.ThreadAlive(2); |
@@ -1798,6 +1899,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1798 | // token bucket could get more tokens | 1899 | // token bucket could get more tokens |
1799 | //if (!m_packetSent) | 1900 | //if (!m_packetSent) |
1800 | // Thread.Sleep((int)TickCountResolution); | 1901 | // Thread.Sleep((int)TickCountResolution); |
1902 | // | ||
1903 | // Instead, now wait for data present to be explicitly signalled. Evidence so far is that with | ||
1904 | // modern mono it reduces CPU base load since there is no more continuous polling. | ||
1801 | m_dataPresentEvent.WaitOne(100); | 1905 | m_dataPresentEvent.WaitOne(100); |
1802 | 1906 | ||
1803 | Watchdog.UpdateThread(); | 1907 | Watchdog.UpdateThread(); |