diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLFramework.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFramework.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 5820a90..a522912 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -45,14 +45,21 @@ namespace OpenSim.Data.MySQL | |||
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected string m_connectionString; | 47 | protected string m_connectionString; |
48 | protected object m_dbLock = new object(); | ||
48 | 49 | ||
49 | protected MySqlFramework(string connectionString) | 50 | protected MySqlFramework(string connectionString) |
50 | { | 51 | { |
51 | m_connectionString = connectionString; | 52 | m_connectionString = connectionString; |
52 | } | 53 | } |
53 | 54 | ||
55 | ////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | // All non queries are funneled through one connection | ||
58 | // to increase performance a little | ||
59 | // | ||
54 | protected int ExecuteNonQuery(MySqlCommand cmd) | 60 | protected int ExecuteNonQuery(MySqlCommand cmd) |
55 | { | 61 | { |
62 | lock (m_dbLock) | ||
56 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 63 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
57 | { | 64 | { |
58 | dbcon.Open(); | 65 | dbcon.Open(); |
@@ -60,7 +67,19 @@ namespace OpenSim.Data.MySQL | |||
60 | 67 | ||
61 | try | 68 | try |
62 | { | 69 | { |
63 | return cmd.ExecuteNonQuery(); | 70 | dbcon.Open(); |
71 | cmd.Connection = dbcon; | ||
72 | |||
73 | try | ||
74 | { | ||
75 | return cmd.ExecuteNonQuery(); | ||
76 | } | ||
77 | catch (Exception e) | ||
78 | { | ||
79 | m_log.Error(e.Message, e); | ||
80 | m_log.Error(Environment.StackTrace.ToString()); | ||
81 | return 0; | ||
82 | } | ||
64 | } | 83 | } |
65 | catch (Exception e) | 84 | catch (Exception e) |
66 | { | 85 | { |