diff options
author | Melanie Thielker | 2017-02-01 16:31:01 +0000 |
---|---|---|
committer | Melanie Thielker | 2017-02-01 16:31:01 +0000 |
commit | a5151bb337cfee14dff6045d7f8e293201ae94ac (patch) | |
tree | f301338415da7160e48efcb4dc6cd1efc7faecaf /OpenSim/Region/CoreModules/Asset | |
parent | Secure sim stats with an (optional) password. (diff) | |
download | opensim-SC_OLD-a5151bb337cfee14dff6045d7f8e293201ae94ac.zip opensim-SC_OLD-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.gz opensim-SC_OLD-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.bz2 opensim-SC_OLD-a5151bb337cfee14dff6045d7f8e293201ae94ac.tar.xz |
Refactor asset handling as per Ubit's suggestion
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
4 files changed, 34 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 136134f..403236c 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -260,12 +260,9 @@ 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, out bool negative) | 263 | public bool Get(string id, out AssetBase assetBase) |
264 | { | 264 | { |
265 | negative = false; | ||
266 | |||
267 | m_getCount++; | 265 | m_getCount++; |
268 | AssetBase assetBase; | ||
269 | if (m_cache.TryGetValue(id, out assetBase)) | 266 | if (m_cache.TryGetValue(id, out assetBase)) |
270 | m_hitCount++; | 267 | m_hitCount++; |
271 | 268 | ||
@@ -286,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
286 | // if (null == assetBase) | 283 | // if (null == assetBase) |
287 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); | 284 | // m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id); |
288 | 285 | ||
289 | return assetBase; | 286 | return true; |
290 | } | 287 | } |
291 | 288 | ||
292 | #endregion | 289 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index d655509..10c0e85 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -115,8 +115,10 @@ 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 | bool negative; | 118 | AssetBase asset; |
119 | return Get(id, out negative) != null; | 119 | if (!Get(id, out asset)) |
120 | return false; | ||
121 | return asset != null; | ||
120 | } | 122 | } |
121 | 123 | ||
122 | public void Cache(AssetBase asset) | 124 | public void Cache(AssetBase asset) |
@@ -130,10 +132,10 @@ namespace OpenSim.Region.CoreModules.Asset | |||
130 | // We don't do negative caching | 132 | // We don't do negative caching |
131 | } | 133 | } |
132 | 134 | ||
133 | public AssetBase Get(string id, out bool negative) | 135 | public bool Get(string id, out AssetBase asset) |
134 | { | 136 | { |
135 | negative = false; | 137 | asset = (AssetBase)m_Cache.Get(id); |
136 | return (AssetBase)m_Cache.Get(id); | 138 | return true; |
137 | } | 139 | } |
138 | 140 | ||
139 | public void Expire(string id) | 141 | public void Expire(string id) |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b183a75..f8a4461 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -536,24 +536,23 @@ namespace OpenSim.Region.CoreModules.Asset | |||
536 | // For IAssetService | 536 | // For IAssetService |
537 | public AssetBase Get(string id) | 537 | public AssetBase Get(string id) |
538 | { | 538 | { |
539 | bool negative; | 539 | AssetBase asset; |
540 | return Get(id, out negative); | 540 | Get(id, out asset); |
541 | return asset; | ||
541 | } | 542 | } |
542 | 543 | ||
543 | public AssetBase Get(string id, out bool negative) | 544 | public bool Get(string id, out AssetBase asset) |
544 | { | 545 | { |
545 | negative = false; | 546 | asset = null; |
546 | 547 | ||
547 | m_Requests++; | 548 | m_Requests++; |
548 | 549 | ||
549 | object dummy; | 550 | object dummy; |
550 | if (m_negativeCache.TryGetValue(id, out dummy)) | 551 | if (m_negativeCache.TryGetValue(id, out dummy)) |
551 | { | 552 | { |
552 | negative = true; | 553 | return false; |
553 | return null; | ||
554 | } | 554 | } |
555 | 555 | ||
556 | AssetBase asset = null; | ||
557 | asset = GetFromWeakReference(id); | 556 | asset = GetFromWeakReference(id); |
558 | if (asset != null && m_updateFileTimeOnCacheHit) | 557 | if (asset != null && m_updateFileTimeOnCacheHit) |
559 | { | 558 | { |
@@ -592,7 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
592 | GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); | 591 | GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); |
593 | } | 592 | } |
594 | 593 | ||
595 | return asset; | 594 | return true; |
596 | } | 595 | } |
597 | 596 | ||
598 | public bool Check(string id) | 597 | public bool Check(string id) |
@@ -607,8 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
607 | 606 | ||
608 | public AssetBase GetCached(string id) | 607 | public AssetBase GetCached(string id) |
609 | { | 608 | { |
610 | bool negative; | 609 | AssetBase asset; |
611 | return Get(id, out negative); | 610 | Get(id, out asset); |
611 | return asset; | ||
612 | } | 612 | } |
613 | 613 | ||
614 | public void Expire(string id) | 614 | public void Expire(string id) |
@@ -1236,23 +1236,22 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1236 | 1236 | ||
1237 | public AssetMetadata GetMetadata(string id) | 1237 | public AssetMetadata GetMetadata(string id) |
1238 | { | 1238 | { |
1239 | bool negative; | 1239 | AssetBase asset; |
1240 | AssetBase asset = Get(id, out negative); | 1240 | Get(id, out asset); |
1241 | return asset.Metadata; | 1241 | return asset.Metadata; |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | public byte[] GetData(string id) | 1244 | public byte[] GetData(string id) |
1245 | { | 1245 | { |
1246 | bool negative; | 1246 | AssetBase asset; |
1247 | AssetBase asset = Get(id, out negative); | 1247 | Get(id, out asset); |
1248 | return asset.Data; | 1248 | return asset.Data; |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | public bool Get(string id, object sender, AssetRetrieved handler) | 1251 | public bool Get(string id, object sender, AssetRetrieved handler) |
1252 | { | 1252 | { |
1253 | bool negative; | 1253 | AssetBase asset; |
1254 | AssetBase asset = Get(id, out negative); | 1254 | if (!Get(id, out asset)) |
1255 | if (negative) | ||
1256 | return false; | 1255 | return false; |
1257 | handler(id, sender, asset); | 1256 | handler(id, sender, asset); |
1258 | return true; | 1257 | return true; |
@@ -1284,8 +1283,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1284 | 1283 | ||
1285 | public bool UpdateContent(string id, byte[] data) | 1284 | public bool UpdateContent(string id, byte[] data) |
1286 | { | 1285 | { |
1287 | bool negative; | 1286 | AssetBase asset; |
1288 | AssetBase asset = Get(id, out negative); | 1287 | if (!Get(id, out asset)) |
1288 | return false; | ||
1289 | asset.Data = data; | 1289 | asset.Data = data; |
1290 | Cache(asset); | 1290 | Cache(asset); |
1291 | return true; | 1291 | return true; |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 342d4d9..abe9b23 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -131,16 +131,15 @@ 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, out bool negative) | 134 | public bool Get(string id, out AssetBase asset) |
135 | { | 135 | { |
136 | negative = false; | 136 | Object a = null; |
137 | m_Cache.TryGet(id, out a); | ||
137 | 138 | ||
138 | Object asset = null; | 139 | Debug(a); |
139 | m_Cache.TryGet(id, out asset); | ||
140 | |||
141 | Debug(asset); | ||
142 | 140 | ||
143 | return (AssetBase)asset; | 141 | asset = (AssetBase)a; |
142 | return true; | ||
144 | } | 143 | } |
145 | 144 | ||
146 | public void Expire(string id) | 145 | public void Expire(string id) |