diff options
author | Melanie Thielker | 2017-01-30 13:59:05 +0000 |
---|---|---|
committer | Melanie Thielker | 2017-01-30 13:59:05 +0000 |
commit | 5a18ea31cf9d9a97fc1a65f8623b633c244221c2 (patch) | |
tree | 80eae98cddde4ffbdb7287ad0ac82449c33cb316 /OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |
parent | Comment two very spammy debug messages that the usr can't do anything about (diff) | |
download | opensim-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/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 37 |
1 files changed, 26 insertions, 11 deletions
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; |