* 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
@ -513,9 +514,12 @@ namespace OpenSim.Framework.Data.MySQL
cmd.Parameters.AddWithValue("?version", folder.version); cmd.Parameters.AddWithValue("?version", folder.version);
try try
{
lock (database)
{ {
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
}
catch (Exception e) catch (Exception e)
{ {
m_log.Error(e.ToString()); m_log.Error(e.ToString());
@ -543,11 +547,13 @@ 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
{
lock (database)
{ {
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
}
catch (Exception e) catch (Exception e)
{ {
m_log.Error(e.ToString()); m_log.Error(e.ToString());
@ -590,8 +596,12 @@ namespace OpenSim.Framework.Data.MySQL
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());
lock (database)
{
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
}
catch (MySqlException e) catch (MySqlException e)
{ {
database.Reconnect(); database.Reconnect();
@ -606,8 +616,12 @@ 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());
lock (database)
{
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
}
catch (MySqlException e) catch (MySqlException e)
{ {
database.Reconnect(); database.Reconnect();
@ -621,8 +635,6 @@ namespace OpenSim.Framework.Data.MySQL
/// </summary> /// </summary>
/// <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); List<InventoryFolderBase> subFolders = getFolderHierarchy(folderID);
@ -638,5 +650,4 @@ namespace OpenSim.Framework.Data.MySQL
deleteItemsInFolder(folderID); deleteItemsInFolder(folderID);
} }
} }
}
} }