diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index baff2f4354..45c54e4989 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -27,10 +27,8 @@
using System;
using System.Collections.Generic;
-using System.Reflection;
using System.Net;
using OpenMetaverse;
-using OpenMetaverse.Packets;
namespace OpenSim.Framework
{
@@ -76,20 +74,16 @@ namespace OpenSim.Framework
{
lock (m_syncRoot)
{
- if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
- return false;
+ // allow self healing
+// if (m_dict1.ContainsKey(value.AgentId) || m_dict2.ContainsKey(value.RemoteEndPoint))
+// return false;
m_dict1[value.AgentId] = value;
m_dict2[value.RemoteEndPoint] = value;
- IClientAPI[] oldArray = m_array;
- int oldLength = oldArray.Length;
-
- IClientAPI[] newArray = new IClientAPI[oldLength + 1];
- for (int i = 0; i < oldLength; i++)
- newArray[i] = oldArray[i];
- newArray[oldLength] = value;
-
+ // dict1 is the master
+ IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
+ m_dict1.Values.CopyTo(newArray, 0);
m_array = newArray;
}
@@ -112,22 +106,12 @@ namespace OpenSim.Framework
m_dict1.Remove(key);
m_dict2.Remove(value.RemoteEndPoint);
- IClientAPI[] oldArray = m_array;
- int oldLength = oldArray.Length;
-
- IClientAPI[] newArray = new IClientAPI[oldLength - 1];
- int j = 0;
- for (int i = 0; i < oldLength; i++)
- {
- if (oldArray[i] != value)
- newArray[j++] = oldArray[i];
- }
-
+ IClientAPI[] newArray = new IClientAPI[m_dict1.Count];
+ m_dict1.Values.CopyTo(newArray, 0);
m_array = newArray;
return true;
}
}
-
return false;
}
@@ -196,26 +180,12 @@ namespace OpenSim.Framework
}
}
- ///
- /// Performs a given task in parallel for each of the elements in the
- /// collection
- ///
- /// Action to perform on each element
- public void ForEach(Action action)
- {
- IClientAPI[] localArray = m_array;
- Parallel.For(0, localArray.Length,
- delegate(int i)
- { action(localArray[i]); }
- );
- }
-
///
/// Performs a given task synchronously for each of the elements in
/// the collection
///
/// Action to perform on each element
- public void ForEachSync(Action action)
+ public void ForEach(Action action)
{
IClientAPI[] localArray = m_array;
for (int i = 0; i < localArray.Length; i++)