From 9fee431cc8a054dd4d6b20392cbefd0a0f8343f1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 30 Mar 2013 01:21:16 +0000
Subject: In the flotasm asset cache, if we get a request for a file that we're
actively writing, simply return null instead of first logging an exception.
---
.../Region/CoreModules/Asset/FlotsamAssetCache.cs | 52 +++++++++++-----------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 3cba9b4..2afe065 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;
}
--
cgit v1.1