From 7351d92a76ac24edce848fe7410e920f17962101 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 29 Aug 2014 16:19:30 +0100 Subject: [PATCH] add method to get a category throttle rate --- OpenSim/Framework/IClientAPI.cs | 1 + .../ClientStack/Linden/UDP/LLClientView.cs | 8 ++- .../ClientStack/Linden/UDP/LLUDPClient.cs | 67 +++++++++---------- .../Server/IRCClientView.cs | 5 ++ .../OptionalModules/World/NPC/NPCAvatar.cs | 5 ++ OpenSim/Tests/Common/Mock/TestClient.cs | 5 ++ 6 files changed, 53 insertions(+), 38 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index d73802e0b5..c386c95038 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1186,6 +1186,7 @@ namespace OpenSim.Framework void SetChildAgentThrottle(byte[] throttle); void SetAgentThrottleSilent(int throttle, int setting); + int GetAgentThrottleSilent(int throttle); void SendAvatarDataImmediate(ISceneEntity avatar); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 72279645db..12ee3b2e4a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -12306,16 +12306,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// - /// Sets the throttles from values supplied by the client + /// Sets the throttles from values supplied caller /// /// public void SetAgentThrottleSilent(int throttle, int setting) { m_udpClient.ForceThrottleSetting(throttle,setting); - //m_udpClient.SetThrottles(throttles); - } + public int GetAgentThrottleSilent(int throttle) + { + return m_udpClient.GetThrottleSetting(throttle); + } /// /// Get the current throttles for this client as a packed byte array diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 89a9401373..f91abfe2b8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -688,6 +688,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP RTO = Math.Min(RTO * 2, m_maxRTO); } + + const int MIN_CALLBACK_MS = 30; + /// /// Does an early check to see if this queue empty callback is already /// running, then asynchronously firing the event @@ -695,24 +698,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttle categories to fire the callback for private void BeginFireQueueEmpty(ThrottleOutPacketTypeFlags categories) { -// if (m_nextOnQueueEmpty != 0 && (Environment.TickCount & Int32.MaxValue) >= m_nextOnQueueEmpty) - if (!m_isQueueEmptyRunning && (Environment.TickCount & Int32.MaxValue) >= m_nextOnQueueEmpty) + if (!m_isQueueEmptyRunning) { - m_isQueueEmptyRunning = true; - int start = Environment.TickCount & Int32.MaxValue; - const int MIN_CALLBACK_MS = 30; + + if (start < m_nextOnQueueEmpty) + return; + + m_isQueueEmptyRunning = true; m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; if (m_nextOnQueueEmpty == 0) m_nextOnQueueEmpty = 1; - // Use a value of 0 to signal that FireQueueEmpty is running -// m_nextOnQueueEmpty = 0; - - m_categories = categories; - - if (HasUpdates(m_categories)) + if (HasUpdates(categories)) { // Asynchronously run the callback Util.FireAndForget(FireQueueEmpty, categories); @@ -725,7 +724,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } private bool m_isQueueEmptyRunning; - private ThrottleOutPacketTypeFlags m_categories = 0; + /// /// Fires the OnQueueEmpty callback and sets the minimum time that it @@ -736,35 +735,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// signature private void FireQueueEmpty(object o) { -// int start = Environment.TickCount & Int32.MaxValue; -// const int MIN_CALLBACK_MS = 30; + ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o; + QueueEmpty callback = OnQueueEmpty; -// if (m_udpServer.IsRunningOutbound) -// { - ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o; - QueueEmpty callback = OnQueueEmpty; - - if (callback != null) - { -// if (m_udpServer.IsRunningOutbound) -// { - try { callback(categories); } - catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); } -// } - } -// } - -// m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; -// if (m_nextOnQueueEmpty == 0) -// m_nextOnQueueEmpty = 1; - -// } + if (callback != null) + { + // if (m_udpServer.IsRunningOutbound) + // { + try { callback(categories); } + catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); } + // } + } m_isQueueEmptyRunning = false; } + internal void ForceThrottleSetting(int throttle, int setting) { - m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); ; + if (throttle > 0 && throttle < THROTTLE_CATEGORY_COUNT) + m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); + } + + internal int GetThrottleSetting(int throttle) + { + if (throttle > 0 && throttle < THROTTLE_CATEGORY_COUNT) + return (int)m_throttleCategories[throttle].RequestedDripRate; + else + return 0; } /// diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 2112b718aa..a45bea9902 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1705,5 +1705,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) { } + + public int GetAgentThrottleSilent(int throttle) + { + return 0; + } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index fa1d38a31f..cb87536c4e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1276,5 +1276,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public int GetAgentThrottleSilent(int throttle) + { + return 0; + } + } } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 27580300d8..00929df827 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -548,6 +548,11 @@ namespace OpenSim.Tests.Common.Mock { } + public int GetAgentThrottleSilent(int throttle) + { + return 0; + } + public byte[] GetThrottlesPacked(float multiplier) { return new byte[0];