Make sharing errors not spew and let the cache retry the files

avinationmerge
Melanie Thielker 2013-03-23 13:12:41 +01:00
parent 455da9dd20
commit aba66c7112
1 changed files with 15 additions and 1 deletions

View File

@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Asset
AssetBase asset = null; AssetBase asset = null;
string filename = GetFileName(id); string filename = GetFileName(id);
if (File.Exists(filename)) while (File.Exists(filename))
{ {
FileStream stream = null; FileStream stream = null;
try try
@ -380,6 +380,8 @@ namespace OpenSim.Region.CoreModules.Asset
asset = (AssetBase)bformatter.Deserialize(stream); asset = (AssetBase)bformatter.Deserialize(stream);
m_DiskHits++; m_DiskHits++;
break;
} }
catch (System.Runtime.Serialization.SerializationException e) catch (System.Runtime.Serialization.SerializationException e)
{ {
@ -392,12 +394,24 @@ namespace OpenSim.Region.CoreModules.Asset
// {different version of AssetBase} -- we should attempt to // {different version of AssetBase} -- we should attempt to
// delete it and re-cache // delete it and re-cache
File.Delete(filename); File.Delete(filename);
break;
}
catch (IOException e)
{
// This is a sharing violation: File exists but can't be opened because it's
// being written
Thread.Sleep(100);
continue;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}",
filename, id, e.Message, e.StackTrace); filename, id, e.Message, e.StackTrace);
break;
} }
finally finally
{ {