Merge branch 'careminster-presence-refactor' of ssh://melanie@3dhosting.de/var/git/careminster into careminster-presence-refactor

avinationmerge
Melanie 2010-05-16 15:02:23 +01:00
commit a723225179
6 changed files with 73 additions and 13 deletions

View File

@ -909,7 +909,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
client.OnLogout += LogoutHandler; client.OnLogout += LogoutHandler;
// Start the IClientAPI // Start the IClientAPI
client.Start(); // Spin it off so that it doesn't clog up the LLUDPServer
Util.FireAndForget(delegate(object o) { client.Start(); });
} }
else else
{ {

View File

@ -201,9 +201,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
UserFriendData data = m_Friends[principalID]; UserFriendData data = m_Friends[principalID];
string searchFor = friendID.ToString();
foreach (FriendInfo fi in data.Friends) foreach (FriendInfo fi in data.Friends)
{ {
if (fi.Friend == friendID.ToString()) if (fi.Friend == searchFor)
return (uint)fi.TheirFlags; return (uint)fi.TheirFlags;
} }
return 0; return 0;

View File

@ -70,6 +70,9 @@ namespace OpenSim.Region.Framework.Scenes
protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>(); protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>();
protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0];
protected List<ScenePresence> m_scenePresenceList = new List<ScenePresence>();
protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim();
// SceneObjects is not currently populated or used. // SceneObjects is not currently populated or used.
//public Dictionary<UUID, SceneObjectGroup> SceneObjects; //public Dictionary<UUID, SceneObjectGroup> SceneObjects;
@ -132,10 +135,16 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void Close() protected internal void Close()
{ {
lock (m_scenePresences) m_scenePresencesLock.EnterWriteLock();
try
{ {
m_scenePresences.Clear(); m_scenePresences.Clear();
m_scenePresenceArray = new ScenePresence[0]; m_scenePresenceArray = new ScenePresence[0];
m_scenePresenceList = new List<ScenePresence>();
}
finally
{
m_scenePresencesLock.ExitWriteLock();
} }
lock (m_dictionary_lock) lock (m_dictionary_lock)
@ -542,7 +551,8 @@ namespace OpenSim.Region.Framework.Scenes
Entities[presence.UUID] = presence; Entities[presence.UUID] = presence;
lock (m_scenePresences) m_scenePresencesLock.EnterWriteLock();
try
{ {
if (!m_scenePresences.ContainsKey(presence.UUID)) if (!m_scenePresences.ContainsKey(presence.UUID))
{ {
@ -554,11 +564,12 @@ namespace OpenSim.Region.Framework.Scenes
Array.Copy(m_scenePresenceArray, newArray, oldLength); Array.Copy(m_scenePresenceArray, newArray, oldLength);
newArray[oldLength] = presence; newArray[oldLength] = presence;
m_scenePresenceArray = newArray; m_scenePresenceArray = newArray;
m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray);
} }
else else
{ {
m_scenePresences[presence.UUID] = presence; m_scenePresences[presence.UUID] = presence;
// Do a linear search through the array of ScenePresence references // Do a linear search through the array of ScenePresence references
// and update the modified entry // and update the modified entry
for (int i = 0; i < m_scenePresenceArray.Length; i++) for (int i = 0; i < m_scenePresenceArray.Length; i++)
@ -569,8 +580,13 @@ namespace OpenSim.Region.Framework.Scenes
break; break;
} }
} }
m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray);
} }
} }
finally
{
m_scenePresencesLock.ExitWriteLock();
}
} }
/// <summary> /// <summary>
@ -585,7 +601,8 @@ namespace OpenSim.Region.Framework.Scenes
agentID); agentID);
} }
lock (m_scenePresences) m_scenePresencesLock.EnterWriteLock();
try
{ {
if (m_scenePresences.Remove(agentID)) if (m_scenePresences.Remove(agentID))
{ {
@ -604,12 +621,17 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
m_scenePresenceArray = newArray; m_scenePresenceArray = newArray;
m_scenePresenceList = new List<ScenePresence>(m_scenePresenceArray);
} }
else else
{ {
m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
} }
} }
finally
{
m_scenePresencesLock.ExitWriteLock();
}
} }
protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F)
@ -730,8 +752,15 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns> /// <returns></returns>
private List<ScenePresence> GetScenePresences() private List<ScenePresence> GetScenePresences()
{ {
lock (m_scenePresences) m_scenePresencesLock.EnterReadLock();
return new List<ScenePresence>(m_scenePresenceArray); try
{
return m_scenePresenceList;
}
finally
{
m_scenePresencesLock.ExitReadLock();
}
} }
/// <summary> /// <summary>
@ -742,10 +771,15 @@ namespace OpenSim.Region.Framework.Scenes
protected internal ScenePresence GetScenePresence(UUID agentID) protected internal ScenePresence GetScenePresence(UUID agentID)
{ {
ScenePresence sp; ScenePresence sp;
lock (m_scenePresences) m_scenePresencesLock.EnterReadLock();
try
{ {
m_scenePresences.TryGetValue(agentID, out sp); m_scenePresences.TryGetValue(agentID, out sp);
} }
finally
{
m_scenePresencesLock.ExitReadLock();
}
return sp; return sp;
} }
@ -780,10 +814,15 @@ namespace OpenSim.Region.Framework.Scenes
protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar)
{ {
lock (m_scenePresences) m_scenePresencesLock.EnterReadLock();
try
{ {
m_scenePresences.TryGetValue(agentID, out avatar); m_scenePresences.TryGetValue(agentID, out avatar);
} }
finally
{
m_scenePresencesLock.ExitReadLock();
}
return (avatar != null); return (avatar != null);
} }
@ -1061,6 +1100,7 @@ namespace OpenSim.Region.Framework.Scenes
Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
*/ */
// For now, perform actiona serially // For now, perform actiona serially
foreach (ScenePresence sp in GetScenePresences()) foreach (ScenePresence sp in GetScenePresences())
{ {
try try

View File

@ -3651,7 +3651,8 @@ namespace OpenSim.Region.Framework.Scenes
if (atRotTargets.Count > 0) if (atRotTargets.Count > 0)
{ {
uint[] localids = new uint[0]; uint[] localids = new uint[0];
lock (m_parts) lockPartsForRead(true);
try
{ {
localids = new uint[m_parts.Count]; localids = new uint[m_parts.Count];
int cntr = 0; int cntr = 0;
@ -3661,6 +3662,10 @@ namespace OpenSim.Region.Framework.Scenes
cntr++; cntr++;
} }
} }
finally
{
lockPartsForRead(false);
}
for (int ctr = 0; ctr < localids.Length; ctr++) for (int ctr = 0; ctr < localids.Length; ctr++)
{ {
@ -3679,7 +3684,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
//trigger not_at_target //trigger not_at_target
uint[] localids = new uint[0]; uint[] localids = new uint[0];
lock (m_parts) lockPartsForRead(true);
try
{ {
localids = new uint[m_parts.Count]; localids = new uint[m_parts.Count];
int cntr = 0; int cntr = 0;
@ -3689,6 +3695,10 @@ namespace OpenSim.Region.Framework.Scenes
cntr++; cntr++;
} }
} }
finally
{
lockPartsForRead(false);
}
for (int ctr = 0; ctr < localids.Length; ctr++) for (int ctr = 0; ctr < localids.Length; ctr++)
{ {

View File

@ -840,12 +840,12 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
m_items.LockItemsForRead(false);
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
itemID, m_part.Name, m_part.UUID); itemID, m_part.Name, m_part.UUID);
} }
m_items.LockItemsForWrite(false);
return -1; return -1;
} }

View File

@ -300,6 +300,14 @@ namespace OpenSim.Services.Connectors
{ {
pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
} }
else
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
}
}
else
{
m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
} }
return pinfo; return pinfo;