use seconds version of gettimestamp

httptests
UbitUmarov 2018-04-19 19:08:28 +01:00
parent 728040ab47
commit 79ec9d2887
2 changed files with 14 additions and 42 deletions

View File

@ -244,9 +244,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
lock (responses) lock (responses)
{ {
bool ret = m_throttler.hasEvents(x, responses); return m_throttler.hasEvents(x, responses);
return ret;
} }
}; };
@ -434,43 +432,32 @@ namespace OpenSim.Region.ClientStack.Linden
if(pBytes < 10000) if(pBytes < 10000)
pBytes = 10000; pBytes = 10000;
ThrottleBytes = pBytes; ThrottleBytes = pBytes;
lastTimeElapsed = Util.GetTimeStampMS(); lastTimeElapsed = Util.GetTimeStamp();
} }
public bool hasEvents(UUID key, Dictionary<UUID, APollResponse> responses) public bool hasEvents(UUID key, Dictionary<UUID, APollResponse> responses)
{ {
PassTime(); PassTime();
// Note, this is called IN LOCK APollResponse response;
bool haskey = responses.ContainsKey(key);
if (!haskey)
{
return false;
}
APollResponse response;
if (responses.TryGetValue(key, out response)) if (responses.TryGetValue(key, out response))
{ {
// Normal // Normal
if (BytesSent <= ThrottleBytes) if (response.bytes == 0 || BytesSent <= ThrottleBytes)
{ {
BytesSent += response.bytes; BytesSent += response.bytes;
return true; return true;
} }
else
{
return false;
}
} }
return haskey; return false;
} }
public void PassTime() public void PassTime()
{ {
double currenttime = Util.GetTimeStampMS(); double currenttime = Util.GetTimeStamp();
double timeElapsed = currenttime - lastTimeElapsed; double timeElapsed = currenttime - lastTimeElapsed;
if(timeElapsed < 50.0) if(timeElapsed < .05)
return; return;
int add = (int)(ThrottleBytes * timeElapsed * 0.001); int add = (int)(ThrottleBytes * timeElapsed);
if (add >= 1000) if (add >= 1000)
{ {
lastTimeElapsed = currenttime; lastTimeElapsed = currenttime;

View File

@ -450,46 +450,31 @@ namespace OpenSim.Region.ClientStack.Linden
if(pBytes < 10000) if(pBytes < 10000)
pBytes = 10000; pBytes = 10000;
ThrottleBytes = pBytes; ThrottleBytes = pBytes;
lastTimeElapsed = Util.GetTimeStampMS(); lastTimeElapsed = Util.GetTimeStamp();
} }
public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.APollResponse> responses) public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.APollResponse> responses)
{ {
PassTime(); PassTime();
// Note, this is called IN LOCK // Note, this is called IN LOCK
bool haskey = responses.ContainsKey(key);
if (!haskey)
{
return false;
}
GetTextureModule.APollResponse response; GetTextureModule.APollResponse response;
if (responses.TryGetValue(key, out response)) if (responses.TryGetValue(key, out response))
{ {
// This is any error response if (response.bytes == 0 || BytesSent <= ThrottleBytes)
if (response.bytes == 0)
return true;
// Normal
if (BytesSent <= ThrottleBytes)
{ {
BytesSent += response.bytes; BytesSent += response.bytes;
return true; return true;
} }
else
{
return false;
}
} }
return false;
return haskey;
} }
public void PassTime() public void PassTime()
{ {
double currenttime = Util.GetTimeStampMS(); double currenttime = Util.GetTimeStamp();
double timeElapsed = currenttime - lastTimeElapsed; double timeElapsed = currenttime - lastTimeElapsed;
if(timeElapsed < 50.0) if(timeElapsed < .05)
return; return;
int add = (int)(ThrottleBytes * timeElapsed * 0.001); int add = (int)(ThrottleBytes * timeElapsed);
if (add >= 1000) if (add >= 1000)
{ {
lastTimeElapsed = currenttime; lastTimeElapsed = currenttime;