mirror of
https://github.com/opensim/opensim.git
synced 2026-06-21 04:55:37 +08:00
Remove the using() constructs from the new style database modules; they caused
the underlying connection of a reader or command to be closed before the reader or command itself. Added the proper logic to Close and dispose items in CloseDBConnection. Readers and Connections need Close(), Commands need Dispose(), in the order Reader, Command, Connection. Also reinstated 80-column-friendly formatting
This commit is contained in:
@@ -40,7 +40,9 @@ namespace OpenSim.Data.MySQL
|
||||
/// </summary>
|
||||
public class MySqlFramework
|
||||
{
|
||||
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);
|
||||
|
||||
protected MySqlConnection m_Connection;
|
||||
|
||||
@@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL
|
||||
errorSeen = true;
|
||||
|
||||
m_Connection.Close();
|
||||
MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone();
|
||||
MySqlConnection newConnection =
|
||||
(MySqlConnection)((ICloneable)m_Connection).Clone();
|
||||
m_Connection.Dispose();
|
||||
m_Connection = newConnection;
|
||||
m_Connection.Open();
|
||||
@@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
protected IDataReader ExecuteReader(MySqlCommand cmd)
|
||||
{
|
||||
MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone();
|
||||
MySqlConnection newConnection =
|
||||
(MySqlConnection)((ICloneable)m_Connection).Clone();
|
||||
newConnection.Open();
|
||||
|
||||
cmd.Connection = newConnection;
|
||||
return cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
protected void CloseDBConnection(MySqlCommand cmd)
|
||||
protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd)
|
||||
{
|
||||
reader.Close();
|
||||
cmd.Connection.Close();
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user