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/SQLite/SQLiteAssetData.cs | 9 ++++++- OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 33 ++++++++++++++++++------ OpenSim/Data/SQLite/SQLiteRegionData.cs | 40 +++++++++++++++++++++++++++++ OpenSim/Data/SQLite/SQLiteUserData.cs | 25 +++++++++++++++++- 4 files changed, 97 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/SQLite') 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, -- cgit v1.1