From d9038e650a8cbacc3463c6989b5af1e8429a1e8b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 6 May 2017 01:25:54 +0100 Subject: [PATCH] MySQLConnector is not a MS product --- OpenSim/Data/MySQL/MySQLAssetData.cs | 7 +++++ OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 2 ++ OpenSim/Data/MySQL/MySQLEstateData.cs | 11 +++++-- OpenSim/Data/MySQL/MySQLFSAssetData.cs | 11 +++++-- OpenSim/Data/MySQL/MySQLFramework.cs | 9 ++++-- .../Data/MySQL/MySQLGenericTableHandler.cs | 12 +++++--- OpenSim/Data/MySQL/MySQLInventoryData.cs | 15 ++++++++++ OpenSim/Data/MySQL/MySQLRegionData.cs | 3 ++ OpenSim/Data/MySQL/MySQLSimulationData.cs | 30 ++++++++++++++++++- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 16 ++++++++++ OpenSim/Data/MySQL/MySQLXAssetData.cs | 7 ++++- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 1 - 12 files changed, 110 insertions(+), 14 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index f16cd913e7..27cc0ba5bd 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); Migration m = new Migration(dbcon, Assembly, "AssetStore"); m.Update(); + dbcon.Close(); } } @@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); } } + dbcon.Close(); } return asset; @@ -209,6 +211,7 @@ namespace OpenSim.Data.MySQL return false; } } + dbcon.Close(); } } @@ -238,6 +241,7 @@ namespace OpenSim.Data.MySQL e); } } + dbcon.Close(); } } @@ -270,6 +274,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } bool[] results = new bool[uuids.Length]; @@ -334,6 +339,7 @@ namespace OpenSim.Data.MySQL e); } } + dbcon.Close(); } return retList; @@ -350,6 +356,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?id", id); cmd.ExecuteNonQuery(); } + dbcon.Close(); } return true; diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index af6be75bf7..5030c1d0f9 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -59,6 +59,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); Migration m = new Migration(dbcon, Assembly, "AuthStore"); m.Update(); + dbcon.Close(); } } @@ -99,6 +100,7 @@ namespace OpenSim.Data.MySQL return null; } } + dbcon.Close(); } } diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index a5c8d24de5..12593f6c95 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -171,12 +171,13 @@ namespace OpenSim.Data.MySQL } } } - if (!found && create) { DoCreate(es); LinkRegion(regionID, (int)es.EstateID); } + cmd.Connection = null; + dbcon.Close(); } LoadBanList(es); @@ -231,6 +232,7 @@ namespace OpenSim.Data.MySQL es.Save(); } + dbcon.Close(); } } @@ -263,6 +265,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } SaveBanList(es); @@ -300,6 +303,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -329,6 +333,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); } } + dbcon.Close(); } } @@ -358,6 +363,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); } } + dbcon.Close(); } } @@ -383,6 +389,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } return uuids.ToArray(); @@ -437,7 +444,6 @@ namespace OpenSim.Data.MySQL reader.Close(); } } - dbcon.Close(); } @@ -466,7 +472,6 @@ namespace OpenSim.Data.MySQL reader.Close(); } } - dbcon.Close(); } diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs index 2837ce31be..0918596ca8 100644 --- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs @@ -121,9 +121,13 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { + cmd.Connection = null; + conn.Close(); m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString()); return false; } + cmd.Connection = null; + conn.Close(); } return true; @@ -175,7 +179,7 @@ namespace OpenSim.Data.MySQL UpdateAccessTime(id, AccessTime); } } - + conn.Close(); } return meta; @@ -206,6 +210,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?id", AssetID); cmd.ExecuteNonQuery(); } + conn.Close(); } } @@ -299,6 +304,7 @@ namespace OpenSim.Data.MySQL } } } + conn.Close(); } for (int i = 0; i < uuids.Length; i++) @@ -333,6 +339,7 @@ namespace OpenSim.Data.MySQL count = Convert.ToInt32(reader["count"]); } } + conn.Close(); } return count; @@ -413,8 +420,8 @@ namespace OpenSim.Data.MySQL imported++; } } - } + importConn.Close(); } MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 93662db875..98106f0057 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -74,7 +74,9 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - return ExecuteNonQueryWithConnection(cmd, dbcon); + int ret = ExecuteNonQueryWithConnection(cmd, dbcon); + dbcon.Close(); + return ret; } } else @@ -97,12 +99,15 @@ namespace OpenSim.Data.MySQL try { - return cmd.ExecuteNonQuery(); + int ret = cmd.ExecuteNonQuery(); + cmd.Connection = null; + return ret; } catch (Exception e) { m_log.Error(e.Message, e); m_log.Error(Environment.StackTrace.ToString()); + cmd.Connection = null; return 0; } } diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index bd8bbd5920..9bd3c0cc26 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -160,8 +160,9 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - - return DoQueryWithConnection(cmd, dbcon); + T[] ret = DoQueryWithConnection(cmd, dbcon); + dbcon.Close(); + return ret; } } else @@ -243,7 +244,7 @@ namespace OpenSim.Data.MySQL result.Add(row); } } - + cmd.Connection = null; return result.ToArray(); } @@ -402,7 +403,10 @@ namespace OpenSim.Data.MySQL dbcon.Open(); cmd.Connection = dbcon; - return cmd.ExecuteScalar(); + Object ret = cmd.ExecuteScalar(); + cmd.Connection = null; + dbcon.Close(); + return ret; } } else diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 382d4a5c33..3216544e54 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); Migration m = new Migration(dbcon, assem, "InventoryStore"); m.Update(); + dbcon.Close(); } } @@ -133,6 +134,7 @@ namespace OpenSim.Data.MySQL return items; } } + dbcon.Close(); } } } @@ -173,6 +175,7 @@ namespace OpenSim.Data.MySQL return items; } } + dbcon.Close(); } } } @@ -224,6 +227,7 @@ namespace OpenSim.Data.MySQL return rootFolder; } } + dbcon.Close(); } } } @@ -264,6 +268,7 @@ namespace OpenSim.Data.MySQL return items; } } + dbcon.Close(); } } } @@ -355,6 +360,7 @@ namespace OpenSim.Data.MySQL return item; } } + dbcon.Close(); } } } @@ -420,6 +426,7 @@ namespace OpenSim.Data.MySQL return folder; } } + dbcon.Close(); } } } @@ -497,6 +504,8 @@ namespace OpenSim.Data.MySQL result.Dispose(); } + dbcon.Close(); + using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon)) { result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); @@ -540,6 +549,7 @@ namespace OpenSim.Data.MySQL lock (m_dbLock) cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (MySqlException e) @@ -600,6 +610,7 @@ namespace OpenSim.Data.MySQL m_log.Error(e.ToString()); } } + dbcon.Close(); } } @@ -643,6 +654,7 @@ namespace OpenSim.Data.MySQL m_log.Error(e.ToString()); } } + dbcon.Close(); } } @@ -806,6 +818,7 @@ namespace OpenSim.Data.MySQL lock (m_dbLock) cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (MySqlException e) @@ -833,6 +846,7 @@ namespace OpenSim.Data.MySQL lock (m_dbLock) cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (MySqlException e) @@ -889,6 +903,7 @@ namespace OpenSim.Data.MySQL return list; } } + dbcon.Close(); } } catch (Exception e) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 0e55285451..46df421352 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); Migration m = new Migration(dbcon, Assembly, "GridStore"); m.Update(); + dbcon.Close(); } } @@ -260,6 +261,8 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } } + cmd.Connection = null; + dbcon.Close(); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 5740b916db..8d1a4a5713 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -88,6 +88,7 @@ namespace OpenSim.Data.MySQL // Migration m = new Migration(dbcon, Assembly, "RegionStore"); m.Update(); + dbcon.Close(); } } @@ -334,6 +335,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } } @@ -372,6 +374,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } } @@ -411,6 +414,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } } @@ -460,6 +464,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -535,6 +540,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -580,6 +586,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } prim.Inventory.RestoreInventoryItems(inventory); @@ -634,6 +641,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } }); @@ -681,6 +689,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } }); @@ -727,6 +736,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -762,6 +772,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -783,6 +794,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } } @@ -842,6 +854,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); } } + dbcon.Close(); } } } @@ -939,6 +952,7 @@ namespace OpenSim.Data.MySQL nWP.valid = true; } } + dbcon.Close(); } return nWP; @@ -976,6 +990,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -1084,6 +1099,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } @@ -1099,6 +1115,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); ExecuteNonQuery(cmd); } + dbcon.Close(); } } @@ -1127,6 +1144,7 @@ namespace OpenSim.Data.MySQL return Convert.ToString(result["llsd_settings"]); } } + dbcon.Close(); } } @@ -1145,6 +1163,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } + dbcon.Close(); } } @@ -1160,6 +1179,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); ExecuteNonQuery(cmd); } + dbcon.Close(); } } #endregion @@ -1212,7 +1232,7 @@ namespace OpenSim.Data.MySQL FillRegionSettingsCommand(cmd, rs); ExecuteNonQuery(cmd); } - + dbcon.Close(); SaveSpawnPoints(rs); } } @@ -1259,6 +1279,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -2123,6 +2144,7 @@ namespace OpenSim.Data.MySQL ExecuteNonQuery(cmd); } } + dbcon.Close(); } } } @@ -2152,6 +2174,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } @@ -2187,6 +2210,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } } @@ -2221,6 +2245,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); } } + dbcon.Close(); } } } @@ -2240,6 +2265,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } @@ -2257,6 +2283,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } @@ -2280,6 +2307,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } return ret; diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 8af2a3ef29..dfc3711674 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -69,6 +69,7 @@ namespace OpenSim.Data.MySQL Migration m = new Migration(dbcon, Assembly, "UserProfiles"); m.Update(); + dbcon.Close(); } } #endregion Member Functions @@ -121,6 +122,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } return data; } @@ -228,6 +230,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -258,6 +261,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -352,6 +356,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -474,6 +479,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -504,6 +510,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -548,6 +555,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -596,6 +604,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -719,6 +728,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -759,6 +769,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -884,6 +895,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -939,6 +951,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -975,6 +988,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) @@ -1035,6 +1049,7 @@ namespace OpenSim.Data.MySQL } } } + dbcon.Close(); } } catch (Exception e) @@ -1072,6 +1087,7 @@ namespace OpenSim.Data.MySQL cmd.ExecuteNonQuery(); } + dbcon.Close(); } } catch (Exception e) diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 2c6acdef32..2ef7f8fc79 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); Migration m = new Migration(dbcon, Assembly, "XAssetStore"); m.Update(); + dbcon.Close(); } } @@ -184,6 +185,7 @@ namespace OpenSim.Data.MySQL m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); } } + dbcon.Close(); } return asset; @@ -303,6 +305,7 @@ namespace OpenSim.Data.MySQL transaction.Commit(); } + dbcon.Close(); } } @@ -344,6 +347,7 @@ namespace OpenSim.Data.MySQL "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", assetMetadata.ID, assetMetadata.Name); } + dbcon.Close(); } } @@ -474,6 +478,7 @@ namespace OpenSim.Data.MySQL m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); } } + dbcon.Close(); } return retList; @@ -492,9 +497,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?ID", id); cmd.ExecuteNonQuery(); } - // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we // keep a reference count (?) + dbcon.Close(); } return true; diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 4e41fec9cd..501999425d 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -328,7 +328,6 @@ namespace OpenSim.Data.MySQL { return false; } - cmd.Dispose(); } dbcon.Close();