diff options
author | Justin Clark-Casey (justincc) | 2014-01-18 00:06:12 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-01-18 00:06:12 +0000 |
commit | 12bfce7b9f1356893e351d13ddd947810c352727 (patch) | |
tree | 40af2a3dcb4570ea6821427830813cd6159d33bb | |
parent | minor: reinsert some method doc back into IEntityTransferModule (diff) | |
download | opensim-SC_OLD-12bfce7b9f1356893e351d13ddd947810c352727.zip opensim-SC_OLD-12bfce7b9f1356893e351d13ddd947810c352727.tar.gz opensim-SC_OLD-12bfce7b9f1356893e351d13ddd947810c352727.tar.bz2 opensim-SC_OLD-12bfce7b9f1356893e351d13ddd947810c352727.tar.xz |
elminate unnecessary asset != null check in FlotsamAssetCache.UpdateFileCache()
Passed in asset is always not null
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index f1fee63..e1aa460 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -248,70 +248,67 @@ namespace OpenSim.Region.CoreModules.Asset | |||
248 | 248 | ||
249 | private void UpdateFileCache(string key, AssetBase asset) | 249 | private void UpdateFileCache(string key, AssetBase asset) |
250 | { | 250 | { |
251 | // TODO: Spawn this off to some seperate thread to do the actual writing | 251 | string filename = GetFileName(key); |
252 | if (asset != null) | ||
253 | { | ||
254 | string filename = GetFileName(key); | ||
255 | 252 | ||
256 | try | 253 | try |
254 | { | ||
255 | // If the file is already cached, don't cache it, just touch it so access time is updated | ||
256 | if (File.Exists(filename)) | ||
257 | { | 257 | { |
258 | // If the file is already cached, don't cache it, just touch it so access time is updated | 258 | // We don't really want to know about sharing |
259 | if (File.Exists(filename)) | 259 | // violations here. If the file is locked, then |
260 | // the other thread has updated the time for us. | ||
261 | try | ||
260 | { | 262 | { |
261 | // We don't really want to know about sharing | 263 | lock (m_CurrentlyWriting) |
262 | // violations here. If the file is locked, then | ||
263 | // the other thread has updated the time for us. | ||
264 | try | ||
265 | { | 264 | { |
266 | lock (m_CurrentlyWriting) | 265 | if (!m_CurrentlyWriting.Contains(filename)) |
267 | { | 266 | File.SetLastAccessTime(filename, DateTime.Now); |
268 | if (!m_CurrentlyWriting.Contains(filename)) | ||
269 | File.SetLastAccessTime(filename, DateTime.Now); | ||
270 | } | ||
271 | } | 267 | } |
272 | catch | 268 | } |
269 | catch | ||
270 | { | ||
271 | } | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | // Once we start writing, make sure we flag that we're writing | ||
276 | // that object to the cache so that we don't try to write the | ||
277 | // same file multiple times. | ||
278 | lock (m_CurrentlyWriting) | ||
279 | { | ||
280 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
281 | if (m_CurrentlyWriting.ContainsKey(filename)) | ||
273 | { | 282 | { |
283 | return; | ||
274 | } | 284 | } |
275 | } else { | 285 | else |
276 | |||
277 | // Once we start writing, make sure we flag that we're writing | ||
278 | // that object to the cache so that we don't try to write the | ||
279 | // same file multiple times. | ||
280 | lock (m_CurrentlyWriting) | ||
281 | { | 286 | { |
282 | #if WAIT_ON_INPROGRESS_REQUESTS | 287 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); |
283 | if (m_CurrentlyWriting.ContainsKey(filename)) | 288 | } |
284 | { | ||
285 | return; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||
290 | } | ||
291 | 289 | ||
292 | #else | 290 | #else |
293 | if (m_CurrentlyWriting.Contains(filename)) | 291 | if (m_CurrentlyWriting.Contains(filename)) |
294 | { | 292 | { |
295 | return; | 293 | return; |
296 | } | ||
297 | else | ||
298 | { | ||
299 | m_CurrentlyWriting.Add(filename); | ||
300 | } | ||
301 | #endif | ||
302 | |||
303 | } | 294 | } |
295 | else | ||
296 | { | ||
297 | m_CurrentlyWriting.Add(filename); | ||
298 | } | ||
299 | #endif | ||
304 | 300 | ||
305 | Util.FireAndForget( | ||
306 | delegate { WriteFileCache(filename, asset); }); | ||
307 | } | 301 | } |
302 | |||
303 | Util.FireAndForget( | ||
304 | delegate { WriteFileCache(filename, asset); }); | ||
308 | } | 305 | } |
309 | catch (Exception e) | 306 | } |
310 | { | 307 | catch (Exception e) |
311 | m_log.ErrorFormat( | 308 | { |
312 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | 309 | m_log.ErrorFormat( |
313 | asset.ID, e.Message, e.StackTrace); | 310 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", |
314 | } | 311 | asset.ID, e.Message, e.StackTrace); |
315 | } | 312 | } |
316 | } | 313 | } |
317 | 314 | ||