diff options
author | Melanie | 2009-10-06 14:30:25 +0100 |
---|---|---|
committer | Melanie | 2009-10-06 14:30:25 +0100 |
commit | 8a7a947faaeeaeac2f74f695cefd6eb3e774dc15 (patch) | |
tree | 0b7cc12640fa58c5635b61ae2af087469581253d /OpenSim/Data/MySQL/MySQLFramework.cs | |
parent | Correction on the DEBUG code. (diff) | |
download | opensim-SC-8a7a947faaeeaeac2f74f695cefd6eb3e774dc15.zip opensim-SC-8a7a947faaeeaeac2f74f695cefd6eb3e774dc15.tar.gz opensim-SC-8a7a947faaeeaeac2f74f695cefd6eb3e774dc15.tar.bz2 opensim-SC-8a7a947faaeeaeac2f74f695cefd6eb3e774dc15.tar.xz |
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
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLFramework.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFramework.cs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f37e9bc..ccd1ab0 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -40,7 +40,9 @@ namespace OpenSim.Data.MySQL | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class MySqlFramework | 41 | public class MySqlFramework |
42 | { | 42 | { |
43 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly log4net.ILog m_log = |
44 | log4net.LogManager.GetLogger( | ||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | 46 | ||
45 | protected MySqlConnection m_Connection; | 47 | protected MySqlConnection m_Connection; |
46 | 48 | ||
@@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL | |||
81 | errorSeen = true; | 83 | errorSeen = true; |
82 | 84 | ||
83 | m_Connection.Close(); | 85 | m_Connection.Close(); |
84 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); | 86 | MySqlConnection newConnection = |
87 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
85 | m_Connection.Dispose(); | 88 | m_Connection.Dispose(); |
86 | m_Connection = newConnection; | 89 | m_Connection = newConnection; |
87 | m_Connection.Open(); | 90 | m_Connection.Open(); |
@@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL | |||
102 | 105 | ||
103 | protected IDataReader ExecuteReader(MySqlCommand cmd) | 106 | protected IDataReader ExecuteReader(MySqlCommand cmd) |
104 | { | 107 | { |
105 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); | 108 | MySqlConnection newConnection = |
109 | (MySqlConnection)((ICloneable)m_Connection).Clone(); | ||
106 | newConnection.Open(); | 110 | newConnection.Open(); |
107 | 111 | ||
108 | cmd.Connection = newConnection; | 112 | cmd.Connection = newConnection; |
109 | return cmd.ExecuteReader(); | 113 | return cmd.ExecuteReader(); |
110 | } | 114 | } |
111 | 115 | ||
112 | protected void CloseDBConnection(MySqlCommand cmd) | 116 | protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) |
113 | { | 117 | { |
118 | reader.Close(); | ||
119 | cmd.Connection.Close(); | ||
114 | cmd.Connection.Dispose(); | 120 | cmd.Connection.Dispose(); |
115 | } | 121 | } |
116 | } | 122 | } |