From ea72428c9d3fa27ab43bb3e0b2e297bf3b22861e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 19 Jan 2012 23:09:16 +0000
Subject: Allow a viewer UDP image request retry to trigger another asset fetch
if an existing fetch hasn't responded before a timeout.
This is to stop a high priority image/texture request from blocking the entire download queue if its asset fetch got dropped for some reason.
---
OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 32 ++++++++++++++++++++--
.../ClientStack/Linden/UDP/LLImageManager.cs | 6 ++--
2 files changed, 32 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/ClientStack')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
index 8dd76d8..afbe56b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
@@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private const int IMAGE_PACKET_SIZE = 1000;
private const int FIRST_PACKET_SIZE = 600;
+ ///
+ /// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate
+ /// request from the client to trigger a fresh asset request.
+ ///
+ ///
+ /// There are 10,000 ticks in a millisecond
+ ///
+ private const int ASSET_REQUEST_TIMEOUT = 100000000;
+
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public uint LastSequence;
@@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public UUID AgentID;
public IInventoryAccessModule InventoryAccessModule;
private OpenJPEG.J2KLayerInfo[] m_layers;
+
+ ///
+ /// Has this request decoded the asset data?
+ ///
public bool IsDecoded { get; private set; }
+
+ ///
+ /// Has this request received the required asset data?
+ ///
public bool HasAsset { get; private set; }
+
+ ///
+ /// Time in milliseconds at which the asset was requested.
+ ///
+ public long AssetRequestTime { get; private set; }
+
public C5.IPriorityQueueHandle PriorityQueueHandle;
private uint m_currentPacket;
@@ -123,10 +146,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (!HasAsset)
{
- if (!m_assetRequested)
+ if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT)
{
+// m_log.DebugFormat(
+// "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}",
+// TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT);
+
m_assetRequested = true;
-// m_log.DebugFormat("[J2KIMAGE]: Requesting asset {0}", TextureID);
+ AssetRequestTime = DateTime.UtcNow.Ticks;
+
AssetService.Get(TextureID.ToString(), this, AssetReceived);
}
}
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
index a48251f..073c357 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
@@ -101,9 +101,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Do a linear search for this texture download
lock (m_syncRoot)
- {
m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest);
- }
if (imgrequest != null)
{
@@ -124,8 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}",
// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);
- //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
- // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
+// m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
+// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
//Check the packet sequence to make sure this isn't older than
//one we've already received
--
cgit v1.1