aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/Framework/Scenes/UuidGatherer.cs
parentAdd a build script. (diff)
downloadopensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs231
1 files changed, 158 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 2070ce5..80d3f62 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -65,7 +65,10 @@ namespace OpenSim.Region.Framework.Scenes
65 /// </summary> 65 /// </summary>
66 /// <value>The gathered uuids.</value> 66 /// <value>The gathered uuids.</value>
67 public IDictionary<UUID, sbyte> GatheredUuids { get; private set; } 67 public IDictionary<UUID, sbyte> GatheredUuids { get; private set; }
68 68 public HashSet<UUID> FailedUUIDs { get; private set; }
69 public HashSet<UUID> UncertainAssetsUUIDs { get; private set; }
70 public int possibleNotAssetCount { get; set; }
71 public int ErrorCount { get; private set; }
69 /// <summary> 72 /// <summary>
70 /// Gets the next UUID to inspect. 73 /// Gets the next UUID to inspect.
71 /// </summary> 74 /// </summary>
@@ -92,7 +95,10 @@ namespace OpenSim.Region.Framework.Scenes
92 /// <param name="assetService"> 95 /// <param name="assetService">
93 /// Asset service. 96 /// Asset service.
94 /// </param> 97 /// </param>
95 public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary<UUID, sbyte>()) {} 98 public UuidGatherer(IAssetService assetService) : this(assetService, new Dictionary<UUID, sbyte>(),
99 new HashSet <UUID>(),new HashSet <UUID>()) {}
100 public UuidGatherer(IAssetService assetService, IDictionary<UUID, sbyte> collector) : this(assetService, collector,
101 new HashSet <UUID>(), new HashSet <UUID>()) {}
96 102
97 /// <summary> 103 /// <summary>
98 /// Initializes a new instance of the <see cref="OpenSim.Region.Framework.Scenes.UuidGatherer"/> class. 104 /// Initializes a new instance of the <see cref="OpenSim.Region.Framework.Scenes.UuidGatherer"/> class.
@@ -101,16 +107,20 @@ namespace OpenSim.Region.Framework.Scenes
101 /// Asset service. 107 /// Asset service.
102 /// </param> 108 /// </param>
103 /// <param name="collector"> 109 /// <param name="collector">
104 /// Gathered UUIDs will be collected in this dictinaory. 110 /// Gathered UUIDs will be collected in this dictionary.
105 /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected. 111 /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected.
106 /// </param> 112 /// </param>
107 public UuidGatherer(IAssetService assetService, IDictionary<UUID, sbyte> collector) 113 public UuidGatherer(IAssetService assetService, IDictionary<UUID, sbyte> collector, HashSet <UUID> failedIDs, HashSet <UUID> uncertainAssetsUUIDs)
108 { 114 {
109 m_assetService = assetService; 115 m_assetService = assetService;
110 GatheredUuids = collector; 116 GatheredUuids = collector;
111 117
112 // FIXME: Not efficient for searching, can improve. 118 // FIXME: Not efficient for searching, can improve.
113 m_assetUuidsToInspect = new Queue<UUID>(); 119 m_assetUuidsToInspect = new Queue<UUID>();
120 FailedUUIDs = failedIDs;
121 UncertainAssetsUUIDs = uncertainAssetsUUIDs;
122 ErrorCount = 0;
123 possibleNotAssetCount = 0;
114 } 124 }
115 125
116 /// <summary> 126 /// <summary>
@@ -120,16 +130,28 @@ namespace OpenSim.Region.Framework.Scenes
120 /// <param name="uuid">UUID.</param> 130 /// <param name="uuid">UUID.</param>
121 public bool AddForInspection(UUID uuid) 131 public bool AddForInspection(UUID uuid)
122 { 132 {
133 if(uuid == UUID.Zero)
134 return false;
135
136 if(FailedUUIDs.Contains(uuid))
137 {
138 if(UncertainAssetsUUIDs.Contains(uuid))
139 possibleNotAssetCount++;
140 else
141 ErrorCount++;
142 return false;
143 }
144 if(GatheredUuids.ContainsKey(uuid))
145 return false;
123 if (m_assetUuidsToInspect.Contains(uuid)) 146 if (m_assetUuidsToInspect.Contains(uuid))
124 return false; 147 return false;
125 148
126// m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid); 149// m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid);
127 150
128 m_assetUuidsToInspect.Enqueue(uuid); 151 m_assetUuidsToInspect.Enqueue(uuid);
129
130 return true; 152 return true;
131 } 153 }
132 154
133 /// <summary> 155 /// <summary>
134 /// Gather all the asset uuids associated with a given object. 156 /// Gather all the asset uuids associated with a given object.
135 /// </summary> 157 /// </summary>
@@ -142,7 +164,9 @@ namespace OpenSim.Region.Framework.Scenes
142 public void AddForInspection(SceneObjectGroup sceneObject) 164 public void AddForInspection(SceneObjectGroup sceneObject)
143 { 165 {
144 // m_log.DebugFormat( 166 // m_log.DebugFormat(
145 // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 167 // "[UUID GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
168 if(sceneObject.IsDeleted)
169 return;
146 170
147 SceneObjectPart[] parts = sceneObject.Parts; 171 SceneObjectPart[] parts = sceneObject.Parts;
148 for (int i = 0; i < parts.Length; i++) 172 for (int i = 0; i < parts.Length; i++)
@@ -150,7 +174,7 @@ namespace OpenSim.Region.Framework.Scenes
150 SceneObjectPart part = parts[i]; 174 SceneObjectPart part = parts[i];
151 175
152 // m_log.DebugFormat( 176 // m_log.DebugFormat(
153 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); 177 // "[UUID GATHERER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
154 178
155 try 179 try
156 { 180 {
@@ -179,8 +203,10 @@ namespace OpenSim.Region.Framework.Scenes
179 if (part.Shape.ProjectionTextureUUID != UUID.Zero) 203 if (part.Shape.ProjectionTextureUUID != UUID.Zero)
180 GatheredUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture; 204 GatheredUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
181 205
182 if (part.CollisionSound != UUID.Zero) 206 UUID collisionSound = part.CollisionSound;
183 GatheredUuids[part.CollisionSound] = (sbyte)AssetType.Sound; 207 if ( collisionSound != UUID.Zero &&
208 collisionSound != part.invalidCollisionSoundUUID)
209 GatheredUuids[collisionSound] = (sbyte)AssetType.Sound;
184 210
185 if (part.ParticleSystem.Length > 0) 211 if (part.ParticleSystem.Length > 0)
186 { 212 {
@@ -193,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes
193 catch (Exception) 219 catch (Exception)
194 { 220 {
195 m_log.WarnFormat( 221 m_log.WarnFormat(
196 "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.", 222 "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.",
197 part.Name, part.UUID, sceneObject.Name, sceneObject.UUID); 223 part.Name, part.UUID, sceneObject.Name, sceneObject.UUID);
198 } 224 }
199 } 225 }
@@ -204,29 +230,24 @@ namespace OpenSim.Region.Framework.Scenes
204 foreach (TaskInventoryItem tii in taskDictionary.Values) 230 foreach (TaskInventoryItem tii in taskDictionary.Values)
205 { 231 {
206 // m_log.DebugFormat( 232 // m_log.DebugFormat(
207 // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}", 233 // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
208 // tii.Name, tii.Type, part.Name, part.UUID); 234 // tii.Name, tii.Type, part.Name, part.UUID);
209 235 AddForInspection(tii.AssetID, (sbyte)tii.Type);
210 if (!GatheredUuids.ContainsKey(tii.AssetID))
211 AddForInspection(tii.AssetID, (sbyte)tii.Type);
212 } 236 }
213 237
214 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed 238 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
215 // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and 239 // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
216 // inventory transfer. There needs to be a way for a module to register a method without assuming a 240 // inventory transfer. There needs to be a way for a module to register a method without assuming a
217 // Scene.EventManager is present. 241 // Scene.EventManager is present.
218 // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); 242 // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
219 243
220 244
221 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs 245 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
222 RecordMaterialsUuids(part); 246 RecordMaterialsUuids(part);
223 } 247 }
224 catch (Exception e) 248 catch (Exception e)
225 { 249 {
226 m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e); 250 m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
227 m_log.DebugFormat(
228 "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
229 part.Shape.TextureEntry.Length);
230 } 251 }
231 } 252 }
232 } 253 }
@@ -277,58 +298,115 @@ namespace OpenSim.Region.Framework.Scenes
277 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 298 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
278 private void GetAssetUuids(UUID assetUuid) 299 private void GetAssetUuids(UUID assetUuid)
279 { 300 {
301 if(assetUuid == UUID.Zero)
302 return;
303
304 if(FailedUUIDs.Contains(assetUuid))
305 {
306 if(UncertainAssetsUUIDs.Contains(assetUuid))
307 possibleNotAssetCount++;
308 else
309 ErrorCount++;
310 return;
311 }
312
280 // avoid infinite loops 313 // avoid infinite loops
281 if (GatheredUuids.ContainsKey(assetUuid)) 314 if (GatheredUuids.ContainsKey(assetUuid))
282 return; 315 return;
283 316
317 AssetBase assetBase;
284 try 318 try
285 { 319 {
286 AssetBase assetBase = GetAsset(assetUuid); 320 assetBase = GetAsset(assetUuid);
321 }
322 catch (Exception e)
323 {
324 m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset {0} : {1}", assetUuid, e.Message);
325 ErrorCount++;
326 FailedUUIDs.Add(assetUuid);
327 return;
328 }
287 329
288 if (null != assetBase) 330 if(assetBase == null)
289 { 331 {
290 sbyte assetType = assetBase.Type; 332// m_log.ErrorFormat("[UUID GATHERER]: asset {0} not found", assetUuid);
291 GatheredUuids[assetUuid] = assetType; 333 FailedUUIDs.Add(assetUuid);
334 if(UncertainAssetsUUIDs.Contains(assetUuid))
335 possibleNotAssetCount++;
336 else
337 ErrorCount++;
338 return;
339 }
292 340
293 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) 341 if(UncertainAssetsUUIDs.Contains(assetUuid))
294 { 342 UncertainAssetsUUIDs.Remove(assetUuid);
295 RecordWearableAssetUuids(assetBase); 343
296 } 344 sbyte assetType = assetBase.Type;
297 else if ((sbyte)AssetType.Gesture == assetType) 345
298 { 346 if(assetBase.Data == null || assetBase.Data.Length == 0)
299 RecordGestureAssetUuids(assetBase); 347 {
300 } 348// m_log.ErrorFormat("[UUID GATHERER]: asset {0}, type {1} has no data", assetUuid, assetType);
301 else if ((sbyte)AssetType.Notecard == assetType) 349 ErrorCount++;
302 { 350 FailedUUIDs.Add(assetUuid);
303 RecordTextEmbeddedAssetUuids(assetBase); 351 return;
304 } 352 }
305 else if ((sbyte)AssetType.LSLText == assetType) 353
306 { 354 GatheredUuids[assetUuid] = assetType;
307 RecordTextEmbeddedAssetUuids(assetBase); 355 try
308 } 356 {
309 else if ((sbyte)OpenSimAssetType.Material == assetType) 357 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
310 { 358 {
311 RecordMaterialAssetUuids(assetBase); 359 RecordWearableAssetUuids(assetBase);
312 } 360 }
313 else if ((sbyte)AssetType.Object == assetType) 361 else if ((sbyte)AssetType.Gesture == assetType)
314 { 362 {
315 RecordSceneObjectAssetUuids(assetBase); 363 RecordGestureAssetUuids(assetBase);
316 } 364 }
365 else if ((sbyte)AssetType.Notecard == assetType)
366 {
367 RecordTextEmbeddedAssetUuids(assetBase);
368 }
369 else if ((sbyte)AssetType.LSLText == assetType)
370 {
371 RecordTextEmbeddedAssetUuids(assetBase);
372 }
373 else if ((sbyte)OpenSimAssetType.Material == assetType)
374 {
375 RecordMaterialAssetUuids(assetBase);
376 }
377 else if ((sbyte)AssetType.Object == assetType)
378 {
379 RecordSceneObjectAssetUuids(assetBase);
317 } 380 }
318 } 381 }
319 catch (Exception) 382 catch (Exception e)
320 { 383 {
321 m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset id {0}", assetUuid); 384 m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset with id {0} type {1}: {2}", assetUuid, assetType, e.Message);
322 throw; 385 GatheredUuids.Remove(assetUuid);
386 ErrorCount++;
387 FailedUUIDs.Add(assetUuid);
323 } 388 }
324 } 389 }
325 390
326 private void AddForInspection(UUID assetUuid, sbyte assetType) 391 private void AddForInspection(UUID assetUuid, sbyte assetType)
327 { 392 {
393 if(assetUuid == UUID.Zero)
394 return;
395
328 // Here, we want to collect uuids which require further asset fetches but mark the others as gathered 396 // Here, we want to collect uuids which require further asset fetches but mark the others as gathered
397 if(FailedUUIDs.Contains(assetUuid))
398 {
399 if(UncertainAssetsUUIDs.Contains(assetUuid))
400 possibleNotAssetCount++;
401 else
402 ErrorCount++;
403 return;
404 }
405 if(GatheredUuids.ContainsKey(assetUuid))
406 return;
329 try 407 try
330 { 408 {
331 if ((sbyte)AssetType.Bodypart == assetType 409 if ((sbyte)AssetType.Bodypart == assetType
332 || (sbyte)AssetType.Clothing == assetType 410 || (sbyte)AssetType.Clothing == assetType
333 || (sbyte)AssetType.Gesture == assetType 411 || (sbyte)AssetType.Gesture == assetType
334 || (sbyte)AssetType.Notecard == assetType 412 || (sbyte)AssetType.Notecard == assetType
@@ -346,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes
346 catch (Exception) 424 catch (Exception)
347 { 425 {
348 m_log.ErrorFormat( 426 m_log.ErrorFormat(
349 "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}", 427 "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}",
350 assetUuid, assetType); 428 assetUuid, assetType);
351 throw; 429 throw;
352 } 430 }
@@ -457,8 +535,11 @@ namespace OpenSim.Region.Framework.Scenes
457 foreach (Match uuidMatch in uuidMatches) 535 foreach (Match uuidMatch in uuidMatches)
458 { 536 {
459 UUID uuid = new UUID(uuidMatch.Value); 537 UUID uuid = new UUID(uuidMatch.Value);
538 if(uuid == UUID.Zero)
539 continue;
460// m_log.DebugFormat("[UUID GATHERER]: Recording {0} in text", uuid); 540// m_log.DebugFormat("[UUID GATHERER]: Recording {0} in text", uuid);
461 541 if(!UncertainAssetsUUIDs.Contains(uuid))
542 UncertainAssetsUUIDs.Add(uuid);
462 AddForInspection(uuid); 543 AddForInspection(uuid);
463 } 544 }
464 } 545 }
@@ -490,23 +571,18 @@ namespace OpenSim.Region.Framework.Scenes
490 { 571 {
491 string xml = Utils.BytesToString(sceneObjectAsset.Data); 572 string xml = Utils.BytesToString(sceneObjectAsset.Data);
492 573
493 if (String.IsNullOrEmpty(xml)) 574 CoalescedSceneObjects coa;
494 m_log.ErrorFormat("[UUIDGatherer]: Asset {0} - {1} has a zero length XML blob!", sceneObjectAsset.Name, sceneObjectAsset.ID); 575 if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa))
576 {
577 foreach (SceneObjectGroup sog in coa.Objects)
578 AddForInspection(sog);
579 }
495 else 580 else
496 { 581 {
497 CoalescedSceneObjects coa; 582 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);
498 if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa))
499 {
500 foreach (SceneObjectGroup sog in coa.Objects)
501 AddForInspection(sog);
502 }
503 else
504 {
505 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);
506 583
507 if (null != sog) 584 if (null != sog)
508 AddForInspection(sog); 585 AddForInspection(sog);
509 }
510 } 586 }
511 } 587 }
512 588
@@ -554,7 +630,16 @@ namespace OpenSim.Region.Framework.Scenes
554 /// </summary> 630 /// </summary>
555 private void RecordMaterialAssetUuids(AssetBase materialAsset) 631 private void RecordMaterialAssetUuids(AssetBase materialAsset)
556 { 632 {
557 OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(materialAsset.Data); 633 OSDMap mat;
634 try
635 {
636 mat = (OSDMap)OSDParser.DeserializeLLSDXml(materialAsset.Data);
637 }
638 catch (Exception e)
639 {
640 m_log.WarnFormat("[Materials]: cannot decode material asset {0}: {1}", materialAsset.ID, e.Message);
641 return;
642 }
558 643
559 UUID normMap = mat["NormMap"].AsUUID(); 644 UUID normMap = mat["NormMap"].AsUUID();
560 if (normMap != UUID.Zero) 645 if (normMap != UUID.Zero)