From e99a7d879ecf59737e9916a9eb229698ef866627 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 16 Jan 2014 00:05:04 +0000 Subject: Remove old IInterRegionComms and references. This hasn't been used since 2009 and was superseded by ISimulationService --- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 4 ++-- .../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 678f3dc..4dcb99f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #endregion - #region ISimulation + #region ISimulationService public IScene GetScene(UUID regionId) { @@ -353,7 +353,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - #endregion /* IInterregionComms */ + #endregion #region Misc diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f45f560..cc01430 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #endregion - #region IInterregionComms + #region ISimulationService public IScene GetScene(UUID regionId) { @@ -279,6 +279,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - #endregion /* IInterregionComms */ + #endregion } } -- cgit v1.1 From 9fefbcf7fc5e8767030757da7ab077fa96cc0904 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 17 Jan 2014 23:32:37 +0000 Subject: minor: since structs are values, assigning them to another variable copies it. Instantiation is unnecessary. --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 246b253..5fea0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1385,7 +1385,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) { version = String.Empty; - newpos = new Vector3(pos.X, pos.Y, pos.Z); + newpos = pos; // m_log.DebugFormat( // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); -- cgit v1.1 From 12bfce7b9f1356893e351d13ddd947810c352727 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:06:12 +0000 Subject: elminate unnecessary asset != null check in FlotsamAssetCache.UpdateFileCache() Passed in asset is always not null --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 97 +++++++++++----------- 1 file changed, 47 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/CoreModules') 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 private void UpdateFileCache(string key, AssetBase asset) { - // TODO: Spawn this off to some seperate thread to do the actual writing - if (asset != null) - { - string filename = GetFileName(key); + string filename = GetFileName(key); - try + try + { + // If the file is already cached, don't cache it, just touch it so access time is updated + if (File.Exists(filename)) { - // If the file is already cached, don't cache it, just touch it so access time is updated - if (File.Exists(filename)) + // 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 { - // 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) { - lock (m_CurrentlyWriting) - { - if (!m_CurrentlyWriting.Contains(filename)) - File.SetLastAccessTime(filename, DateTime.Now); - } + if (!m_CurrentlyWriting.Contains(filename)) + File.SetLastAccessTime(filename, DateTime.Now); } - catch + } + 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 (m_CurrentlyWriting.ContainsKey(filename)) { + return; } - } 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) + else { -#if WAIT_ON_INPROGRESS_REQUESTS - if (m_CurrentlyWriting.ContainsKey(filename)) - { - return; - } - 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 - + if (m_CurrentlyWriting.Contains(filename)) + { + return; } + else + { + m_CurrentlyWriting.Add(filename); + } +#endif - Util.FireAndForget( - delegate { WriteFileCache(filename, asset); }); } + + Util.FireAndForget( + delegate { WriteFileCache(filename, asset); }); } - catch (Exception e) - { - m_log.ErrorFormat( - "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", - asset.ID, e.Message, e.StackTrace); - } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", + asset.ID, e.Message, e.StackTrace); } } -- cgit v1.1 From 97fbb8ed45e4827ea7473bac2b792499a9284c3e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:12:12 +0000 Subject: Elminate some copy/paste in FlotsamAssetCache.CheckFromFileCache() and use using() construct to ensure filestream is always closed --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 43 +++++----------------- 1 file changed, 10 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index e1aa460..169412e 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -352,7 +352,6 @@ namespace OpenSim.Region.CoreModules.Asset return false; } - /// /// Try to get an asset from the file cache. /// @@ -390,15 +389,16 @@ namespace OpenSim.Region.CoreModules.Asset if (File.Exists(filename)) { - FileStream stream = null; try { - stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryFormatter bformatter = new BinaryFormatter(); + using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + BinaryFormatter bformatter = new BinaryFormatter(); - asset = (AssetBase)bformatter.Deserialize(stream); + asset = (AssetBase)bformatter.Deserialize(stream); - m_DiskHits++; + m_DiskHits++; + } } catch (System.Runtime.Serialization.SerializationException e) { @@ -417,12 +417,6 @@ namespace OpenSim.Region.CoreModules.Asset m_log.WarnFormat( "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", filename, id, e.Message, e.StackTrace); - - } - finally - { - if (stream != null) - stream.Close(); } } @@ -434,36 +428,19 @@ namespace OpenSim.Region.CoreModules.Asset bool found = false; string filename = GetFileName(id); + if (File.Exists(filename)) { - // actually check if we can open it, and so update expire - FileStream stream = null; try { - stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); - if (stream != null) + using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { - found = true; - stream.Close(); + if (stream != null) + found = true; } - - } - catch (System.Runtime.Serialization.SerializationException e) - { - found = false; - m_log.ErrorFormat( - "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", - filename, id, e.Message, e.StackTrace); - - // If there was a problem deserializing the asset, the asset may - // either be corrupted OR was serialized under an old format - // {different version of AssetBase} -- we should attempt to - // delete it and re-cache - File.Delete(filename); } catch (Exception e) { - found = false; m_log.ErrorFormat( "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", filename, id, e.Message, e.StackTrace); -- cgit v1.1 From ee8ba1ab9a30cf397c390b161a5d03e8c7b86290 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:21:53 +0000 Subject: Simplify FlotsamAssetCache.CheckFromMemoryCache() --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 169412e..a1803c1 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -344,12 +344,7 @@ namespace OpenSim.Region.CoreModules.Asset private bool CheckFromMemoryCache(string id) { - AssetBase asset = null; - - if (m_MemoryCache.TryGetValue(id, out asset)) - return true; - - return false; + return m_MemoryCache.Contains(id); } /// -- cgit v1.1 From fc7ccfdafae7b8e9acd130b9f70e99241e0d33fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:30:23 +0000 Subject: Properly implement CenomeAssetCache.Check() --- OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index f43305f..9b0e1f4 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs @@ -194,10 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset #region IImprovedAssetCache Members - public bool Check(string id) { - return false; + AssetBase asset; + + // XXX:This is probably not an efficient implementation. + return m_cache.TryGetValue(id, out asset); } /// -- cgit v1.1 From 427ffd3387c13daf7babc08c13a9acac1fe405c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:48:20 +0000 Subject: implement GlynnTuckerAssetCache.Check() --- OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index ce9b546..5f76ac2 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs @@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Asset public bool Check(string id) { - return false; + return m_Cache.Contains(id); } public void Cache(AssetBase asset) -- cgit v1.1 From b9453a8f6f68cff86c261d245c41955ec8f8af84 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:52:36 +0000 Subject: implement CoreAssetCache.Check() --- OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 58ce61a..f720748 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs @@ -114,7 +114,8 @@ namespace OpenSim.Region.CoreModules.Asset // public bool Check(string id) { - return false; + // XXX This is probably not an efficient implementation. + return Get(id) != null; } public void Cache(AssetBase asset) -- cgit v1.1 From 0cbe5f842419040dcfee688664d605a03d2f420b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 18 Jan 2014 00:55:49 +0000 Subject: Remove redundant methods in FlotsamAssetCache --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index a1803c1..6a5f8f3 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -487,11 +487,6 @@ namespace OpenSim.Region.CoreModules.Asset return Get(id); } - public AssetBase CheckCached(string id) - { - return Get(id); - } - public void Expire(string id) { if (m_LogLevel >= 2) @@ -1036,11 +1031,6 @@ namespace OpenSim.Region.CoreModules.Asset return asset.Data; } - public bool CheckData(string id) - { - return Check(id); ; - } - public bool Get(string id, object sender, AssetRetrieved handler) { AssetBase asset = Get(id); -- cgit v1.1