diff options
author | UbitUmarov | 2017-05-07 22:22:28 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-07 22:22:28 +0100 |
commit | 8ef43e5fb3c8596cb793a38f9b5a2611bdb80668 (patch) | |
tree | 2528814a784be4d2fb331c8d8beda6f3d85464af /OpenSim | |
parent | let StreamReader be in using statements (diff) | |
download | opensim-SC-8ef43e5fb3c8596cb793a38f9b5a2611bdb80668.zip opensim-SC-8ef43e5fb3c8596cb793a38f9b5a2611bdb80668.tar.gz opensim-SC-8ef43e5fb3c8596cb793a38f9b5a2611bdb80668.tar.bz2 opensim-SC-8ef43e5fb3c8596cb793a38f9b5a2611bdb80668.tar.xz |
take more heavy work out of opened dbconn sections
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 4766372..e754522 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -607,6 +607,10 @@ namespace OpenSim.Data.MySQL | |||
607 | { | 607 | { |
608 | m_log.Info("[REGION DB]: Storing terrain"); | 608 | m_log.Info("[REGION DB]: Storing terrain"); |
609 | 609 | ||
610 | int terrainDBRevision; | ||
611 | Array terrainDBblob; | ||
612 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
613 | |||
610 | lock (m_dbLock) | 614 | lock (m_dbLock) |
611 | { | 615 | { |
612 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 616 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
@@ -626,10 +630,6 @@ namespace OpenSim.Data.MySQL | |||
626 | "Revision, Heightfield) values (?RegionUUID, " + | 630 | "Revision, Heightfield) values (?RegionUUID, " + |
627 | "?Revision, ?Heightfield)"; | 631 | "?Revision, ?Heightfield)"; |
628 | 632 | ||
629 | int terrainDBRevision; | ||
630 | Array terrainDBblob; | ||
631 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
632 | |||
633 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | 633 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
634 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); | 634 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); |
635 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); | 635 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); |
@@ -655,6 +655,10 @@ namespace OpenSim.Data.MySQL | |||
655 | { | 655 | { |
656 | m_log.Info("[REGION DB]: Storing Baked terrain"); | 656 | m_log.Info("[REGION DB]: Storing Baked terrain"); |
657 | 657 | ||
658 | int terrainDBRevision; | ||
659 | Array terrainDBblob; | ||
660 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
661 | |||
658 | lock (m_dbLock) | 662 | lock (m_dbLock) |
659 | { | 663 | { |
660 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 664 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
@@ -674,10 +678,6 @@ namespace OpenSim.Data.MySQL | |||
674 | "Revision, Heightfield) values (?RegionUUID, " + | 678 | "Revision, Heightfield) values (?RegionUUID, " + |
675 | "?Revision, ?Heightfield)"; | 679 | "?Revision, ?Heightfield)"; |
676 | 680 | ||
677 | int terrainDBRevision; | ||
678 | Array terrainDBblob; | ||
679 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
680 | |||
681 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | 681 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
682 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); | 682 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); |
683 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); | 683 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); |
@@ -711,9 +711,12 @@ namespace OpenSim.Data.MySQL | |||
711 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | 711 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) |
712 | { | 712 | { |
713 | TerrainData terrData = null; | 713 | TerrainData terrData = null; |
714 | byte[] blob = null; | ||
715 | int rev = 0; | ||
714 | 716 | ||
715 | lock (m_dbLock) | 717 | lock (m_dbLock) |
716 | { | 718 | { |
719 | |||
717 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 720 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
718 | { | 721 | { |
719 | dbcon.Open(); | 722 | dbcon.Open(); |
@@ -729,11 +732,10 @@ namespace OpenSim.Data.MySQL | |||
729 | { | 732 | { |
730 | while (reader.Read()) | 733 | while (reader.Read()) |
731 | { | 734 | { |
732 | int rev = Convert.ToInt32(reader["Revision"]); | 735 | rev = Convert.ToInt32(reader["Revision"]); |
733 | if ((reader["Heightfield"] != DBNull.Value)) | 736 | if ((reader["Heightfield"] != DBNull.Value)) |
734 | { | 737 | { |
735 | byte[] blob = (byte[])reader["Heightfield"]; | 738 | blob = (byte[])reader["Heightfield"]; |
736 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
737 | } | 739 | } |
738 | } | 740 | } |
739 | } | 741 | } |
@@ -742,12 +744,17 @@ namespace OpenSim.Data.MySQL | |||
742 | } | 744 | } |
743 | } | 745 | } |
744 | 746 | ||
747 | if(blob != null) | ||
748 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
749 | |||
745 | return terrData; | 750 | return terrData; |
746 | } | 751 | } |
747 | 752 | ||
748 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | 753 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) |
749 | { | 754 | { |
750 | TerrainData terrData = null; | 755 | TerrainData terrData = null; |
756 | byte[] blob = null; | ||
757 | int rev = 0; | ||
751 | 758 | ||
752 | lock (m_dbLock) | 759 | lock (m_dbLock) |
753 | { | 760 | { |
@@ -765,11 +772,10 @@ namespace OpenSim.Data.MySQL | |||
765 | { | 772 | { |
766 | while (reader.Read()) | 773 | while (reader.Read()) |
767 | { | 774 | { |
768 | int rev = Convert.ToInt32(reader["Revision"]); | 775 | rev = Convert.ToInt32(reader["Revision"]); |
769 | if ((reader["Heightfield"] != DBNull.Value)) | 776 | if ((reader["Heightfield"] != DBNull.Value)) |
770 | { | 777 | { |
771 | byte[] blob = (byte[])reader["Heightfield"]; | 778 | blob = (byte[])reader["Heightfield"]; |
772 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
773 | } | 779 | } |
774 | } | 780 | } |
775 | } | 781 | } |
@@ -777,6 +783,8 @@ namespace OpenSim.Data.MySQL | |||
777 | dbcon.Close(); | 783 | dbcon.Close(); |
778 | } | 784 | } |
779 | } | 785 | } |
786 | if(blob != null) | ||
787 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
780 | 788 | ||
781 | return terrData; | 789 | return terrData; |
782 | } | 790 | } |