aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Asset
diff options
context:
space:
mode:
authorMelanie Thielker2017-01-30 13:59:05 +0000
committerMelanie Thielker2017-01-30 13:59:05 +0000
commit5a18ea31cf9d9a97fc1a65f8623b633c244221c2 (patch)
tree80eae98cddde4ffbdb7287ad0ac82449c33cb316 /OpenSim/Region/CoreModules/Asset
parentComment two very spammy debug messages that the usr can't do anything about (diff)
downloadopensim-SC_OLD-5a18ea31cf9d9a97fc1a65f8623b633c244221c2.zip
opensim-SC_OLD-5a18ea31cf9d9a97fc1a65f8623b633c244221c2.tar.gz
opensim-SC_OLD-5a18ea31cf9d9a97fc1a65f8623b633c244221c2.tar.bz2
opensim-SC_OLD-5a18ea31cf9d9a97fc1a65f8623b633c244221c2.tar.xz
Make negative asset caching actually work
Also fixes some merge artefacts in HGAssetBroker where cached assets were requested but not actually used and completely squelch a materials debug message because there is nothing the user can do to fix it anyway.
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs6
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs37
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs4
4 files changed, 36 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 23c1f03..136134f 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -260,8 +260,10 @@ namespace OpenSim.Region.CoreModules.Asset
260 /// Cache doesn't guarantee in any situation that asset is stored to it. 260 /// Cache doesn't guarantee in any situation that asset is stored to it.
261 /// </para> 261 /// </para>
262 /// </remarks> 262 /// </remarks>
263 public AssetBase Get(string id) 263 public AssetBase Get(string id, out bool negative)
264 { 264 {
265 negative = false;
266
265 m_getCount++; 267 m_getCount++;
266 AssetBase assetBase; 268 AssetBase assetBase;
267 if (m_cache.TryGetValue(id, out assetBase)) 269 if (m_cache.TryGetValue(id, out assetBase))
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 51fc3d1..d655509 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -115,7 +115,8 @@ namespace OpenSim.Region.CoreModules.Asset
115 public bool Check(string id) 115 public bool Check(string id)
116 { 116 {
117 // XXX This is probably not an efficient implementation. 117 // XXX This is probably not an efficient implementation.
118 return Get(id) != null; 118 bool negative;
119 return Get(id, out negative) != null;
119 } 120 }
120 121
121 public void Cache(AssetBase asset) 122 public void Cache(AssetBase asset)
@@ -129,8 +130,9 @@ namespace OpenSim.Region.CoreModules.Asset
129 // We don't do negative caching 130 // We don't do negative caching
130 } 131 }
131 132
132 public AssetBase Get(string id) 133 public AssetBase Get(string id, out bool negative)
133 { 134 {
135 negative = false;
134 return (AssetBase)m_Cache.Get(id); 136 return (AssetBase)m_Cache.Get(id);
135 } 137 }
136 138
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 187f090..b183a75 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -474,6 +474,8 @@ namespace OpenSim.Region.CoreModules.Asset
474 { 474 {
475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) 475 using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
476 { 476 {
477 if (stream.Length == 0) // Empty file will trigger exception below
478 return null;
477 BinaryFormatter bformatter = new BinaryFormatter(); 479 BinaryFormatter bformatter = new BinaryFormatter();
478 480
479 asset = (AssetBase)bformatter.Deserialize(stream); 481 asset = (AssetBase)bformatter.Deserialize(stream);
@@ -531,13 +533,25 @@ namespace OpenSim.Region.CoreModules.Asset
531 return found; 533 return found;
532 } 534 }
533 535
536 // For IAssetService
534 public AssetBase Get(string id) 537 public AssetBase Get(string id)
535 { 538 {
539 bool negative;
540 return Get(id, out negative);
541 }
542
543 public AssetBase Get(string id, out bool negative)
544 {
545 negative = false;
546
536 m_Requests++; 547 m_Requests++;
537 548
538 object dummy; 549 object dummy;
539 if (m_negativeCache.TryGetValue(id, out dummy)) 550 if (m_negativeCache.TryGetValue(id, out dummy))
551 {
552 negative = true;
540 return null; 553 return null;
554 }
541 555
542 AssetBase asset = null; 556 AssetBase asset = null;
543 asset = GetFromWeakReference(id); 557 asset = GetFromWeakReference(id);
@@ -578,12 +592,6 @@ namespace OpenSim.Region.CoreModules.Asset
578 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); 592 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
579 } 593 }
580 594
581 if(asset == null)
582 {
583
584
585 }
586
587 return asset; 595 return asset;
588 } 596 }
589 597
@@ -599,7 +607,8 @@ namespace OpenSim.Region.CoreModules.Asset
599 607
600 public AssetBase GetCached(string id) 608 public AssetBase GetCached(string id)
601 { 609 {
602 return Get(id); 610 bool negative;
611 return Get(id, out negative);
603 } 612 }
604 613
605 public void Expire(string id) 614 public void Expire(string id)
@@ -1227,19 +1236,24 @@ namespace OpenSim.Region.CoreModules.Asset
1227 1236
1228 public AssetMetadata GetMetadata(string id) 1237 public AssetMetadata GetMetadata(string id)
1229 { 1238 {
1230 AssetBase asset = Get(id); 1239 bool negative;
1240 AssetBase asset = Get(id, out negative);
1231 return asset.Metadata; 1241 return asset.Metadata;
1232 } 1242 }
1233 1243
1234 public byte[] GetData(string id) 1244 public byte[] GetData(string id)
1235 { 1245 {
1236 AssetBase asset = Get(id); 1246 bool negative;
1247 AssetBase asset = Get(id, out negative);
1237 return asset.Data; 1248 return asset.Data;
1238 } 1249 }
1239 1250
1240 public bool Get(string id, object sender, AssetRetrieved handler) 1251 public bool Get(string id, object sender, AssetRetrieved handler)
1241 { 1252 {
1242 AssetBase asset = Get(id); 1253 bool negative;
1254 AssetBase asset = Get(id, out negative);
1255 if (negative)
1256 return false;
1243 handler(id, sender, asset); 1257 handler(id, sender, asset);
1244 return true; 1258 return true;
1245 } 1259 }
@@ -1270,7 +1284,8 @@ namespace OpenSim.Region.CoreModules.Asset
1270 1284
1271 public bool UpdateContent(string id, byte[] data) 1285 public bool UpdateContent(string id, byte[] data)
1272 { 1286 {
1273 AssetBase asset = Get(id); 1287 bool negative;
1288 AssetBase asset = Get(id, out negative);
1274 asset.Data = data; 1289 asset.Data = data;
1275 Cache(asset); 1290 Cache(asset);
1276 return true; 1291 return true;
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 208963d..342d4d9 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -131,8 +131,10 @@ namespace OpenSim.Region.CoreModules.Asset
131 // We don't do negative caching 131 // We don't do negative caching
132 } 132 }
133 133
134 public AssetBase Get(string id) 134 public AssetBase Get(string id, out bool negative)
135 { 135 {
136 negative = false;
137
136 Object asset = null; 138 Object asset = null;
137 m_Cache.TryGet(id, out asset); 139 m_Cache.TryGet(id, out asset);
138 140