aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Asset
diff options
context:
space:
mode:
authorUbitUmarov2017-04-25 17:59:53 +0100
committerUbitUmarov2017-04-25 17:59:53 +0100
commita680d8b8d700f78beb1a9eea98b52d59118efe2e (patch)
treedd084e74fb61400c704a14dcfa8689670acb9ec2 /OpenSim/Region/CoreModules/Asset
parentMerge branch 'master' into httptests (diff)
parentmove mesh pbs creation code out of mesh upload code into to PrimitiveBaseShap... (diff)
downloadopensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.zip
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.gz
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.bz2
opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.xz
fix merge
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs10
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs46
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs11
4 files changed, 47 insertions, 25 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 23c1f03..403236c 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -260,10 +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) 263 public bool Get(string id, out AssetBase assetBase)
264 { 264 {
265 m_getCount++; 265 m_getCount++;
266 AssetBase assetBase;
267 if (m_cache.TryGetValue(id, out assetBase)) 266 if (m_cache.TryGetValue(id, out assetBase))
268 m_hitCount++; 267 m_hitCount++;
269 268
@@ -284,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Asset
284// if (null == assetBase) 283// if (null == assetBase)
285// 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);
286 285
287 return assetBase; 286 return true;
288 } 287 }
289 288
290 #endregion 289 #endregion
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 51fc3d1..10c0e85 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -115,7 +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 return Get(id) != null; 118 AssetBase asset;
119 if (!Get(id, out asset))
120 return false;
121 return asset != null;
119 } 122 }
120 123
121 public void Cache(AssetBase asset) 124 public void Cache(AssetBase asset)
@@ -129,9 +132,10 @@ namespace OpenSim.Region.CoreModules.Asset
129 // We don't do negative caching 132 // We don't do negative caching
130 } 133 }
131 134
132 public AssetBase Get(string id) 135 public bool Get(string id, out AssetBase asset)
133 { 136 {
134 return (AssetBase)m_Cache.Get(id); 137 asset = (AssetBase)m_Cache.Get(id);
138 return true;
135 } 139 }
136 140
137 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 187f090..610e279 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,15 +533,26 @@ 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 AssetBase asset;
540 Get(id, out asset);
541 return asset;
542 }
543
544 public bool Get(string id, out AssetBase asset)
545 {
546 asset = null;
547
536 m_Requests++; 548 m_Requests++;
537 549
538 object dummy; 550 object dummy;
539 if (m_negativeCache.TryGetValue(id, out dummy)) 551 if (m_negativeCache.TryGetValue(id, out dummy))
540 return null; 552 {
553 return false;
554 }
541 555
542 AssetBase asset = null;
543 asset = GetFromWeakReference(id); 556 asset = GetFromWeakReference(id);
544 if (asset != null && m_updateFileTimeOnCacheHit) 557 if (asset != null && m_updateFileTimeOnCacheHit)
545 { 558 {
@@ -578,13 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset
578 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l)); 591 GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
579 } 592 }
580 593
581 if(asset == null) 594 return true;
582 {
583
584
585 }
586
587 return asset;
588 } 595 }
589 596
590 public bool Check(string id) 597 public bool Check(string id)
@@ -599,7 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset
599 606
600 public AssetBase GetCached(string id) 607 public AssetBase GetCached(string id)
601 { 608 {
602 return Get(id); 609 AssetBase asset;
610 Get(id, out asset);
611 return asset;
603 } 612 }
604 613
605 public void Expire(string id) 614 public void Expire(string id)
@@ -797,6 +806,9 @@ namespace OpenSim.Region.CoreModules.Asset
797 806
798 return; 807 return;
799 } 808 }
809 catch (UnauthorizedAccessException e)
810 {
811 }
800 finally 812 finally
801 { 813 {
802 if (stream != null) 814 if (stream != null)
@@ -1227,19 +1239,23 @@ namespace OpenSim.Region.CoreModules.Asset
1227 1239
1228 public AssetMetadata GetMetadata(string id) 1240 public AssetMetadata GetMetadata(string id)
1229 { 1241 {
1230 AssetBase asset = Get(id); 1242 AssetBase asset;
1243 Get(id, out asset);
1231 return asset.Metadata; 1244 return asset.Metadata;
1232 } 1245 }
1233 1246
1234 public byte[] GetData(string id) 1247 public byte[] GetData(string id)
1235 { 1248 {
1236 AssetBase asset = Get(id); 1249 AssetBase asset;
1250 Get(id, out asset);
1237 return asset.Data; 1251 return asset.Data;
1238 } 1252 }
1239 1253
1240 public bool Get(string id, object sender, AssetRetrieved handler) 1254 public bool Get(string id, object sender, AssetRetrieved handler)
1241 { 1255 {
1242 AssetBase asset = Get(id); 1256 AssetBase asset;
1257 if (!Get(id, out asset))
1258 return false;
1243 handler(id, sender, asset); 1259 handler(id, sender, asset);
1244 return true; 1260 return true;
1245 } 1261 }
@@ -1270,7 +1286,9 @@ namespace OpenSim.Region.CoreModules.Asset
1270 1286
1271 public bool UpdateContent(string id, byte[] data) 1287 public bool UpdateContent(string id, byte[] data)
1272 { 1288 {
1273 AssetBase asset = Get(id); 1289 AssetBase asset;
1290 if (!Get(id, out asset))
1291 return false;
1274 asset.Data = data; 1292 asset.Data = data;
1275 Cache(asset); 1293 Cache(asset);
1276 return true; 1294 return true;
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 208963d..abe9b23 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -131,14 +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) 134 public bool Get(string id, out AssetBase asset)
135 { 135 {
136 Object asset = null; 136 Object a = null;
137 m_Cache.TryGet(id, out asset); 137 m_Cache.TryGet(id, out a);
138 138
139 Debug(asset); 139 Debug(a);
140 140
141 return (AssetBase)asset; 141 asset = (AssetBase)a;
142 return true;
142 } 143 }
143 144
144 public void Expire(string id) 145 public void Expire(string id)