Locking the priority queue to see if it gets pass that exception.

prioritization
Diva Canto 2009-10-01 20:32:22 -07:00
parent 54ff84050f
commit 746dad7b74
1 changed files with 28 additions and 7 deletions

View File

@ -77,6 +77,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
J2KImage imgrequest;
// Do a linear search for this texture download
lock (m_priorityQueue)
m_priorityQueue.Find(delegate(J2KImage img) { return img.m_requestedUUID == newRequest.RequestedAssetID; }, out imgrequest);
if (imgrequest != null)
@ -85,7 +86,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
//m_log.Debug("[TEX]: (CAN) ID=" + newRequest.RequestedAssetID);
try { m_priorityQueue.Delete(imgrequest.m_priorityQueueHandle); }
try
{
lock (m_priorityQueue)
m_priorityQueue.Delete(imgrequest.m_priorityQueueHandle);
}
catch (Exception) { }
}
else
@ -108,8 +113,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//Update the requested priority
imgrequest.m_requestedPriority = newRequest.Priority;
try { m_priorityQueue.Replace(imgrequest.m_priorityQueueHandle, imgrequest); }
catch (Exception) { imgrequest.m_priorityQueueHandle = null; m_priorityQueue.Add(ref imgrequest.m_priorityQueueHandle, imgrequest); }
try
{
lock (m_priorityQueue)
m_priorityQueue.Replace(imgrequest.m_priorityQueueHandle, imgrequest);
}
catch (Exception)
{
imgrequest.m_priorityQueueHandle = null;
lock (m_priorityQueue)
m_priorityQueue.Add(ref imgrequest.m_priorityQueueHandle, imgrequest);
}
//Run an update
imgrequest.RunUpdate();
@ -152,6 +166,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
imgrequest.m_requestedPriority = newRequest.Priority;
//Add this download to the priority queue
lock (m_priorityQueue)
m_priorityQueue.Add(ref imgrequest.m_priorityQueueHandle, imgrequest);
//Run an update
@ -212,7 +227,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
while (m_priorityQueue.Count > 0)
{
J2KImage imagereq = m_priorityQueue.FindMax();
J2KImage imagereq = null;
lock (m_priorityQueue)
imagereq = m_priorityQueue.FindMax();
if (imagereq.m_decoded == true)
{
@ -230,7 +247,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (imagereq.SendPackets(m_client, maxpack))
{
// Send complete. Destroy any knowledge of this transfer
try { m_priorityQueue.Delete(imagereq.m_priorityQueueHandle); }
try
{
lock (m_priorityQueue)
m_priorityQueue.Delete(imagereq.m_priorityQueueHandle);
}
catch (Exception) { }
}
}