aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs70
1 files changed, 43 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index c673e18..129d6d3 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -70,20 +70,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
70 private int m_repliesRequired; 70 private int m_repliesRequired;
71 71
72 /// <value> 72 /// <value>
73 /// Asset cache used to request the assets 73 /// Asset service used to request the assets
74 /// </value> 74 /// </value>
75 protected IAssetService m_assetCache; 75 protected IAssetService m_assetService;
76 76
77 protected AssetsArchiver m_assetsArchiver; 77 protected AssetsArchiver m_assetsArchiver;
78 78
79 protected internal AssetsRequest( 79 protected internal AssetsRequest(
80 AssetsArchiver assetsArchiver, ICollection<UUID> uuids, 80 AssetsArchiver assetsArchiver, ICollection<UUID> uuids,
81 IAssetService assetCache, AssetsRequestCallback assetsRequestCallback) 81 IAssetService assetService, AssetsRequestCallback assetsRequestCallback)
82 { 82 {
83 m_assetsArchiver = assetsArchiver; 83 m_assetsArchiver = assetsArchiver;
84 m_uuids = uuids; 84 m_uuids = uuids;
85 m_assetsRequestCallback = assetsRequestCallback; 85 m_assetsRequestCallback = assetsRequestCallback;
86 m_assetCache = assetCache; 86 m_assetService = assetService;
87 m_repliesRequired = uuids.Count; 87 m_repliesRequired = uuids.Count;
88 } 88 }
89 89
@@ -93,14 +93,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
93 93
94 // We can stop here if there are no assets to fetch 94 // We can stop here if there are no assets to fetch
95 if (m_repliesRequired == 0) 95 if (m_repliesRequired == 0)
96 m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids); 96 PerformAssetsRequestCallback();
97 97
98 foreach (UUID uuid in m_uuids) 98 foreach (UUID uuid in m_uuids)
99 { 99 {
100 m_assetCache.Get(uuid.ToString(), this, AssetRequestCallback); 100 m_assetService.Get(uuid.ToString(), this, AssetRequestCallback);
101 } 101 }
102 } 102 }
103 103
104 private bool done = false;
104 /// <summary> 105 /// <summary>
105 /// Called back by the asset cache when it has the asset 106 /// Called back by the asset cache when it has the asset
106 /// </summary> 107 /// </summary>
@@ -108,29 +109,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver
108 /// <param name="asset"></param> 109 /// <param name="asset"></param>
109 public void AssetRequestCallback(string id, object sender, AssetBase asset) 110 public void AssetRequestCallback(string id, object sender, AssetBase asset)
110 { 111 {
111 //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", assetID); 112 try
112
113 if (asset != null)
114 {
115 m_foundAssetUuids.Add(asset.FullID);
116 m_assetsArchiver.WriteAsset(asset);
117 }
118 else
119 { 113 {
120 m_notFoundAssetUuids.Add(new UUID(id)); 114 lock (this)
115 {
116 //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id);
117
118 if (asset != null)
119 {
120 m_foundAssetUuids.Add(asset.FullID);
121 m_assetsArchiver.WriteAsset(asset);
122 }
123 else
124 {
125 m_notFoundAssetUuids.Add(new UUID(id));
126 }
127
128 if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
129 {
130 if (done)
131 throw new Exception("AArgh");
132
133 m_log.DebugFormat(
134 "[ARCHIVER]: Successfully added {0} assets ({1} assets missing)",
135 m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);
136
137 done = true;
138
139 // We want to stop using the asset cache thread asap
140 // as we now need to do the work of producing the rest of the archive
141 Thread newThread = new Thread(PerformAssetsRequestCallback);
142 newThread.Name = "OpenSimulator archiving thread post assets receipt";
143 newThread.Start();
144 }
145 }
121 } 146 }
122 147 catch (Exception e)
123 if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
124 { 148 {
125 m_log.DebugFormat( 149 m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e);
126 "[ARCHIVER]: Successfully added {0} assets ({1} assets missing)",
127 m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);
128
129 // We want to stop using the asset cache thread asap
130 // as we now need to do the work of producing the rest of the archive
131 Thread newThread = new Thread(PerformAssetsRequestCallback);
132 newThread.Name = "OpenSimulator archiving thread post assets receipt";
133 newThread.Start();
134 } 150 }
135 } 151 }
136 152