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 | |
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')
8 files changed, 50 insertions, 72 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 594b6bb..6e4a710 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -369,8 +369,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
369 | else if (Cache != null) | 369 | else if (Cache != null) |
370 | { | 370 | { |
371 | string assetName = "j2kCache_" + AssetId.ToString(); | 371 | string assetName = "j2kCache_" + AssetId.ToString(); |
372 | bool negative; | 372 | AssetBase layerDecodeAsset; |
373 | AssetBase layerDecodeAsset = Cache.Get(assetName, out negative); | 373 | Cache.Get(assetName, out layerDecodeAsset); |
374 | 374 | ||
375 | if (layerDecodeAsset != null) | 375 | if (layerDecodeAsset != null) |
376 | { | 376 | { |
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) |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 3e47782..535d946 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -299,8 +299,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
299 | if (bakedTextureFace == null) | 299 | if (bakedTextureFace == null) |
300 | continue; | 300 | continue; |
301 | 301 | ||
302 | bool negative; | 302 | AssetBase asset; |
303 | AssetBase asset = cache.Get(bakedTextureFace.TextureID.ToString(), out negative); | 303 | cache.Get(bakedTextureFace.TextureID.ToString(), out asset); |
304 | 304 | ||
305 | if (asset != null && asset.Local) | 305 | if (asset != null && asset.Local) |
306 | { | 306 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index ce61ff0..bf9327c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | |||
@@ -209,10 +209,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
209 | 209 | ||
210 | if (m_Cache != null) | 210 | if (m_Cache != null) |
211 | { | 211 | { |
212 | bool negative; | 212 | if (!m_Cache.Get(id, out asset)) |
213 | asset = m_Cache.Get(id, out negative); | ||
214 | |||
215 | if (negative) | ||
216 | return null; | 213 | return null; |
217 | 214 | ||
218 | if (asset != null) | 215 | if (asset != null) |
@@ -242,9 +239,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
242 | 239 | ||
243 | public AssetBase GetCached(string id) | 240 | public AssetBase GetCached(string id) |
244 | { | 241 | { |
245 | bool negative; | 242 | AssetBase asset = null; |
246 | if (m_Cache != null) | 243 | if (m_Cache != null) |
247 | return m_Cache.Get(id, out negative); | 244 | m_Cache.Get(id, out asset); |
248 | 245 | ||
249 | return null; | 246 | return null; |
250 | } | 247 | } |
@@ -255,10 +252,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
255 | 252 | ||
256 | if (m_Cache != null) | 253 | if (m_Cache != null) |
257 | { | 254 | { |
258 | bool negative; | 255 | if (!m_Cache.Get(id, out asset)) |
259 | asset = m_Cache.Get(id, out negative); | ||
260 | |||
261 | if (negative) | ||
262 | return null; | 256 | return null; |
263 | 257 | ||
264 | if (asset != null) | 258 | if (asset != null) |
@@ -281,10 +275,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
281 | 275 | ||
282 | if (m_Cache != null) | 276 | if (m_Cache != null) |
283 | { | 277 | { |
284 | bool negative; | 278 | if (!m_Cache.Get(id, out asset)) |
285 | asset = m_Cache.Get(id, out negative); | ||
286 | |||
287 | if (negative) | ||
288 | return null; | 279 | return null; |
289 | 280 | ||
290 | if (asset != null) | 281 | if (asset != null) |
@@ -304,10 +295,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
304 | 295 | ||
305 | if (m_Cache != null) | 296 | if (m_Cache != null) |
306 | { | 297 | { |
307 | bool negative; | 298 | if (!m_Cache.Get(id, out asset)) |
308 | asset = m_Cache.Get(id, out negative); | ||
309 | |||
310 | if (negative) | ||
311 | return false; | 299 | return false; |
312 | } | 300 | } |
313 | 301 | ||
@@ -398,9 +386,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
398 | { | 386 | { |
399 | AssetBase asset = null; | 387 | AssetBase asset = null; |
400 | 388 | ||
401 | bool negative; | ||
402 | if (m_Cache != null) | 389 | if (m_Cache != null) |
403 | asset = m_Cache.Get(id, out negative); | 390 | m_Cache.Get(id, out asset); |
404 | 391 | ||
405 | if (asset != null) | 392 | if (asset != null) |
406 | { | 393 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index bbaed21..2fe9733 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -159,10 +159,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
159 | AssetBase asset = null; | 159 | AssetBase asset = null; |
160 | if (m_Cache != null) | 160 | if (m_Cache != null) |
161 | { | 161 | { |
162 | bool negative; | 162 | if (!m_Cache.Get(id, out asset)) |
163 | asset = m_Cache.Get(id, out negative); | ||
164 | |||
165 | if (negative) | ||
166 | return null; | 163 | return null; |
167 | } | 164 | } |
168 | 165 | ||
@@ -183,13 +180,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
183 | { | 180 | { |
184 | // m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id); | 181 | // m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id); |
185 | 182 | ||
183 | AssetBase asset = null; | ||
186 | if (m_Cache != null) | 184 | if (m_Cache != null) |
187 | { | 185 | m_Cache.Get(id, out asset); |
188 | bool negative; | ||
189 | return m_Cache.Get(id, out negative); | ||
190 | } | ||
191 | 186 | ||
192 | return null; | 187 | return asset; |
193 | } | 188 | } |
194 | 189 | ||
195 | public AssetMetadata GetMetadata(string id) | 190 | public AssetMetadata GetMetadata(string id) |
@@ -197,9 +192,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
197 | AssetBase asset = null; | 192 | AssetBase asset = null; |
198 | if (m_Cache != null) | 193 | if (m_Cache != null) |
199 | { | 194 | { |
200 | bool negative; | 195 | if (!m_Cache.Get(id, out asset)) |
201 | asset = m_Cache.Get(id, out negative); | ||
202 | if (negative) | ||
203 | return null; | 196 | return null; |
204 | } | 197 | } |
205 | 198 | ||