From 1c08f46ec3397f4e4fd5897107c0df89bec70d84 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Thu, 18 Sep 2008 20:10:09 +0000 Subject: - Add Dispose method to IRegionDataStore - Add necessary dummy Dispose-methods where they are missing - Implement the SQLite Dispose-methods (currently only used for unit tests, in the next commit) --- OpenSim/Data/MSSQL/MSSQLRegionData.cs | 5 +++ OpenSim/Data/MySQL/MySQLRegionData.cs | 2 ++ OpenSim/Data/NHibernate/NHibernateRegionData.cs | 2 ++ OpenSim/Data/Null/NullDataStore.cs | 4 +++ OpenSim/Data/SQLite/SQLiteAssetData.cs | 9 ++++- OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 33 +++++++++++++----- OpenSim/Data/SQLite/SQLiteRegionData.cs | 40 ++++++++++++++++++++++ OpenSim/Data/SQLite/SQLiteUserData.cs | 25 +++++++++++++- .../Environment/Interfaces/IRegionDataStore.cs | 5 +++ 9 files changed, 115 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 8b808d3..ae94252 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs @@ -156,6 +156,11 @@ namespace OpenSim.Data.MSSQL //After this we have a empty fully configured DataSet. } + + /// + /// Dispose the database + /// + public void Dispose() {} /// /// Loads the objects present in the region. diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9c36d49..284c970 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -203,6 +203,8 @@ namespace OpenSim.Data.MySQL } } + public void Dispose() {} + /// /// Get the wait_timeout value for our connection /// diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 07bf05c..ecb29fe 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -105,6 +105,8 @@ namespace OpenSim.Data.NHibernate * **********************************************************************/ + public void Dispose() {} + public void StoreRegionSettings(RegionSettings rs) { } diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs index aea03d6..94ad4af 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullDataStore.cs @@ -43,6 +43,10 @@ namespace OpenSim.Data.Null return; } + public void Dispose() + { + } + public void StoreRegionSettings(RegionSettings rs) { } diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 8b14f09..17af2b0 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -56,7 +56,14 @@ namespace OpenSim.Data.SQLite private SqliteConnection m_conn; - override public void Dispose() { } + override public void Dispose() + { + if (m_conn != null) + { + m_conn.Close(); + m_conn = null; + } + } /// /// diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index ca7e612..49d351a 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs @@ -46,6 +46,7 @@ namespace OpenSim.Data.SQLite private const string invItemsSelect = "select * from inventoryitems"; private const string invFoldersSelect = "select * from inventoryfolders"; + private SqliteConnection conn; private DataSet ds; private SqliteDataAdapter invItemsDa; private SqliteDataAdapter invFoldersDa; @@ -71,7 +72,7 @@ namespace OpenSim.Data.SQLite dbconnect = "URI=file:inventoryStore.db,version=3"; } m_log.Info("[INVENTORY DB]: Sqlite - connecting: " + dbconnect); - SqliteConnection conn = new SqliteConnection(dbconnect); + conn = new SqliteConnection(dbconnect); conn.Open(); @@ -102,6 +103,29 @@ namespace OpenSim.Data.SQLite } /// + /// Closes the inventory interface + /// + public void Dispose() + { + if(conn != null) { + conn.Close(); + conn = null; + } + if(invItemsDa != null) { + invItemsDa.Dispose(); + invItemsDa = null; + } + if(invFoldersDa != null) { + invFoldersDa.Dispose(); + invFoldersDa = null; + } + if(ds != null) { + ds.Dispose(); + ds = null; + } + } + + /// /// /// /// @@ -278,13 +302,6 @@ namespace OpenSim.Data.SQLite } /// - /// Closes the inventory interface - /// - public void Dispose() - { - } - - /// /// The name of this DB provider /// /// Name of DB provider diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 36b3d2f..f71535f 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -203,6 +203,46 @@ namespace OpenSim.Data.SQLite } } + public void Dispose() + { + if(m_conn != null) { + m_conn.Close(); + m_conn = null; + } + if(ds != null) { + ds.Dispose(); + ds = null; + } + if(primDa != null) { + primDa.Dispose(); + primDa = null; + } + if(shapeDa != null) { + shapeDa.Dispose(); + shapeDa = null; + } + if(itemsDa != null) { + itemsDa.Dispose(); + itemsDa = null; + } + if(terrainDa != null) { + terrainDa.Dispose(); + terrainDa = null; + } + if(landDa != null) { + landDa.Dispose(); + landDa = null; + } + if(landAccessListDa != null) { + landAccessListDa.Dispose(); + landAccessListDa = null; + } + if(regionSettingsDa != null) { + regionSettingsDa.Dispose(); + regionSettingsDa = null; + } + } + public void StoreRegionSettings(RegionSettings rs) { lock (ds) diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 2c1e3c3..a238ebf 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -122,7 +122,30 @@ namespace OpenSim.Data.SQLite return; } - public override void Dispose () {} + public override void Dispose () + { + if(g_conn != null) { + g_conn.Close(); + g_conn = null; + } + if(ds != null) { + ds.Dispose(); + ds = null; + } + if(da != null) { + da.Dispose(); + da = null; + } + if(daf != null) { + daf.Dispose(); + daf = null; + } + if(dua != null) { + dua.Dispose(); + dua = null; + } + aplist = null; + } /// /// see IUserDataPlugin, diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 5f10ec5..0ee4933 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -42,6 +42,11 @@ namespace OpenSim.Region.Environment.Interfaces void Initialise(string filename); /// + /// Dispose the database + /// + void Dispose(); + + /// /// Stores all object's details apart from inventory /// /// -- cgit v1.1