diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 3cba9b4afd..2afe0658a7 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -341,11 +341,35 @@ namespace OpenSim.Region.CoreModules.Asset
///
/// An asset retrieved from the file cache. null if there was a problem retrieving an asset.
private AssetBase GetFromFileCache(string id)
- {
- AssetBase asset = null;
-
+ {
string filename = GetFileName(id);
+#if WAIT_ON_INPROGRESS_REQUESTS
+ // Check if we're already downloading this asset. If so, try to wait for it to
+ // download.
+ if (m_WaitOnInprogressTimeout > 0)
+ {
+ m_RequestsForInprogress++;
+
+ ManualResetEvent waitEvent;
+ if (m_CurrentlyWriting.TryGetValue(filename, out waitEvent))
+ {
+ waitEvent.WaitOne(m_WaitOnInprogressTimeout);
+ return Get(id);
+ }
+ }
+#else
+ // Track how often we have the problem that an asset is requested while
+ // it is still being downloaded by a previous request.
+ if (m_CurrentlyWriting.Contains(filename))
+ {
+ m_RequestsForInprogress++;
+ return null;
+ }
+#endif
+
+ AssetBase asset = null;
+
if (File.Exists(filename))
{
FileStream stream = null;
@@ -383,28 +407,6 @@ namespace OpenSim.Region.CoreModules.Asset
}
}
-#if WAIT_ON_INPROGRESS_REQUESTS
- // Check if we're already downloading this asset. If so, try to wait for it to
- // download.
- if (m_WaitOnInprogressTimeout > 0)
- {
- m_RequestsForInprogress++;
-
- ManualResetEvent waitEvent;
- if (m_CurrentlyWriting.TryGetValue(filename, out waitEvent))
- {
- waitEvent.WaitOne(m_WaitOnInprogressTimeout);
- return Get(id);
- }
- }
-#else
- // Track how often we have the problem that an asset is requested while
- // it is still being downloaded by a previous request.
- if (m_CurrentlyWriting.Contains(filename))
- {
- m_RequestsForInprogress++;
- }
-#endif
return asset;
}