diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLEstateData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLEstateData.cs | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3dd46cb..fe1487b 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -43,12 +43,7 @@ namespace OpenSim.Data.MySQL | |||
43 | private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | private const string m_waitTimeoutSelect = "select @@wait_timeout"; | ||
47 | |||
48 | private string m_connectionString; | 46 | private string m_connectionString; |
49 | private long m_waitTimeout; | ||
50 | private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; | ||
51 | // private long m_lastConnectionUse; | ||
52 | 47 | ||
53 | private FieldInfo[] m_Fields; | 48 | private FieldInfo[] m_Fields; |
54 | private Dictionary<string, FieldInfo> m_FieldMap = | 49 | private Dictionary<string, FieldInfo> m_FieldMap = |
@@ -81,8 +76,6 @@ namespace OpenSim.Data.MySQL | |||
81 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); | 76 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); |
82 | } | 77 | } |
83 | 78 | ||
84 | GetWaitTimeout(); | ||
85 | |||
86 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 79 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
87 | { | 80 | { |
88 | dbcon.Open(); | 81 | dbcon.Open(); |
@@ -108,33 +101,6 @@ namespace OpenSim.Data.MySQL | |||
108 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } | 101 | get { return new List<string>(m_FieldMap.Keys).ToArray(); } |
109 | } | 102 | } |
110 | 103 | ||
111 | protected void GetWaitTimeout() | ||
112 | { | ||
113 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
114 | { | ||
115 | dbcon.Open(); | ||
116 | |||
117 | using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) | ||
118 | { | ||
119 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
120 | { | ||
121 | if (dbReader.Read()) | ||
122 | { | ||
123 | m_waitTimeout | ||
124 | = Convert.ToInt32(dbReader["@@wait_timeout"]) * | ||
125 | TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // m_lastConnectionUse = DateTime.Now.Ticks; | ||
131 | |||
132 | m_log.DebugFormat( | ||
133 | "[REGION DB]: Connection wait timeout {0} seconds", | ||
134 | m_waitTimeout / TimeSpan.TicksPerSecond); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 104 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
139 | { | 105 | { |
140 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + | 106 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + |
@@ -145,7 +111,11 @@ namespace OpenSim.Data.MySQL | |||
145 | cmd.CommandText = sql; | 111 | cmd.CommandText = sql; |
146 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 112 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
147 | 113 | ||
148 | return DoLoad(cmd, regionID, create); | 114 | EstateSettings e = DoLoad(cmd, regionID, create); |
115 | if (!create && e.EstateID == 0) // Not found | ||
116 | return null; | ||
117 | |||
118 | return e; | ||
149 | } | 119 | } |
150 | } | 120 | } |
151 | 121 | ||
@@ -427,7 +397,10 @@ namespace OpenSim.Data.MySQL | |||
427 | cmd.CommandText = sql; | 397 | cmd.CommandText = sql; |
428 | cmd.Parameters.AddWithValue("?EstateID", estateID); | 398 | cmd.Parameters.AddWithValue("?EstateID", estateID); |
429 | 399 | ||
430 | return DoLoad(cmd, UUID.Zero, false); | 400 | EstateSettings e = DoLoad(cmd, UUID.Zero, false); |
401 | if (e.EstateID != estateID) | ||
402 | return null; | ||
403 | return e; | ||
431 | } | 404 | } |
432 | } | 405 | } |
433 | 406 | ||