diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 68 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 10 |
2 files changed, 34 insertions, 44 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 08e7cb7..d510d82 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -365,11 +365,36 @@ namespace OpenSim.Region.CoreModules.Asset | |||
365 | /// <param name="id"></param> | 365 | /// <param name="id"></param> |
366 | /// <returns>An asset retrieved from the file cache. null if there was a problem retrieving an asset.</returns> | 366 | /// <returns>An asset retrieved from the file cache. null if there was a problem retrieving an asset.</returns> |
367 | private AssetBase GetFromFileCache(string id) | 367 | private AssetBase GetFromFileCache(string id) |
368 | { | 368 | { |
369 | AssetBase asset = null; | ||
370 | |||
371 | string filename = GetFileName(id); | 369 | string filename = GetFileName(id); |
372 | while (File.Exists(filename)) | 370 | |
371 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
372 | // Check if we're already downloading this asset. If so, try to wait for it to | ||
373 | // download. | ||
374 | if (m_WaitOnInprogressTimeout > 0) | ||
375 | { | ||
376 | m_RequestsForInprogress++; | ||
377 | |||
378 | ManualResetEvent waitEvent; | ||
379 | if (m_CurrentlyWriting.TryGetValue(filename, out waitEvent)) | ||
380 | { | ||
381 | waitEvent.WaitOne(m_WaitOnInprogressTimeout); | ||
382 | return Get(id); | ||
383 | } | ||
384 | } | ||
385 | #else | ||
386 | // Track how often we have the problem that an asset is requested while | ||
387 | // it is still being downloaded by a previous request. | ||
388 | if (m_CurrentlyWriting.Contains(filename)) | ||
389 | { | ||
390 | m_RequestsForInprogress++; | ||
391 | return null; | ||
392 | } | ||
393 | #endif | ||
394 | |||
395 | AssetBase asset = null; | ||
396 | |||
397 | if (File.Exists(filename)) | ||
373 | { | 398 | { |
374 | FileStream stream = null; | 399 | FileStream stream = null; |
375 | try | 400 | try |
@@ -380,8 +405,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
380 | asset = (AssetBase)bformatter.Deserialize(stream); | 405 | asset = (AssetBase)bformatter.Deserialize(stream); |
381 | 406 | ||
382 | m_DiskHits++; | 407 | m_DiskHits++; |
383 | |||
384 | break; | ||
385 | } | 408 | } |
386 | catch (System.Runtime.Serialization.SerializationException e) | 409 | catch (System.Runtime.Serialization.SerializationException e) |
387 | { | 410 | { |
@@ -394,16 +417,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
394 | // {different version of AssetBase} -- we should attempt to | 417 | // {different version of AssetBase} -- we should attempt to |
395 | // delete it and re-cache | 418 | // delete it and re-cache |
396 | File.Delete(filename); | 419 | File.Delete(filename); |
397 | |||
398 | break; | ||
399 | } | ||
400 | catch (IOException e) | ||
401 | { | ||
402 | // This is a sharing violation: File exists but can't be opened because it's | ||
403 | // being written | ||
404 | Thread.Sleep(100); | ||
405 | |||
406 | continue; | ||
407 | } | 420 | } |
408 | catch (Exception e) | 421 | catch (Exception e) |
409 | { | 422 | { |
@@ -411,7 +424,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
411 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | 424 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", |
412 | filename, id, e.Message, e.StackTrace); | 425 | filename, id, e.Message, e.StackTrace); |
413 | 426 | ||
414 | break; | ||
415 | } | 427 | } |
416 | finally | 428 | finally |
417 | { | 429 | { |
@@ -420,28 +432,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
420 | } | 432 | } |
421 | } | 433 | } |
422 | 434 | ||
423 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
424 | // Check if we're already downloading this asset. If so, try to wait for it to | ||
425 | // download. | ||
426 | if (m_WaitOnInprogressTimeout > 0) | ||
427 | { | ||
428 | m_RequestsForInprogress++; | ||
429 | |||
430 | ManualResetEvent waitEvent; | ||
431 | if (m_CurrentlyWriting.TryGetValue(filename, out waitEvent)) | ||
432 | { | ||
433 | waitEvent.WaitOne(m_WaitOnInprogressTimeout); | ||
434 | return Get(id); | ||
435 | } | ||
436 | } | ||
437 | #else | ||
438 | // Track how often we have the problem that an asset is requested while | ||
439 | // it is still being downloaded by a previous request. | ||
440 | if (m_CurrentlyWriting.Contains(filename)) | ||
441 | { | ||
442 | m_RequestsForInprogress++; | ||
443 | } | ||
444 | #endif | ||
445 | return asset; | 435 | return asset; |
446 | } | 436 | } |
447 | 437 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8082c1b..b70aeb7 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1289,16 +1289,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | 1291 | ||
1292 | public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, | 1292 | public delegate void InformClientToInitiateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, |
1293 | Vector3 position, | 1293 | Vector3 position, |
1294 | Scene initiatingScene); | 1294 | Scene initiatingScene); |
1295 | 1295 | ||
1296 | private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) | 1296 | private void InformClientToInitiateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) |
1297 | { | 1297 | { |
1298 | 1298 | ||
1299 | // This assumes that we know what our neighbours are. | 1299 | // This assumes that we know what our neighbours are. |
1300 | 1300 | ||
1301 | InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; | 1301 | InformClientToInitiateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; |
1302 | d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, | 1302 | d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, |
1303 | InformClientToInitiateTeleportToLocationCompleted, | 1303 | InformClientToInitiateTeleportToLocationCompleted, |
1304 | d); | 1304 | d); |
@@ -1360,8 +1360,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1360 | 1360 | ||
1361 | private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) | 1361 | private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) |
1362 | { | 1362 | { |
1363 | InformClientToInitateTeleportToLocationDelegate icon = | 1363 | InformClientToInitiateTeleportToLocationDelegate icon = |
1364 | (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState; | 1364 | (InformClientToInitiateTeleportToLocationDelegate)iar.AsyncState; |
1365 | icon.EndInvoke(iar); | 1365 | icon.EndInvoke(iar); |
1366 | } | 1366 | } |
1367 | 1367 | ||