Put in locks on m_killRecord to replace changed locks on m_entityUpdates.SyncRoot

These locks are necessary to avoid a delete/update race condition for scene objects.
However, since we're now locking on m_killRecord this shouldn't cause delays to m_entityUpdates reprioritization
viewer-2-initial-appearance
Justin Clark-Casey (justincc) 2010-12-15 23:11:42 +00:00
parent ed26376ec5
commit 0745d65344
1 changed files with 203 additions and 196 deletions

View File

@ -327,7 +327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
/// ownerless phantom.
///
/// All manipulation of this set has to occur under an m_entityUpdates.SyncRoot lock
/// All manipulation of this set has to occur under a lock
///
/// </value>
protected HashSet<uint> m_killRecord;
@ -1521,7 +1521,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_scene.GetScenePresence(localID) == null)
{
lock (m_entityUpdates.SyncRoot)
// We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
// condition where a kill can be processed before an out-of-date update for the same object.
lock (m_killRecord)
{
m_killRecord.Add(localID);
@ -3558,6 +3560,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (maxUpdates <= 0) maxUpdates = Int32.MaxValue;
int updatesThisCall = 0;
// We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
// condition where a kill can be processed before an out-of-date update for the same object.
lock (m_killRecord)
{
EntityUpdate update;
while (updatesThisCall < maxUpdates)
{
@ -3661,36 +3667,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
else
{
// if (update.Entity is SceneObjectPart && ((SceneObjectPart)update.Entity).IsAttachment)
// {
// SceneObjectPart sop = (SceneObjectPart)update.Entity;
// string text = sop.Text;
// if (text.IndexOf("\n") >= 0)
// text = text.Remove(text.IndexOf("\n"));
//
// if (m_attachmentsSent.Contains(sop.ParentID))
// {
//// m_log.DebugFormat(
//// "[CLIENT]: Sending full info about attached prim {0} text {1}",
//// sop.LocalId, text);
//
// objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock(sop, this.m_agentId));
//
// m_attachmentsSent.Add(sop.LocalId);
// }
// else
// {
// m_log.DebugFormat(
// "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet",
// sop.LocalId, text, sop.ParentID);
//
// m_entityUpdates.Enqueue(double.MaxValue, update, sop.LocalId);
// }
// }
// else
// {
// if (update.Entity is SceneObjectPart && ((SceneObjectPart)update.Entity).IsAttachment)
// {
// SceneObjectPart sop = (SceneObjectPart)update.Entity;
// string text = sop.Text;
// if (text.IndexOf("\n") >= 0)
// text = text.Remove(text.IndexOf("\n"));
//
// if (m_attachmentsSent.Contains(sop.ParentID))
// {
//// m_log.DebugFormat(
//// "[CLIENT]: Sending full info about attached prim {0} text {1}",
//// sop.LocalId, text);
//
// objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock(sop, this.m_agentId));
//
// m_attachmentsSent.Add(sop.LocalId);
// }
// else
// {
// m_log.DebugFormat(
// "[CLIENT]: Requeueing full update of prim {0} text {1} since we haven't sent its parent {2} yet",
// sop.LocalId, text, sop.ParentID);
//
// m_entityUpdates.Enqueue(double.MaxValue, update, sop.LocalId);
// }
// }
// else
// {
objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
// }
// }
}
}
else if (!canUseImproved)
@ -3774,6 +3780,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(packet, ThrottleOutPacketType.Task, true);
}
}
#endregion Packet Sending
}