* Bug fix: Fixes an exception when Scene.RemoveClient is called to remove on a

non-existing ScenePresence avatar. Also removed trailing white spaces.
0.6.6-post-fixes
Arthur Valadares 2009-05-29 21:12:55 +00:00
parent 95643971be
commit 8545621d9b
1 changed files with 121 additions and 121 deletions

View File

@ -154,7 +154,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get { return m_capsModule; } get { return m_capsModule; }
} }
protected override IConfigSource GetConfig() protected override IConfigSource GetConfig()
{ {
return m_config; return m_config;
@ -899,17 +899,17 @@ namespace OpenSim.Region.Framework.Scenes
if (m_updateEntitiesThread == null) if (m_updateEntitiesThread == null)
{ {
m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities); m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities);
ThreadTracker.Add(m_updateEntitiesThread); ThreadTracker.Add(m_updateEntitiesThread);
} }
if (m_updateEntitiesThread.ThreadState == ThreadState.Stopped) if (m_updateEntitiesThread.ThreadState == ThreadState.Stopped)
m_updateEntitiesThread.Start(); m_updateEntitiesThread.Start();
*/ */
m_sceneGraph.UpdateEntities(); m_sceneGraph.UpdateEntities();
} }
// run through entities that have scheduled themselves for // run through entities that have scheduled themselves for
// updates looking for updates(faster) // updates looking for updates(faster)
@ -937,7 +937,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_frame % m_update_land == 0) if (m_frame % m_update_land == 0)
UpdateLand(); UpdateLand();
otherMS = Environment.TickCount - otherMS; otherMS = Environment.TickCount - otherMS;
// if (m_frame%m_update_avatars == 0) // if (m_frame%m_update_avatars == 0)
// UpdateInWorldTime(); // UpdateInWorldTime();
@ -1209,8 +1209,8 @@ namespace OpenSim.Region.Framework.Scenes
if (data != null) if (data != null)
{ {
IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>();
if (mapModule != null) if (mapModule != null)
mapModule.LazySaveGeneratedMaptile(data, temporary); mapModule.LazySaveGeneratedMaptile(data, temporary);
} }
} }
@ -1391,7 +1391,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Add an object into the scene that has come from storage /// Add an object into the scene that has come from storage
/// </summary> /// </summary>
/// ///
/// <param name="sceneObject"></param> /// <param name="sceneObject"></param>
/// <param name="attachToBackup"> /// <param name="attachToBackup">
/// If true, changes to the object will be reflected in its persisted data /// If true, changes to the object will be reflected in its persisted data
@ -1778,7 +1778,7 @@ namespace OpenSim.Region.Framework.Scenes
uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt);
} }
return false; return false;
} }
@ -1847,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes
RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
RootPrim.AddFlag(PrimFlags.TemporaryOnRez); RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
} }
} }
else else
{ {
@ -1881,10 +1881,10 @@ namespace OpenSim.Region.Framework.Scenes
if (m_restorePresences.ContainsKey(client.AgentId)) if (m_restorePresences.ContainsKey(client.AgentId))
{ {
m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName); m_log.DebugFormat("[SCENE]: Restoring agent {0} {1} in {2}", client.Name, client.AgentId, RegionInfo.RegionName);
presence = m_restorePresences[client.AgentId]; presence = m_restorePresences[client.AgentId];
m_restorePresences.Remove(client.AgentId); m_restorePresences.Remove(client.AgentId);
// This is one of two paths to create avatars that are // This is one of two paths to create avatars that are
// used. This tends to get called more in standalone // used. This tends to get called more in standalone
// than grid, not really sure why, but as such needs // than grid, not really sure why, but as such needs
@ -1892,11 +1892,11 @@ namespace OpenSim.Region.Framework.Scenes
AvatarAppearance appearance = null; AvatarAppearance appearance = null;
GetAvatarAppearance(client, out appearance); GetAvatarAppearance(client, out appearance);
presence.Appearance = appearance; presence.Appearance = appearance;
presence.initializeScenePresence(client, RegionInfo, this); presence.initializeScenePresence(client, RegionInfo, this);
m_sceneGraph.AddScenePresence(presence); m_sceneGraph.AddScenePresence(presence);
lock (m_restorePresences) lock (m_restorePresences)
{ {
Monitor.PulseAll(m_restorePresences); Monitor.PulseAll(m_restorePresences);
@ -1907,9 +1907,9 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE]: Adding new child agent for {0} in {1}", "[SCENE]: Adding new child agent for {0} in {1}",
client.Name, RegionInfo.RegionName); client.Name, RegionInfo.RegionName);
CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
CreateAndAddScenePresence(client); CreateAndAddScenePresence(client);
} }
@ -1956,7 +1956,7 @@ namespace OpenSim.Region.Framework.Scenes
client.OnObjectDuplicate += m_sceneGraph.DuplicateObject; client.OnObjectDuplicate += m_sceneGraph.DuplicateObject;
client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay;
client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags; client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags;
client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily;
client.OnObjectPermissions += HandleObjectPermissionsUpdate; client.OnObjectPermissions += HandleObjectPermissionsUpdate;
client.OnCreateNewInventoryItem += CreateNewInventoryItem; client.OnCreateNewInventoryItem += CreateNewInventoryItem;
client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder;
@ -1995,9 +1995,9 @@ namespace OpenSim.Region.Framework.Scenes
client.OnUnackedTerrain += TerrainUnAcked; client.OnUnackedTerrain += TerrainUnAcked;
client.OnObjectOwner += ObjectOwner; client.OnObjectOwner += ObjectOwner;
IGodsModule godsModule = RequestModuleInterface<IGodsModule>(); IGodsModule godsModule = RequestModuleInterface<IGodsModule>();
client.OnGodKickUser += godsModule.KickUser; client.OnGodKickUser += godsModule.KickUser;
client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers; client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers;
client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
@ -2171,7 +2171,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[APPEARANCE]: Appearance not found in {0}, returning default", RegionInfo.RegionName); m_log.DebugFormat("[APPEARANCE]: Appearance not found in {0}, returning default", RegionInfo.RegionName);
appearance = new AvatarAppearance(client.AgentId); appearance = new AvatarAppearance(client.AgentId);
} }
} }
/// <summary> /// <summary>
@ -2185,96 +2185,96 @@ namespace OpenSim.Region.Framework.Scenes
if (avatar != null) if (avatar != null)
{ {
childagentYN = avatar.IsChildAgent; childagentYN = avatar.IsChildAgent;
}
if (avatar.ParentID != 0) if (avatar.ParentID != 0)
{
avatar.StandUp();
}
try
{
m_log.DebugFormat(
"[SCENE]: Removing {0} agent {1} from region {2}",
(childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
m_sceneGraph.removeUserCount(!childagentYN);
CapsModule.RemoveCapsHandler(agentID);
if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
{ {
CommsManager.UserProfileCacheService.RemoveUser(agentID); avatar.StandUp();
} }
if (!avatar.IsChildAgent) try
{ {
m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat); m_log.DebugFormat(
//List<ulong> childknownRegions = new List<ulong>(); "[SCENE]: Removing {0} agent {1} from region {2}",
//List<ulong> ckn = avatar.KnownChildRegionHandles; (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
//for (int i = 0; i < ckn.Count; i++)
//{
// childknownRegions.Add(ckn[i]);
//}
List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
regions.Remove(RegionInfo.RegionHandle);
m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
m_sceneGraph.removeUserCount(!childagentYN);
CapsModule.RemoveCapsHandler(agentID);
if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
{
CommsManager.UserProfileCacheService.RemoveUser(agentID);
}
if (!avatar.IsChildAgent)
{
m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
//List<ulong> childknownRegions = new List<ulong>();
//List<ulong> ckn = avatar.KnownChildRegionHandles;
//for (int i = 0; i < ckn.Count; i++)
//{
// childknownRegions.Add(ckn[i]);
//}
List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
regions.Remove(RegionInfo.RegionHandle);
m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
}
m_eventManager.TriggerClientClosed(agentID);
}
catch (NullReferenceException)
{
// We don't know which count to remove it from
// Avatar is already disposed :/
} }
m_eventManager.TriggerClientClosed(agentID);
}
catch (NullReferenceException)
{
// We don't know which count to remove it from
// Avatar is already disposed :/
}
m_eventManager.TriggerOnRemovePresence(agentID); m_eventManager.TriggerOnRemovePresence(agentID);
Broadcast(delegate(IClientAPI client) Broadcast(delegate(IClientAPI client)
{
try
{ {
client.SendKillObject(avatar.RegionHandle, avatar.LocalId); try
} {
catch (NullReferenceException) client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
{ }
//We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. catch (NullReferenceException)
} {
}); //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
}
});
ForEachScenePresence( ForEachScenePresence(
delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
if (agentTransactions != null) if (agentTransactions != null)
{ {
agentTransactions.RemoveAgentAssetTransactions(agentID); agentTransactions.RemoveAgentAssetTransactions(agentID);
}
m_sceneGraph.RemoveScenePresence(agentID);
try
{
avatar.Close();
}
catch (NullReferenceException)
{
//We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
}
catch (Exception e)
{
m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
}
// Remove client agent from profile, so new logins will work
if (!childagentYN)
{
m_sceneGridService.ClearUserAgent(agentID);
}
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
} }
m_sceneGraph.RemoveScenePresence(agentID);
try
{
avatar.Close();
}
catch (NullReferenceException)
{
//We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
}
catch (Exception e)
{
m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
}
// Remove client agent from profile, so new logins will work
if (!childagentYN)
{
m_sceneGridService.ClearUserAgent(agentID);
}
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
} }
public void HandleRemoveKnownRegionsFromAvatar(UUID avatarID, List<ulong> regionslst) public void HandleRemoveKnownRegionsFromAvatar(UUID avatarID, List<ulong> regionslst)
@ -2400,7 +2400,7 @@ namespace OpenSim.Region.Framework.Scenes
// Don't disable this log message - it's too helpful // Don't disable this log message - it's too helpful
m_log.InfoFormat( m_log.InfoFormat(
"[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5})", "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5})",
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode); agent.AgentID, agent.circuitcode);
reason = String.Empty; reason = String.Empty;
@ -2412,7 +2412,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.InfoFormat( m_log.InfoFormat(
"[CONNECTION BEGIN]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", "[CONNECTION BEGIN]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode); agent.AgentID, agent.circuitcode);
CapsModule.NewUserConnection(agent); CapsModule.NewUserConnection(agent);
@ -2423,14 +2423,14 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE]: Adjusting known seeds for existing agent {0} in {1}", "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
agent.AgentID, RegionInfo.RegionName); agent.AgentID, RegionInfo.RegionName);
sp.AdjustKnownSeeds(); sp.AdjustKnownSeeds();
return true; return true;
} }
CapsModule.AddCapsHandler(agent.AgentID); CapsModule.AddCapsHandler(agent.AgentID);
if (!agent.child) if (!agent.child)
{ {
// Honor parcel landing type and position. // Honor parcel landing type and position.
@ -2443,9 +2443,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
// rewrite session_id // rewrite session_id
CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
if (userinfo != null) if (userinfo != null)
@ -2457,7 +2457,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat( m_log.WarnFormat(
"[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID);
} }
return true; return true;
} }
@ -2467,7 +2467,7 @@ namespace OpenSim.Region.Framework.Scenes
bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID);
m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result);
if (!result) if (!result)
reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
return result; return result;
@ -2479,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!m_strictAccessControl) return true; if (!m_strictAccessControl) return true;
if (Permissions.IsGod(agent.AgentID)) return true; if (Permissions.IsGod(agent.AgentID)) return true;
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
{ {
@ -2490,12 +2490,12 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
if (!m_regInfo.EstateSettings.PublicAccess && if (!m_regInfo.EstateSettings.PublicAccess &&
!m_regInfo.EstateSettings.HasAccess(agent.AgentID)) !m_regInfo.EstateSettings.HasAccess(agent.AgentID))
{ {
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
RegionInfo.RegionName); RegionInfo.RegionName);
return false; return false;
} }
@ -2512,7 +2512,7 @@ namespace OpenSim.Region.Framework.Scenes
// { // {
// m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
// agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
// reason = String.Format("Denied access to private region {0}: You are banned from that region.", // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
// RegionInfo.RegionName); // RegionInfo.RegionName);
// return false; // return false;
// } // }
@ -2521,7 +2521,7 @@ namespace OpenSim.Region.Framework.Scenes
// { // {
// m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
// agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
// reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
// RegionInfo.RegionName); // RegionInfo.RegionName);
// return false; // return false;
// } // }
@ -2861,7 +2861,7 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region Other Methods #region Other Methods
public void SetObjectCapacity(int objects) public void SetObjectCapacity(int objects)
{ {
// Region specific config overrides global // Region specific config overrides global
@ -2875,7 +2875,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
objectCapacity = objects; objectCapacity = objects;
} }
public List<FriendListItem> GetFriendList(string id) public List<FriendListItem> GetFriendList(string id)
{ {
UUID avatarID; UUID avatarID;
@ -2974,7 +2974,7 @@ namespace OpenSim.Region.Framework.Scenes
public override void Show(string[] showParams) public override void Show(string[] showParams)
{ {
base.Show(showParams); base.Show(showParams);
switch (showParams[0]) switch (showParams[0])
{ {
case "users": case "users":
@ -2993,9 +2993,9 @@ namespace OpenSim.Region.Framework.Scenes
"Unknown", "Unknown",
RegionInfo.RegionName); RegionInfo.RegionName);
} }
break; break;
} }
} }
#region Script Handling Methods #region Script Handling Methods
@ -3055,8 +3055,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
else if ((parcel.landData.Flags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0) else if ((parcel.landData.Flags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0)
{ {
if (part.OwnerID == parcel.landData.OwnerID if (part.OwnerID == parcel.landData.OwnerID
|| (parcel.landData.IsGroupOwned && part.GroupID == parcel.landData.GroupID) || (parcel.landData.IsGroupOwned && part.GroupID == parcel.landData.GroupID)
|| Permissions.IsGod(part.OwnerID)) || Permissions.IsGod(part.OwnerID))
{ {
return true; return true;