aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs48
1 files changed, 45 insertions, 3 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index d1ff9c9..4765548 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -156,16 +156,58 @@ namespace OpenSim.Framework.Communications.Cache
156 } 156 }
157 } 157 }
158 158
159 /// <summary>
160 /// Get an asset. If the asset isn't in the cache, a request will be made to the persistent store to
161 /// load it into the cache.
162 ///
163 /// XXX We'll keep polling the cache until we get the asset or we exceed
164 /// the allowed number of polls. This isn't a very good way of doing things since a single thread
165 /// is processing inbound packets, so if the asset server is slow, we could block this for up to
166 /// the timeout period. What we might want to do is register asynchronous callbacks on asset
167 /// receipt in the same manner as the nascent (but not yet active) TextureDownloadModule. Of course,
168 /// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the
169 /// asset is much more likely to have made it into the cache.
170 /// </summary>
171 /// <param name="assetID"></param>
172 /// <param name="isTexture"></param>
173 /// <returns>null if the asset could not be retrieved</returns>
159 public AssetBase GetAsset(LLUUID assetID, bool isTexture) 174 public AssetBase GetAsset(LLUUID assetID, bool isTexture)
160 { 175 {
176 // I'm not going over 3 seconds since this will be blocking processing of all the other inbound
177 // packets from the client.
178 int pollPeriod = 200;
179 int maxPolls = 15;
180
161 AssetBase asset = GetCachedAsset(assetID); 181 AssetBase asset = GetCachedAsset(assetID);
162 if (asset == null) 182 if (asset != null)
163 { 183 {
164 m_assetServer.RequestAsset(assetID, isTexture); 184 return asset;
165 } 185 }
166 return asset; 186
187 m_assetServer.RequestAsset(assetID, isTexture);
188
189 do
190 {
191 Thread.Sleep(pollPeriod);
192
193 asset = GetCachedAsset(assetID);
194 if (asset != null)
195 {
196 return asset;
197 }
198 }
199 while (--maxPolls > 0);
200
201 MainLog.Instance.Warn(
202 "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached");
203
204 return null;
167 } 205 }
168 206
207 /// <summary>
208 /// Add an asset to both the persistent store and the cache.
209 /// </summary>
210 /// <param name="asset"></param>
169 public void AddAsset(AssetBase asset) 211 public void AddAsset(AssetBase asset)
170 { 212 {
171 string temporary = asset.Temporary ? "temporary" : ""; 213 string temporary = asset.Temporary ? "temporary" : "";