take more heavy work out of opened dbconn sections

httptests
UbitUmarov 2017-05-07 22:22:28 +01:00
parent d0912b6151
commit 8ef43e5fb3
1 changed files with 22 additions and 14 deletions

View File

@ -607,6 +607,10 @@ namespace OpenSim.Data.MySQL
{ {
m_log.Info("[REGION DB]: Storing terrain"); m_log.Info("[REGION DB]: Storing terrain");
int terrainDBRevision;
Array terrainDBblob;
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
lock (m_dbLock) lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
@ -626,10 +630,6 @@ namespace OpenSim.Data.MySQL
"Revision, Heightfield) values (?RegionUUID, " + "Revision, Heightfield) values (?RegionUUID, " +
"?Revision, ?Heightfield)"; "?Revision, ?Heightfield)";
int terrainDBRevision;
Array terrainDBblob;
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
@ -655,6 +655,10 @@ namespace OpenSim.Data.MySQL
{ {
m_log.Info("[REGION DB]: Storing Baked terrain"); m_log.Info("[REGION DB]: Storing Baked terrain");
int terrainDBRevision;
Array terrainDBblob;
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
lock (m_dbLock) lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
@ -674,10 +678,6 @@ namespace OpenSim.Data.MySQL
"Revision, Heightfield) values (?RegionUUID, " + "Revision, Heightfield) values (?RegionUUID, " +
"?Revision, ?Heightfield)"; "?Revision, ?Heightfield)";
int terrainDBRevision;
Array terrainDBblob;
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
@ -711,9 +711,12 @@ namespace OpenSim.Data.MySQL
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{ {
TerrainData terrData = null; TerrainData terrData = null;
byte[] blob = null;
int rev = 0;
lock (m_dbLock) lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
@ -729,11 +732,10 @@ namespace OpenSim.Data.MySQL
{ {
while (reader.Read()) while (reader.Read())
{ {
int rev = Convert.ToInt32(reader["Revision"]); rev = Convert.ToInt32(reader["Revision"]);
if ((reader["Heightfield"] != DBNull.Value)) if ((reader["Heightfield"] != DBNull.Value))
{ {
byte[] blob = (byte[])reader["Heightfield"]; blob = (byte[])reader["Heightfield"];
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
} }
} }
} }
@ -742,12 +744,17 @@ namespace OpenSim.Data.MySQL
} }
} }
if(blob != null)
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
return terrData; return terrData;
} }
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{ {
TerrainData terrData = null; TerrainData terrData = null;
byte[] blob = null;
int rev = 0;
lock (m_dbLock) lock (m_dbLock)
{ {
@ -765,11 +772,10 @@ namespace OpenSim.Data.MySQL
{ {
while (reader.Read()) while (reader.Read())
{ {
int rev = Convert.ToInt32(reader["Revision"]); rev = Convert.ToInt32(reader["Revision"]);
if ((reader["Heightfield"] != DBNull.Value)) if ((reader["Heightfield"] != DBNull.Value))
{ {
byte[] blob = (byte[])reader["Heightfield"]; blob = (byte[])reader["Heightfield"];
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
} }
} }
} }
@ -777,6 +783,8 @@ namespace OpenSim.Data.MySQL
dbcon.Close(); dbcon.Close();
} }
} }
if(blob != null)
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
return terrData; return terrData;
} }