From 6309fcc5b4b42102b5bb901dbbdf44846f5643f2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:19:55 -0800 Subject: Reverting the memory leak patch for MySQL. Problems have been reported with the grid server after running for several hours --- OpenSim/Data/MySQL/MySQLAssetData.cs | 102 +++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 47 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..1fe6d29 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -139,42 +139,45 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", assetID.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - asset = new AssetBase(); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; - asset.FullID = assetID; - - string local = dbReader["local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; - - asset.Name = (string)dbReader["name"]; - asset.Type = (sbyte)dbReader["assetType"]; - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); - } + asset = new AssetBase(); + asset.Data = (byte[]) dbReader["data"]; + asset.Description = (string) dbReader["description"]; + asset.FullID = assetID; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Reconnecting", assetID); - _dbConnection.Reconnect(); - } + if (asset != null) + UpdateAccessTime(asset); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Reconnecting", assetID); + _dbConnection.Reconnect(); } } return asset; @@ -291,27 +294,32 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT id FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", uuid.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT id FROM assets WHERE id=?id", + _dbConnection.Connection); + + cmd.Parameters.AddWithValue("?id", uuid.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - assetExists = true; + assetExists = true; } + + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", uuid); - _dbConnection.Reconnect(); - } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", uuid); + _dbConnection.Reconnect(); } } -- cgit v1.1 From afef1ac191d32e9c1514c294b17e404b1d4ae217 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 13:10:58 -0800 Subject: Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen --- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1fe6d29..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -151,10 +151,9 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; string local = dbReader["local"].ToString(); if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) @@ -162,8 +161,6 @@ namespace OpenSim.Data.MySQL else asset.Local = false; - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } dbReader.Close(); -- cgit v1.1