better have a lock

0.9.1.0-post-fixes
UbitUmarov 2018-10-08 18:53:30 +01:00
parent 57ec0d3884
commit 235dd37b9c
1 changed files with 23 additions and 19 deletions

View File

@ -6856,12 +6856,15 @@ namespace OpenSim.Region.Framework.Scenes
private int m_bandwidthBurst = 20000; private int m_bandwidthBurst = 20000;
private int m_bytesControl; private int m_bytesControl;
private double m_lastBandwithTime; private double m_lastBandwithTime;
private object m_throttleLock = new object();
public bool CapCanSendAsset(int type, int size) public bool CapCanSendAsset(int type, int size)
{ {
if(size == 0) if(size == 0)
return true; return true;
lock (m_throttleLock)
{
if (type > 1) if (type > 1)
{ {
// not texture or mesh // not texture or mesh
@ -6871,7 +6874,7 @@ namespace OpenSim.Region.Framework.Scenes
double currenttime = Util.GetTimeStamp(); double currenttime = Util.GetTimeStamp();
double timeElapsed = currenttime - m_lastBandwithTime; double timeElapsed = currenttime - m_lastBandwithTime;
if (timeElapsed > .05) if (timeElapsed > .02)
{ {
m_lastBandwithTime = currenttime; m_lastBandwithTime = currenttime;
int add = (int)(m_bandwidth * timeElapsed); int add = (int)(m_bandwidth * timeElapsed);
@ -6884,6 +6887,7 @@ namespace OpenSim.Region.Framework.Scenes
m_bytesControl -= size; m_bytesControl -= size;
return true; return true;
} }
}
return false; return false;
} }
} }