* Add missing locking to mysql inventory plugin

* Should resolve mantis 542
ThreadPoolClientBranch
Justin Clarke Casey 2008-02-12 22:24:12 +00:00
parent 6a3455a98c
commit c0211c1ca2
2 changed files with 34 additions and 20 deletions

View File

@ -259,6 +259,9 @@ namespace OpenSim.Framework.Communications.Cache
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID) 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; CachedUserInfo userProfile;
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{ {

View File

@ -38,7 +38,8 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
public class MySQLInventoryData : IInventoryData 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);
/// <summary> /// <summary>
/// The database manager /// The database manager
@ -514,7 +515,10 @@ namespace OpenSim.Framework.Data.MySQL
try try
{ {
cmd.ExecuteNonQuery(); lock (database)
{
cmd.ExecuteNonQuery();
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -543,10 +547,12 @@ namespace OpenSim.Framework.Data.MySQL
cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString()); cmd.Parameters.AddWithValue("?folderID", folder.folderID.ToString());
cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToString());
try try
{ {
cmd.ExecuteNonQuery(); lock (database)
{
cmd.ExecuteNonQuery();
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -586,11 +592,15 @@ namespace OpenSim.Framework.Data.MySQL
protected void deleteOneFolder(LLUUID folderID) protected void deleteOneFolder(LLUUID folderID)
{ {
try try
{ {
MySqlCommand cmd = MySqlCommand cmd =
new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
cmd.ExecuteNonQuery();
lock (database)
{
cmd.ExecuteNonQuery();
}
} }
catch (MySqlException e) catch (MySqlException e)
{ {
@ -606,7 +616,11 @@ namespace OpenSim.Framework.Data.MySQL
MySqlCommand cmd = MySqlCommand cmd =
new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
cmd.ExecuteNonQuery();
lock (database)
{
cmd.ExecuteNonQuery();
}
} }
catch (MySqlException e) catch (MySqlException e)
{ {
@ -622,21 +636,18 @@ namespace OpenSim.Framework.Data.MySQL
/// <param name="folderId">Id of folder to delete</param> /// <param name="folderId">Id of folder to delete</param>
public void deleteInventoryFolder(LLUUID folderID) public void deleteInventoryFolder(LLUUID folderID)
{ {
lock (database) List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
//Delete all sub-folders
foreach (InventoryFolderBase f in subFolders)
{ {
List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID); deleteOneFolder(f.folderID);
deleteItemsInFolder(f.folderID);
//Delete all sub-folders
foreach (InventoryFolderBase f in subFolders)
{
deleteOneFolder(f.folderID);
deleteItemsInFolder(f.folderID);
}
//Delete the actual row
deleteOneFolder(folderID);
deleteItemsInFolder(folderID);
} }
//Delete the actual row
deleteOneFolder(folderID);
deleteItemsInFolder(folderID);
} }
} }
} }