From c0211c1ca232742946e47346917f3f8ab5ff3acb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 12 Feb 2008 22:24:12 +0000 Subject: * Add missing locking to mysql inventory plugin * Should resolve mantis 542 --- .../Cache/UserProfileCacheService.cs | 3 ++ OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 51 +++++++++++++--------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index e9765a7..257747b 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -259,6 +259,9 @@ namespace OpenSim.Framework.Communications.Cache public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) { +// m_log.InfoFormat("[INVENTORYCACHE]: Purging folder {0} for {1} uuid {2}", +// folderID, remoteClient.Name, remoteClient.AgentId); + CachedUserInfo userProfile; if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index 57c2c9f..8257a23 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -38,7 +38,8 @@ namespace OpenSim.Framework.Data.MySQL /// public class MySQLInventoryData : IInventoryData { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log + = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); /// /// The database manager @@ -514,7 +515,10 @@ namespace OpenSim.Framework.Data.MySQL try { - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); + } } catch (Exception e) { @@ -543,10 +547,12 @@ namespace OpenSim.Framework.Data.MySQL cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); - try { - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); + } } catch (Exception e) { @@ -586,11 +592,15 @@ namespace OpenSim.Framework.Data.MySQL protected void deleteOneFolder(LLUUID folderID) { try - { + { MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - cmd.ExecuteNonQuery(); + + lock (database) + { + cmd.ExecuteNonQuery(); + } } catch (MySqlException e) { @@ -606,7 +616,11 @@ namespace OpenSim.Framework.Data.MySQL MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - cmd.ExecuteNonQuery(); + + lock (database) + { + cmd.ExecuteNonQuery(); + } } catch (MySqlException e) { @@ -622,21 +636,18 @@ namespace OpenSim.Framework.Data.MySQL /// Id of folder to delete public void deleteInventoryFolder(LLUUID folderID) { - lock (database) - { - List subFolders = getFolderHierarchy(folderID); - - //Delete all sub-folders - foreach (InventoryFolderBase f in subFolders) - { - deleteOneFolder(f.folderID); - deleteItemsInFolder(f.folderID); - } + List subFolders = getFolderHierarchy(folderID); - //Delete the actual row - deleteOneFolder(folderID); - deleteItemsInFolder(folderID); + //Delete all sub-folders + foreach (InventoryFolderBase f in subFolders) + { + deleteOneFolder(f.folderID); + deleteItemsInFolder(f.folderID); } + + //Delete the actual row + deleteOneFolder(folderID); + deleteItemsInFolder(folderID); } } } \ No newline at end of file -- cgit v1.1