From 89d23a1fa23cb191e7ebde047311adcadf3b2e45 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Oct 2009 01:45:49 +0100 Subject: Revert "Rewrote parts of the code that were double-locking different objects. This is about half of the code base reviewed." This reverts commit e992ca025571a891333a57012c2cd4419b6581e5. --- .../Cache/UserProfileCacheService.cs | 66 +++++++++++++--------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index b02cf5b..9e12d948 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -128,18 +128,24 @@ namespace OpenSim.Framework.Communications.Cache /// null if no user details are found public CachedUserInfo GetUserDetails(string fname, string lname) { - CachedUserInfo userInfo; lock (m_userProfilesByName) - { + { + CachedUserInfo userInfo; + if (m_userProfilesByName.TryGetValue(string.Format(NAME_FORMAT, fname, lname), out userInfo)) + { return userInfo; + } + else + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); + + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; + } } - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; } /// @@ -154,14 +160,20 @@ namespace OpenSim.Framework.Communications.Cache return null; lock (m_userProfilesById) + { if (m_userProfilesById.ContainsKey(userID)) + { return m_userProfilesById[userID]; - - UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); - if (userProfile != null) - return AddToCaches(userProfile); - else - return null; + } + else + { + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); + if (userProfile != null) + return AddToCaches(userProfile); + else + return null; + } + } } /// @@ -199,10 +211,14 @@ namespace OpenSim.Framework.Communications.Cache CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile); lock (m_userProfilesById) + { m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo; - - lock (m_userProfilesByName) - m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; + + lock (m_userProfilesByName) + { + m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo; + } + } return createdUserInfo; } @@ -214,25 +230,21 @@ namespace OpenSim.Framework.Communications.Cache /// true if there was a profile to remove, false otherwise protected bool RemoveFromCaches(UUID userId) { - CachedUserInfo userInfo = null; lock (m_userProfilesById) { if (m_userProfilesById.ContainsKey(userId)) { - userInfo = m_userProfilesById[userId]; + CachedUserInfo userInfo = m_userProfilesById[userId]; m_userProfilesById.Remove(userId); - } - } - - if (userInfo != null) - lock (m_userProfilesByName) - { - if (m_userProfilesByName.ContainsKey(userInfo.UserProfile.Name)) + + lock (m_userProfilesByName) { m_userProfilesByName.Remove(userInfo.UserProfile.Name); - return true; } + + return true; } + } return false; } -- cgit v1.1 From b5b53dd3ebb331c5d235df161fe9cefc405c3660 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 19:55:35 -0700 Subject: * One more debug message on FetchInventoryDescendants * More streams close on finally --- .../Communications/Clients/RegionClient.cs | 79 +++++++++++++++++----- 1 file changed, 62 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 10be069..220a9b6 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs @@ -124,9 +124,11 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + WebResponse webResponse = null; + StreamReader sr = null; try { - WebResponse webResponse = AgentCreateRequest.GetResponse(); + webResponse = AgentCreateRequest.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); @@ -134,11 +136,10 @@ namespace OpenSim.Framework.Communications.Clients else { - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); string response = sr.ReadToEnd().Trim(); - sr.Close(); m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); - + if (!String.IsNullOrEmpty(response)) { try @@ -167,6 +168,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -246,15 +252,17 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); + WebResponse webResponse = null; + StreamReader sr = null; try { - WebResponse webResponse = ChildUpdateRequest.GetResponse(); + webResponse = ChildUpdateRequest.GetResponse(); if (webResponse == null) { m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -266,6 +274,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -284,6 +297,7 @@ namespace OpenSim.Framework.Communications.Clients HttpWebResponse webResponse = null; string reply = string.Empty; + StreamReader sr = null; try { webResponse = (HttpWebResponse)request.GetResponse(); @@ -292,9 +306,8 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent get "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); reply = sr.ReadToEnd().Trim(); - sr.Close(); //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); @@ -305,6 +318,11 @@ namespace OpenSim.Framework.Communications.Clients // ignore, really return false; } + finally + { + if (sr != null) + sr.Close(); + } if (webResponse.StatusCode == HttpStatusCode.OK) { @@ -333,6 +351,7 @@ namespace OpenSim.Framework.Communications.Clients request.Method = "DELETE"; request.Timeout = 10000; + StreamReader sr = null; try { WebResponse webResponse = request.GetResponse(); @@ -341,7 +360,7 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent delete "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -353,6 +372,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -377,6 +401,7 @@ namespace OpenSim.Framework.Communications.Clients request.Method = "DELETE"; request.Timeout = 10000; + StreamReader sr = null; try { WebResponse webResponse = request.GetResponse(); @@ -385,7 +410,7 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on agent delete "); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); sr.Close(); @@ -397,6 +422,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; } @@ -463,6 +493,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + StreamReader sr = null; try { WebResponse webResponse = ObjectCreateRequest.GetResponse(); @@ -471,10 +502,9 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); } @@ -483,6 +513,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -542,6 +577,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); + StreamReader sr = null; try { WebResponse webResponse = ObjectCreateRequest.GetResponse(); @@ -550,11 +586,10 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); - + //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); } @@ -563,6 +598,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; @@ -630,6 +670,7 @@ namespace OpenSim.Framework.Communications.Clients // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); + StreamReader sr = null; try { WebResponse webResponse = HelloNeighbourRequest.GetResponse(); @@ -638,10 +679,9 @@ namespace OpenSim.Framework.Communications.Clients m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); } - StreamReader sr = new StreamReader(webResponse.GetResponseStream()); + sr = new StreamReader(webResponse.GetResponseStream()); //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); - sr.Close(); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); } @@ -650,6 +690,11 @@ namespace OpenSim.Framework.Communications.Clients m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); // ignore, really } + finally + { + if (sr != null) + sr.Close(); + } return true; -- cgit v1.1