elminate unnecessary asset != null check in FlotsamAssetCache.UpdateFileCache()
Passed in asset is always not nullmaster-beforevarregion
							parent
							
								
									b52b50ee56
								
							
						
					
					
						commit
						12bfce7b9f
					
				|  | @ -248,70 +248,67 @@ namespace OpenSim.Region.CoreModules.Asset | ||||||
| 
 | 
 | ||||||
|         private void UpdateFileCache(string key, AssetBase asset) |         private void UpdateFileCache(string key, AssetBase asset) | ||||||
|         { |         { | ||||||
|             // TODO: Spawn this off to some seperate thread to do the actual writing |             string filename = GetFileName(key); | ||||||
|             if (asset != null) | 
 | ||||||
|  |             try | ||||||
|             { |             { | ||||||
|                 string filename = GetFileName(key); |                 // If the file is already cached, don't cache it, just touch it so access time is updated | ||||||
| 
 |                 if (File.Exists(filename)) | ||||||
|                 try |  | ||||||
|                 { |                 { | ||||||
|                     // If the file is already cached, don't cache it, just touch it so access time is updated |                     // We don't really want to know about sharing | ||||||
|                     if (File.Exists(filename)) |                     // violations here. If the file is locked, then | ||||||
|  |                     // the other thread has updated the time for us. | ||||||
|  |                     try | ||||||
|                     { |                     { | ||||||
|                         // We don't really want to know about sharing |  | ||||||
|                         // violations here. If the file is locked, then |  | ||||||
|                         // the other thread has updated the time for us. |  | ||||||
|                         try |  | ||||||
|                         { |  | ||||||
|                             lock (m_CurrentlyWriting) |  | ||||||
|                             { |  | ||||||
|                                 if (!m_CurrentlyWriting.Contains(filename)) |  | ||||||
|                                     File.SetLastAccessTime(filename, DateTime.Now); |  | ||||||
|                             } |  | ||||||
|                         } |  | ||||||
|                         catch |  | ||||||
|                         { |  | ||||||
|                         } |  | ||||||
|                     } else { |  | ||||||
| 
 |  | ||||||
|                         // Once we start writing, make sure we flag that we're writing |  | ||||||
|                         // that object to the cache so that we don't try to write the  |  | ||||||
|                         // same file multiple times. |  | ||||||
|                         lock (m_CurrentlyWriting) |                         lock (m_CurrentlyWriting) | ||||||
|                         { |                         { | ||||||
|  |                             if (!m_CurrentlyWriting.Contains(filename)) | ||||||
|  |                                 File.SetLastAccessTime(filename, DateTime.Now); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     catch | ||||||
|  |                     { | ||||||
|  |                     } | ||||||
|  |                 }  | ||||||
|  |                 else  | ||||||
|  |                 { | ||||||
|  |                     // Once we start writing, make sure we flag that we're writing | ||||||
|  |                     // that object to the cache so that we don't try to write the  | ||||||
|  |                     // same file multiple times. | ||||||
|  |                     lock (m_CurrentlyWriting) | ||||||
|  |                     { | ||||||
| #if WAIT_ON_INPROGRESS_REQUESTS | #if WAIT_ON_INPROGRESS_REQUESTS | ||||||
|                             if (m_CurrentlyWriting.ContainsKey(filename)) |                         if (m_CurrentlyWriting.ContainsKey(filename)) | ||||||
|                             { |                         { | ||||||
|                                 return; |                             return; | ||||||
|                             } |                         } | ||||||
|                             else |                         else | ||||||
|                             { |                         { | ||||||
|                                 m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); |                             m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||||||
|                             } |  | ||||||
| 
 |  | ||||||
| #else |  | ||||||
|                             if (m_CurrentlyWriting.Contains(filename)) |  | ||||||
|                             { |  | ||||||
|                                 return; |  | ||||||
|                             } |  | ||||||
|                             else |  | ||||||
|                             { |  | ||||||
|                                 m_CurrentlyWriting.Add(filename); |  | ||||||
|                             } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                         Util.FireAndForget( | #else | ||||||
|                             delegate { WriteFileCache(filename, asset); }); |                         if (m_CurrentlyWriting.Contains(filename)) | ||||||
|  |                         { | ||||||
|  |                             return; | ||||||
|  |                         } | ||||||
|  |                         else | ||||||
|  |                         { | ||||||
|  |                             m_CurrentlyWriting.Add(filename); | ||||||
|  |                         } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|                     } |                     } | ||||||
|  | 
 | ||||||
|  |                     Util.FireAndForget( | ||||||
|  |                         delegate { WriteFileCache(filename, asset); }); | ||||||
|                 } |                 } | ||||||
|                 catch (Exception e) |             } | ||||||
|                 { |             catch (Exception e) | ||||||
|                     m_log.ErrorFormat( |             { | ||||||
|                         "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}.  Exception {1} {2}", |                 m_log.ErrorFormat( | ||||||
|                         asset.ID, e.Message, e.StackTrace); |                     "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}.  Exception {1} {2}", | ||||||
|                 } |                     asset.ID, e.Message, e.StackTrace); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Justin Clark-Casey (justincc)
						Justin Clark-Casey (justincc)