diff options
author | Charles Krinke | 2008-05-27 13:40:00 +0000 |
---|---|---|
committer | Charles Krinke | 2008-05-27 13:40:00 +0000 |
commit | 2cea74181ac01574c36dae97d8140f003d69e68c (patch) | |
tree | 714bb575921bf4a7c4f04198613ef277cd535066 /OpenSim/Framework/Communications | |
parent | fixes a CTB when IRCBridgeModule is not configured. (diff) | |
download | opensim-SC-2cea74181ac01574c36dae97d8140f003d69e68c.zip opensim-SC-2cea74181ac01574c36dae97d8140f003d69e68c.tar.gz opensim-SC-2cea74181ac01574c36dae97d8140f003d69e68c.tar.bz2 opensim-SC-2cea74181ac01574c36dae97d8140f003d69e68c.tar.xz |
Thank you very much, Xantor for a patch that:
If a request is made for an asset which is not in the cache yet,
but has already been requested by something else, queue up the
callbacks on that requester instead of swamping the asset server
with multiple requests for the same asset.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 3ae18f1..feac65a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -248,6 +248,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
248 | { | 248 | { |
249 | //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); | 249 | //m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId); |
250 | 250 | ||
251 | |||
252 | // Xantor 20080526: | ||
253 | // if a request is made for an asset which is not in the cache yet, but has already been requested by | ||
254 | // something else, queue up the callbacks on that requestor instead of swamping the assetserver | ||
255 | // with multiple requests for the same asset. | ||
256 | |||
251 | AssetBase asset; | 257 | AssetBase asset; |
252 | 258 | ||
253 | if (TryGetCachedAsset(assetId, out asset)) | 259 | if (TryGetCachedAsset(assetId, out asset)) |
@@ -257,9 +263,33 @@ namespace OpenSim.Framework.Communications.Cache | |||
257 | else | 263 | else |
258 | { | 264 | { |
259 | #if DEBUG | 265 | #if DEBUG |
260 | //m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | 266 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); |
261 | #endif | 267 | #endif |
268 | |||
269 | |||
270 | NewAssetRequest req = new NewAssetRequest(assetId, callback); | ||
271 | AssetRequestsList requestList; | ||
272 | |||
273 | lock (RequestLists) | ||
274 | { | ||
275 | if (RequestLists.TryGetValue(assetId, out requestList)) // do we already have a request pending? | ||
276 | { | ||
277 | // m_log.DebugFormat("[ASSET CACHE]: Intercepted Duplicate request for {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
278 | // add to callbacks for this assetId | ||
279 | RequestLists[assetId].Requests.Add(req); | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | ||
284 | requestList = new AssetRequestsList(assetId); | ||
285 | RequestLists.Add(assetId, requestList); | ||
286 | requestList.Requests.Add(req); | ||
287 | m_assetServer.RequestAsset(assetId, isTexture); | ||
288 | } | ||
289 | } | ||
290 | |||
262 | 291 | ||
292 | /* Old code doesn't handle duplicate requests right | ||
263 | NewAssetRequest req = new NewAssetRequest(assetId, callback); | 293 | NewAssetRequest req = new NewAssetRequest(assetId, callback); |
264 | 294 | ||
265 | // Make sure we always have a request list to which to add the asset | 295 | // Make sure we always have a request list to which to add the asset |
@@ -278,6 +308,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
278 | requestList.Requests.Add(req); | 308 | requestList.Requests.Add(req); |
279 | 309 | ||
280 | m_assetServer.RequestAsset(assetId, isTexture); | 310 | m_assetServer.RequestAsset(assetId, isTexture); |
311 | */ | ||
281 | } | 312 | } |
282 | } | 313 | } |
283 | 314 | ||
@@ -447,6 +478,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
447 | 478 | ||
448 | foreach (NewAssetRequest req in theseRequests) | 479 | foreach (NewAssetRequest req in theseRequests) |
449 | { | 480 | { |
481 | // Xantor 20080526 are we really calling all the callbacks if multiple queued for 1 request? -- Yes, checked | ||
482 | // m_log.DebugFormat("[ASSET CACHE]: Callback for asset {0}", asset.FullID); | ||
450 | req.Callback(asset.FullID, asset); | 483 | req.Callback(asset.FullID, asset); |
451 | } | 484 | } |
452 | } | 485 | } |