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/MySQLGridData.cs | 171 ++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 84 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLGridData.cs') diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - using (IDbCommand result = dbm.Manager.Query( + IDbCommand result = + dbm.Manager.Query( "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while ((row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows.ToArray(); - } + while ((row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows.ToArray(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName LIKE ?name", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows; - } + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); + param["?handle"] = handle.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } @@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } - } + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } - m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } @@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); - try - { + try { if (dbm.Manager.insertRegion(profile)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; + } + return DataResponse.RESPONSE_ERROR; } finally { @@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL { MySQLSuperManager dbm = GetLockedConnection(); - try - { + + try { if (dbm.Manager.deleteRegion(uuid)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; - } - finally + } + return DataResponse.RESPONSE_ERROR; + } finally { dbm.Release(); } @@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - ReservationData row = dbm.Manager.readReservationRow(reader); - return row; - } - } + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param); + IDataReader reader = result.ExecuteReader(); + + ReservationData row = dbm.Manager.readReservationRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } -- cgit v1.1