Merge branch 'master' of ssh://3dhosting.de/var/git/careminster

avinationmerge
Kitto Flora 2010-04-05 16:15:23 -04:00
commit 4bf1598930
5 changed files with 54 additions and 18 deletions

View File

@ -192,7 +192,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
protected string RegionStats(OSHttpResponse httpResponse, Scene scene) protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
{ {
int users = scene.GetAvatars().Count; int users = scene.GetRootAgentCount();
int objects = scene.Entities.Count - users; int objects = scene.Entities.Count - users;
RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); RestXmlWriter rxw = new RestXmlWriter(new StringWriter());

View File

@ -125,7 +125,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
rxw.WriteEndAttribute(); rxw.WriteEndAttribute();
int users = s.GetAvatars().Count; int users = s.GetRootAgentCount();
rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
rxw.WriteValue(users); rxw.WriteValue(users);
rxw.WriteEndAttribute(); rxw.WriteEndAttribute();

View File

@ -4362,6 +4362,14 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetAvatars(); return m_sceneGraph.GetAvatars();
} }
/// <summary>
/// Cheaply return the number of avatars in a region (without fetching a list object)
/// </summary>
public int GetRootAgentCount()
{
return m_sceneGraph.GetRootAgentCount();
}
/// <summary> /// <summary>
/// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents.
/// This list is a new object, so it can be iterated over without locking. /// This list is a new object, so it can be iterated over without locking.

View File

@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes
/// since the group's last persistent backup /// since the group's last persistent backup
/// </summary> /// </summary>
private bool m_hasGroupChanged = false; private bool m_hasGroupChanged = false;
private long timeFirstChanged; private long timeFirstChanged = 0;
private long timeLastChanged; private long timeLastChanged = 0;
long m_maxPersistTime = 0;
long m_minPersistTime = 0;
Random m_rand;
private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim();
public void lockPartsForRead(bool locked) public void lockPartsForRead(bool locked)
@ -182,6 +186,28 @@ namespace OpenSim.Region.Framework.Scenes
timeLastChanged = DateTime.Now.Ticks; timeLastChanged = DateTime.Now.Ticks;
if (!m_hasGroupChanged) if (!m_hasGroupChanged)
timeFirstChanged = DateTime.Now.Ticks; timeFirstChanged = DateTime.Now.Ticks;
if (m_rand == null)
{
byte[] val = new byte[16];
m_rootPart.UUID.ToBytes(val, 0);
m_rand = new Random(BitConverter.ToInt32(val, 0));
}
if (Scene.GetRootAgentCount() == 0)
{
//If the region is empty, this change has been made by an automated process
//and thus we delay the persist time by a random amount between 1.5 and 2.5.
float factor = 1.5f + (float)(m_rand.NextDouble());
m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor);
m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor);
}
else
{
//If the region is not empty, we want to obey the minimum and maximum persist times
//but add a random factor so we stagger the object persistance a little
m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5
m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0
}
} }
m_hasGroupChanged = value; m_hasGroupChanged = value;
} }
@ -197,8 +223,19 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
if (m_scene.ShuttingDown) if (m_scene.ShuttingDown)
return true; return true;
if (m_minPersistTime == 0 || m_maxPersistTime == 0)
{
m_maxPersistTime = m_scene.m_persistAfter;
m_minPersistTime = m_scene.m_dontPersistBefore;
}
long currentTime = DateTime.Now.Ticks; long currentTime = DateTime.Now.Ticks;
if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter)
if (timeLastChanged == 0) timeLastChanged = currentTime;
if (timeFirstChanged == 0) timeFirstChanged = currentTime;
if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime)
return true; return true;
return false; return false;
} }
@ -529,6 +566,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public SceneObjectGroup() public SceneObjectGroup()
{ {
} }
/// <summary> /// <summary>
@ -2203,13 +2241,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void ScheduleGroupForTerseUpdate() public void ScheduleGroupForTerseUpdate()
{ {
<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
lockPartsForRead(true); lockPartsForRead(true);
=======
// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
lock (m_parts)
>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
{ {
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
@ -3765,15 +3797,11 @@ namespace OpenSim.Region.Framework.Scenes
HasGroupChanged = true; HasGroupChanged = true;
} }
<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
lockPartsForRead(false); lockPartsForRead(false);
ScheduleGroupForFullUpdate();
=======
// Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
// for the same object with very different properties. The caller must schedule the update. // for the same object with very different properties. The caller must schedule the update.
//ScheduleGroupForFullUpdate(); //ScheduleGroupForFullUpdate();
>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
} }
public void TriggerScriptChangedEvent(Changed val) public void TriggerScriptChangedEvent(Changed val)

View File

@ -5266,7 +5266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetRegionAgentCount() public LSL_Integer llGetRegionAgentCount()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return new LSL_Integer(World.GetAvatars().Count); return new LSL_Integer(World.GetRootAgentCount());
} }
public LSL_Vector llGetRegionCorner() public LSL_Vector llGetRegionCorner()