From 79e166e9aaf56b6798e27201962f6e109925c697 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 19 Jun 2017 05:22:38 +0100
Subject: revert EnvironmentTick back to orignal clock, since change may cause
issues on some code paths. Clean a bit get mesh and get texture throttle
---
OpenSim/Framework/Util.cs | 7 +-
.../ClientStack/Linden/Caps/GetMeshModule.cs | 81 +++++++---------------
.../ClientStack/Linden/Caps/GetTextureModule.cs | 45 ++++++------
3 files changed, 49 insertions(+), 84 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index a855767..af14939 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2967,9 +2967,9 @@ namespace OpenSim.Framework
///
public static Int32 EnvironmentTickCount()
{
- double now = GetTimeStampMS();
- return (int)now;
+ return Environment.TickCount & EnvironmentTickCountMask;
}
+
const Int32 EnvironmentTickCountMask = 0x3fffffff;
///
@@ -2994,8 +2994,7 @@ namespace OpenSim.Framework
/// subtraction of passed prevValue from current Environment.TickCount
public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
{
- double now = GetTimeStampMS();
- return EnvironmentTickCountSubtract((int)now, prevValue);
+ return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue);
}
// Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index a721454..ba917e39 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -221,7 +221,7 @@ namespace OpenSim.Region.ClientStack.Linden
PollServiceMeshEventArgs args;
if (m_pollservices.TryGetValue(user, out args))
{
- args.UpdateThrottle(imagethrottle, p);
+ args.UpdateThrottle(imagethrottle);
}
}
@@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden
base(null, uri, null, null, null, pId, int.MaxValue)
{
m_scene = scene;
- m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId);
+ m_throttler = new MeshCapsDataThrottler(100000);
// x is request id, y is userid
HasEvents = (x, y) =>
{
lock (responses)
{
bool ret = m_throttler.hasEvents(x, responses);
- m_throttler.ProcessTime();
return ret;
}
@@ -260,8 +259,8 @@ namespace OpenSim.Region.ClientStack.Linden
}
finally
{
- m_throttler.ProcessTime();
responses.Remove(x);
+ m_throttler.PassTime();
}
}
};
@@ -274,6 +273,7 @@ namespace OpenSim.Region.ClientStack.Linden
reqinfo.request = y;
m_queue.Enqueue(reqinfo);
+ m_throttler.PassTime();
};
// this should never happen except possible on shutdown
@@ -335,12 +335,15 @@ namespace OpenSim.Region.ClientStack.Linden
};
}
- m_throttler.ProcessTime();
+ m_throttler.PassTime();
}
- internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
+ internal void UpdateThrottle(int pthrottle)
{
- m_throttler.UpdateThrottle(pimagethrottle, p);
+ int tmp = 2 * pthrottle;
+ if(tmp < 10000)
+ tmp = 10000;
+ m_throttler.ThrottleBytes = tmp;
}
}
@@ -394,25 +397,15 @@ namespace OpenSim.Region.ClientStack.Linden
internal sealed class MeshCapsDataThrottler
{
+ private double lastTimeElapsed = 0;
+ private double BytesSent = 0;
- private volatile int currenttime = 0;
- private volatile int lastTimeElapsed = 0;
- private volatile int BytesSent = 0;
- private int CapSetThrottle = 0;
- private float CapThrottleDistributon = 0.30f;
- private readonly Scene m_scene;
- private ThrottleOutPacketType Throttle;
- private readonly UUID User;
-
- public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser)
+ public MeshCapsDataThrottler(int pBytes)
{
+ if(pBytes < 10000)
+ pBytes = 10000;
ThrottleBytes = pBytes;
- if(ThrottleBytes < 10000)
- ThrottleBytes = 10000;
- lastTimeElapsed = Util.EnvironmentTickCount();
- Throttle = ThrottleOutPacketType.Asset;
- m_scene = pScene;
- User = puser;
+ lastTimeElapsed = Util.GetTimeStampMS();
}
public bool hasEvents(UUID key, Dictionary responses)
@@ -442,46 +435,22 @@ namespace OpenSim.Region.ClientStack.Linden
return haskey;
}
- public void ProcessTime()
- {
- PassTime();
- }
-
- private void PassTime()
+ public void PassTime()
{
- currenttime = Util.EnvironmentTickCount();
- int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
- if (timeElapsed >= 100)
+ double currenttime = Util.GetTimeStampMS();
+ double timeElapsed = currenttime - lastTimeElapsed;
+ if(timeElapsed < 50.0)
+ return;
+ int add = (int)(ThrottleBytes * timeElapsed * 0.001);
+ if (add >= 1000)
{
lastTimeElapsed = currenttime;
- BytesSent -= (ThrottleBytes * timeElapsed / 1000);
+ BytesSent -= add;
if (BytesSent < 0) BytesSent = 0;
}
}
- private void AlterThrottle(int setting, ScenePresence p)
- {
- p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
- }
-
- public int ThrottleBytes
- {
- get { return CapSetThrottle; }
- set
- {
- if (value > 10000)
- CapSetThrottle = value;
- else
- CapSetThrottle = 10000;
- }
- }
-
- internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
- {
- // Client set throttle !
- CapSetThrottle = 2 * pimagethrottle;
- ProcessTime();
- }
+ public int ThrottleBytes;
}
}
}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index ce9798b..b01c7dc 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden
new Dictionary();
private Scene m_scene;
- private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000);
+ private CapsDataThrottler m_throttler = new CapsDataThrottler(100000);
public PollServiceTextureEventArgs(UUID pId, Scene scene) :
base(null, "", null, null, null, pId, int.MaxValue)
{
@@ -231,7 +231,6 @@ namespace OpenSim.Region.ClientStack.Linden
lock (responses)
{
bool ret = m_throttler.hasEvents(x, responses);
- m_throttler.ProcessTime();
return ret;
}
@@ -247,6 +246,7 @@ namespace OpenSim.Region.ClientStack.Linden
finally
{
responses.Remove(x);
+ m_throttler.PassTime();
}
}
};
@@ -271,6 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
}
m_queue.Enqueue(reqinfo);
+ m_throttler.PassTime();
};
// this should never happen except possible on shutdown
@@ -351,14 +352,15 @@ namespace OpenSim.Region.ClientStack.Linden
};
}
- m_throttler.ProcessTime();
+ m_throttler.PassTime();
}
internal void UpdateThrottle(int pimagethrottle)
{
- m_throttler.ThrottleBytes = 2 * pimagethrottle;
- if(m_throttler.ThrottleBytes < 10000)
- m_throttler.ThrottleBytes = 10000;
+ int tmp = 2 * pimagethrottle;
+ if(tmp < 10000)
+ tmp = 10000;
+ m_throttler.ThrottleBytes = tmp;
}
}
@@ -426,16 +428,14 @@ namespace OpenSim.Region.ClientStack.Linden
internal sealed class CapsDataThrottler
{
-
- private volatile int currenttime = 0;
- private volatile int lastTimeElapsed = 0;
+ private double lastTimeElapsed = 0;
private volatile int BytesSent = 0;
- public CapsDataThrottler(int pBytes, int max, int min)
+ public CapsDataThrottler(int pBytes)
{
+ if(pBytes < 10000)
+ pBytes = 10000;
ThrottleBytes = pBytes;
- if(ThrottleBytes < 10000)
- ThrottleBytes = 10000;
- lastTimeElapsed = Util.EnvironmentTickCount();
+ lastTimeElapsed = Util.GetTimeStampMS();
}
public bool hasEvents(UUID key, Dictionary responses)
{
@@ -468,20 +468,17 @@ namespace OpenSim.Region.ClientStack.Linden
return haskey;
}
- public void ProcessTime()
- {
- PassTime();
- }
-
- private void PassTime()
+ public void PassTime()
{
- currenttime = Util.EnvironmentTickCount();
- int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
- //processTimeBasedActions(responses);
- if (timeElapsed >= 100)
+ double currenttime = Util.GetTimeStampMS();
+ double timeElapsed = currenttime - lastTimeElapsed;
+ if(timeElapsed < 50.0)
+ return;
+ int add = (int)(ThrottleBytes * timeElapsed * 0.001);
+ if (add >= 1000)
{
lastTimeElapsed = currenttime;
- BytesSent -= (ThrottleBytes * timeElapsed / 1000);
+ BytesSent -= add;
if (BytesSent < 0) BytesSent = 0;
}
}
--
cgit v1.1