mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
merge
This commit is contained in:
@@ -220,7 +220,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, 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;
|
||||
|
||||
}
|
||||
@@ -271,8 +270,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_throttler.ProcessTime();
|
||||
responses.Remove(x);
|
||||
m_throttler.PassTime();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -285,6 +284,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
reqinfo.request = y;
|
||||
|
||||
m_queue.Enqueue(reqinfo);
|
||||
m_throttler.PassTime();
|
||||
};
|
||||
|
||||
// this should never happen except possible on shutdown
|
||||
@@ -364,12 +364,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,24 +426,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 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<UUID, aPollResponse> responses)
|
||||
@@ -470,46 +464,22 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
return haskey;
|
||||
}
|
||||
|
||||
public void ProcessTime()
|
||||
public void PassTime()
|
||||
{
|
||||
PassTime();
|
||||
}
|
||||
|
||||
private void PassTime()
|
||||
double currenttime = Util.GetTimeStampMS();
|
||||
double timeElapsed = currenttime - lastTimeElapsed;
|
||||
if(timeElapsed < 50.0)
|
||||
return;
|
||||
int add = (int)(ThrottleBytes * timeElapsed * 0.001);
|
||||
if (add >= 1000)
|
||||
{
|
||||
currenttime = Util.EnvironmentTickCount();
|
||||
int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
|
||||
if (timeElapsed >= 100)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user