From 8e119130c506a2debff44a991af7a9106d188759 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 16 Nov 2008 04:39:41 +0000 Subject: [PATCH] Make a quick stab at the "Open data reader" issue. MySqlDataReader needs to be Close()d explicitly. Disposing it or letting it fall out of scope will not free it's hold on the connection. --- OpenSim/Data/MySQL/MySQLRegionData.cs | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index e793b7e1f8..fcb4c0b6d7 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -212,16 +212,23 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection); - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + lock (m_dataSet) { - if (dbReader.Read()) + MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow); + try { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } - dbReader.Close(); - cmd.Dispose(); + cmd.Dispose(); + } + finally + { + dbReader.Close(); + } } m_lastConnectionUse = System.DateTime.Now.Ticks; @@ -571,7 +578,8 @@ namespace OpenSim.Data.MySQL lock (m_dataSet) { CheckConnection(); - using (MySqlDataReader row = cmd.ExecuteReader()) + MySqlDataReader row = cmd.ExecuteReader(); + try { int rev = 0; if (row.Read()) @@ -595,6 +603,10 @@ namespace OpenSim.Data.MySQL m_log.Info("[REGION DB]: Loaded terrain revision r" + rev.ToString()); } + finally + { + row.Close(); + } } return terret; }