diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index 0e3a1729b5..5b76e0a5b8 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -787,7 +787,7 @@ namespace OpenSim.Groups
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
// Update the founder with new group information.
- SendAgentGroupDataUpdate(remoteClient, false);
+ SendAgentGroupDataUpdate(remoteClient, true);
}
else
remoteClient.SendCreateGroupReply(groupID, false, reason);
diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
index af007709be..51f3ec15e0 100644
--- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
@@ -115,9 +115,10 @@ namespace OpenSim.Groups
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
+
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 598e7a5a9d..8502bb5bda 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -91,9 +91,10 @@ namespace OpenSim.Groups
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
+
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 062a842748..e73cf9eca0 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -362,8 +362,6 @@ namespace OpenSim.Capabilities.Handlers
{
// Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
- imgstream = new MemoryStream();
-
// Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{
@@ -404,10 +402,7 @@ namespace OpenSim.Capabilities.Handlers
if(managedImage != null)
managedImage.Clear();
if (imgstream != null)
- {
- imgstream.Close();
imgstream.Dispose();
- }
}
return data;
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
index d5df7a29bd..c339ec5d7e 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
@@ -368,9 +368,6 @@ namespace OpenSim.Capabilities.Handlers
try
{
// Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
-
- imgstream = new MemoryStream();
-
// Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
{
@@ -412,10 +409,7 @@ namespace OpenSim.Capabilities.Handlers
managedImage.Clear();
if (imgstream != null)
- {
- imgstream.Close();
imgstream.Dispose();
- }
}
return data;
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index f16cd913e7..8569c903a6 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;
@@ -156,28 +158,27 @@ namespace OpenSim.Data.MySQL
/// On failure : Throw an exception and attempt to reconnect to database
override public bool StoreAsset(AssetBase asset)
{
+ string assetName = asset.Name;
+ if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
+ {
+ assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
+ m_log.WarnFormat(
+ "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Name, asset.ID, asset.Name.Length, assetName.Length);
+ }
+
+ string assetDescription = asset.Description;
+ if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
+ {
+ assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
+ m_log.WarnFormat(
+ "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
+ }
+
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
-
- string assetName = asset.Name;
- if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
- {
- assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
- m_log.WarnFormat(
- "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
- asset.Name, asset.ID, asset.Name.Length, assetName.Length);
- }
-
- string assetDescription = asset.Description;
- if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
- {
- assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
- m_log.WarnFormat(
- "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
- asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
- }
-
using (MySqlCommand cmd =
new MySqlCommand(
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
@@ -200,15 +201,17 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
cmd.Parameters.AddWithValue("?data", asset.Data);
cmd.ExecuteNonQuery();
+ dbcon.Close();
return true;
}
catch (Exception e)
{
m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
asset.FullID, asset.Name, e.Message);
+ dbcon.Close();
return false;
}
- }
+ }
}
}
@@ -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..fef582e809 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();
}
}
@@ -76,27 +77,30 @@ namespace OpenSim.Data.MySQL
{
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
- IDataReader result = cmd.ExecuteReader();
-
- if (result.Read())
+ using(IDataReader result = cmd.ExecuteReader())
{
- ret.PrincipalID = principalID;
-
- CheckColumnNames(result);
-
- foreach (string s in m_ColumnNames)
+ if(result.Read())
{
- if (s == "UUID")
- continue;
+ ret.PrincipalID = principalID;
- ret.Data[s] = result[s].ToString();
+ CheckColumnNames(result);
+
+ foreach(string s in m_ColumnNames)
+ {
+ if(s == "UUID")
+ continue;
+
+ ret.Data[s] = result[s].ToString();
+ }
+
+ dbcon.Close();
+ return ret;
+ }
+ else
+ {
+ dbcon.Close();
+ return null;
}
-
- return ret;
- }
- else
- {
- return null;
}
}
}
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index a5c8d24de5..eeedf02b29 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL
Migration m = new Migration(dbcon, Assembly, "EstateStore");
m.Update();
+ dbcon.Close();
Type t = typeof(EstateSettings);
m_Fields = t.GetFields(BindingFlags.NonPublic |
@@ -143,7 +144,6 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
-
cmd.Connection = dbcon;
bool found = false;
@@ -171,6 +171,8 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
+ cmd.Connection = null;
if (!found && create)
{
@@ -231,6 +233,7 @@ namespace OpenSim.Data.MySQL
es.Save();
}
+ dbcon.Close();
}
}
@@ -263,6 +266,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
SaveBanList(es);
@@ -300,6 +304,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -329,6 +334,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear();
}
}
+ dbcon.Close();
}
}
@@ -358,6 +364,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear();
}
}
+ dbcon.Close();
}
}
@@ -383,6 +390,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
return uuids.ToArray();
@@ -437,7 +445,6 @@ namespace OpenSim.Data.MySQL
reader.Close();
}
}
-
dbcon.Close();
}
@@ -466,7 +473,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..6c486077d3 100644
--- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
conn.Open();
Migration m = new Migration(conn, Assembly, "FSAssetStore");
m.Update();
+ conn.Close();
}
}
catch (MySqlException e)
@@ -121,9 +122,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;
}
+ conn.Close();
+ cmd.Connection = null;
}
return true;
@@ -175,7 +180,7 @@ namespace OpenSim.Data.MySQL
UpdateAccessTime(id, AccessTime);
}
}
-
+ conn.Close();
}
return meta;
@@ -206,6 +211,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?id", AssetID);
cmd.ExecuteNonQuery();
}
+ conn.Close();
}
}
@@ -299,6 +305,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ conn.Close();
}
for (int i = 0; i < uuids.Length; i++)
@@ -333,6 +340,7 @@ namespace OpenSim.Data.MySQL
count = Convert.ToInt32(reader["count"]);
}
}
+ conn.Close();
}
return count;
@@ -413,8 +421,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..cc787ccde8 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();
}
}
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
items.Add(item);
}
+ dbcon.Close();
return items;
}
}
@@ -170,6 +172,7 @@ namespace OpenSim.Data.MySQL
while (reader.Read())
items.Add(readInventoryFolder(reader));
+ dbcon.Close();
return items;
}
}
@@ -221,6 +224,7 @@ namespace OpenSim.Data.MySQL
if (items.Count > 0)
rootFolder = items[0];
+ dbcon.Close();
return rootFolder;
}
}
@@ -261,6 +265,7 @@ namespace OpenSim.Data.MySQL
while (reader.Read())
items.Add(readInventoryFolder(reader));
+ dbcon.Close();
return items;
}
}
@@ -352,6 +357,7 @@ namespace OpenSim.Data.MySQL
if (reader.Read())
item = readInventoryItem(reader);
+ dbcon.Close();
return item;
}
}
@@ -417,6 +423,7 @@ namespace OpenSim.Data.MySQL
if (reader.Read())
folder = readInventoryFolder(reader);
+ dbcon.Close();
return folder;
}
}
@@ -504,6 +511,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock)
result.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (MySqlException e)
@@ -540,6 +548,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock)
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (MySqlException e)
@@ -600,6 +609,7 @@ namespace OpenSim.Data.MySQL
m_log.Error(e.ToString());
}
}
+ dbcon.Close();
}
}
@@ -643,6 +653,7 @@ namespace OpenSim.Data.MySQL
m_log.Error(e.ToString());
}
}
+ dbcon.Close();
}
}
@@ -806,6 +817,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock)
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (MySqlException e)
@@ -833,6 +845,7 @@ namespace OpenSim.Data.MySQL
lock (m_dbLock)
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (MySqlException e)
@@ -886,6 +899,7 @@ namespace OpenSim.Data.MySQL
if (item != null)
list.Add(item);
}
+ dbcon.Close();
return list;
}
}
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..47663722fd 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();
}
}
@@ -261,6 +262,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
}
+ dbcon.Close();
}
}
}
@@ -300,6 +302,7 @@ namespace OpenSim.Data.MySQL
cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
@@ -334,6 +337,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
}
@@ -372,6 +376,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
}
@@ -411,6 +416,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
}
@@ -460,6 +466,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -535,6 +542,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -580,6 +588,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
prim.Inventory.RestoreInventoryItems(inventory);
@@ -634,6 +643,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
});
@@ -681,6 +691,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
});
@@ -727,6 +738,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -762,6 +774,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -783,6 +796,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
}
@@ -842,6 +856,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear();
}
}
+ dbcon.Close();
}
}
}
@@ -863,82 +878,85 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
+ using(IDataReader result = ExecuteReader(cmd))
{
- //No result, so store our default windlight profile and return it
- nWP.regionID = regionUUID;
-// StoreRegionWindlightSettings(nWP);
- return nWP;
- }
- else
- {
- nWP.regionID = DBGuid.FromDB(result["region_id"]);
- nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
- nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
- nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
- nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
- nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
- nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
- nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
- nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
- nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
- nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
- nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
- nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
- nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
- nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
- nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
- nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
- nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
- UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
- nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
- nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
- nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
- nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
- nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
- nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
- nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
- nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
- nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
- nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
- nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
- nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
- nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
- nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
- nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
- nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
- nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
- nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
- nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
- nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
- nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
- nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
- nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
- nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
- nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
- nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
- nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
- nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
- nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
- nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
- nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
- nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
- nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
- nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
- nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
- nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
- nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
- nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
- nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
- nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
- nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
- nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
- nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
- nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
- nWP.valid = true;
+ if(!result.Read())
+ {
+ //No result, so store our default windlight profile and return it
+ nWP.regionID = regionUUID;
+ // StoreRegionWindlightSettings(nWP);
+ return nWP;
+ }
+ else
+ {
+ nWP.regionID = DBGuid.FromDB(result["region_id"]);
+ nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
+ nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
+ nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
+ nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
+ nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
+ nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
+ nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
+ nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
+ nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
+ nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
+ nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
+ nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
+ nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
+ nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
+ nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
+ nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
+ nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
+ UUID.TryParse(result["normal_map_texture"].ToString(),out nWP.normalMapTexture);
+ nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
+ nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
+ nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
+ nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
+ nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
+ nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
+ nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
+ nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
+ nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
+ nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
+ nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
+ nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
+ nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
+ nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
+ nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
+ nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
+ nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
+ nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
+ nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
+ nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
+ nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
+ nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
+ nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
+ nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
+ nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
+ nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
+ nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
+ nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
+ nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
+ nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
+ nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
+ nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
+ nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
+ nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
+ nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
+ nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
+ nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
+ nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
+ nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
+ nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
+ nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
+ nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
+ nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
+ nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
+ nWP.valid = true;
+ }
}
}
+ dbcon.Close();
}
return nWP;
@@ -947,6 +965,7 @@ namespace OpenSim.Data.MySQL
public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
{
RegionSettings rs = null;
+ bool needStore = false;
lock (m_dbLock)
{
@@ -972,13 +991,17 @@ namespace OpenSim.Data.MySQL
rs.RegionUUID = regionUUID;
rs.OnSave += StoreRegionSettings;
- StoreRegionSettings(rs);
+ needStore = true;
}
}
}
+ dbcon.Close();
}
}
+ if(needStore)
+ StoreRegionSettings(rs);
+
LoadSpawnPoints(rs);
return rs;
@@ -992,31 +1015,32 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = dbcon.CreateCommand())
{
- cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
- cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
- cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
- cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
- cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
- cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
- cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
- cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
- cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
- cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
- cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
- cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
- cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
- cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
- cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
- cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
- cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
- cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
- cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
- cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
- cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
- cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
- cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
- cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
- cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
+ cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "
+ + "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "
+ + "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "
+ + "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "
+ + "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "
+ + "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "
+ + "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "
+ + "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "
+ + "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "
+ + "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "
+ + "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "
+ + "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "
+ + "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "
+ + "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "
+ + "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "
+ + "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "
+ + "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "
+ + "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "
+ + "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "
+ + "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "
+ + "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "
+ + "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "
+ + "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "
+ + "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "
+ + "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"
+ ;
cmd.Parameters.AddWithValue("region_id", wl.regionID);
cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
@@ -1084,6 +1108,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
@@ -1099,6 +1124,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
@@ -1117,14 +1143,19 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
+ using(IDataReader result = ExecuteReader(cmd))
{
- return String.Empty;
- }
- else
- {
- return Convert.ToString(result["llsd_settings"]);
+ if(!result.Read())
+ {
+ dbcon.Close();
+ return String.Empty;
+ }
+ else
+ {
+ string ret = Convert.ToString(result["llsd_settings"]);
+ dbcon.Close();
+ return ret;
+ }
}
}
}
@@ -1145,6 +1176,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
@@ -1160,6 +1192,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
ExecuteNonQuery(cmd);
}
+ dbcon.Close();
}
}
#endregion
@@ -1212,7 +1245,7 @@ namespace OpenSim.Data.MySQL
FillRegionSettingsCommand(cmd, rs);
ExecuteNonQuery(cmd);
}
-
+ dbcon.Close();
SaveSpawnPoints(rs);
}
}
@@ -1259,6 +1292,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -2123,6 +2157,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
}
}
+ dbcon.Close();
}
}
}
@@ -2152,6 +2187,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
@@ -2187,6 +2223,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
}
@@ -2221,6 +2258,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear();
}
}
+ dbcon.Close();
}
}
}
@@ -2240,6 +2278,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
@@ -2257,6 +2296,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
@@ -2280,6 +2320,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..c98e0173a2 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
@@ -89,7 +90,7 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
{
- string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
+ const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
{
@@ -121,58 +122,58 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
return data;
}
public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
{
- string query = string.Empty;
-
-
- query += "INSERT INTO classifieds (";
- query += "`classifieduuid`,";
- query += "`creatoruuid`,";
- query += "`creationdate`,";
- query += "`expirationdate`,";
- query += "`category`,";
- query += "`name`,";
- query += "`description`,";
- query += "`parceluuid`,";
- query += "`parentestate`,";
- query += "`snapshotuuid`,";
- query += "`simname`,";
- query += "`posglobal`,";
- query += "`parcelname`,";
- query += "`classifiedflags`,";
- query += "`priceforlisting`) ";
- query += "VALUES (";
- query += "?ClassifiedId,";
- query += "?CreatorId,";
- query += "?CreatedDate,";
- query += "?ExpirationDate,";
- query += "?Category,";
- query += "?Name,";
- query += "?Description,";
- query += "?ParcelId,";
- query += "?ParentEstate,";
- query += "?SnapshotId,";
- query += "?SimName,";
- query += "?GlobalPos,";
- query += "?ParcelName,";
- query += "?Flags,";
- query += "?ListingPrice ) ";
- query += "ON DUPLICATE KEY UPDATE ";
- query += "category=?Category, ";
- query += "expirationdate=?ExpirationDate, ";
- query += "name=?Name, ";
- query += "description=?Description, ";
- query += "parentestate=?ParentEstate, ";
- query += "posglobal=?GlobalPos, ";
- query += "parcelname=?ParcelName, ";
- query += "classifiedflags=?Flags, ";
- query += "priceforlisting=?ListingPrice, ";
- query += "snapshotuuid=?SnapshotId";
+ const string query =
+ "INSERT INTO classifieds ("
+ + "`classifieduuid`,"
+ + "`creatoruuid`,"
+ + "`creationdate`,"
+ + "`expirationdate`,"
+ + "`category`,"
+ + "`name`,"
+ + "`description`,"
+ + "`parceluuid`,"
+ + "`parentestate`,"
+ + "`snapshotuuid`,"
+ + "`simname`,"
+ + "`posglobal`,"
+ + "`parcelname`,"
+ + "`classifiedflags`,"
+ + "`priceforlisting`) "
+ + "VALUES ("
+ + "?ClassifiedId,"
+ + "?CreatorId,"
+ + "?CreatedDate,"
+ + "?ExpirationDate,"
+ + "?Category,"
+ + "?Name,"
+ + "?Description,"
+ + "?ParcelId,"
+ + "?ParentEstate,"
+ + "?SnapshotId,"
+ + "?SimName,"
+ + "?GlobalPos,"
+ + "?ParcelName,"
+ + "?Flags,"
+ + "?ListingPrice ) "
+ + "ON DUPLICATE KEY UPDATE "
+ + "category=?Category, "
+ + "expirationdate=?ExpirationDate, "
+ + "name=?Name, "
+ + "description=?Description, "
+ + "parentestate=?ParentEstate, "
+ + "posglobal=?GlobalPos, "
+ + "parcelname=?ParcelName, "
+ + "classifiedflags=?Flags, "
+ + "priceforlisting=?ListingPrice, "
+ + "snapshotuuid=?SnapshotId"
+ ;
if(string.IsNullOrEmpty(ad.ParcelName))
ad.ParcelName = "Unknown";
@@ -228,6 +229,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -242,10 +244,7 @@ namespace OpenSim.Data.MySQL
public bool DeleteClassifiedRecord(UUID recordId)
{
- string query = string.Empty;
-
- query += "DELETE FROM classifieds WHERE ";
- query += "classifieduuid = ?recordId";
+ const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId";
try
{
@@ -258,6 +257,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?recordId", recordId.ToString());
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -271,10 +271,8 @@ namespace OpenSim.Data.MySQL
public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
{
- string query = string.Empty;
- query += "SELECT * FROM classifieds WHERE ";
- query += "classifieduuid = ?AdId";
+ const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId";
try
{
@@ -322,10 +320,8 @@ namespace OpenSim.Data.MySQL
#region Picks Queries
public OSDArray GetAvatarPicks(UUID avatarId)
{
- string query = string.Empty;
+ const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id";
- query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
- query += "creatoruuid = ?Id";
OSDArray data = new OSDArray();
try
@@ -352,6 +348,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -364,12 +361,8 @@ namespace OpenSim.Data.MySQL
public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
{
- string query = string.Empty;
UserProfilePick pick = new UserProfilePick();
-
- query += "SELECT * FROM userpicks WHERE ";
- query += "creatoruuid = ?CreatorId AND ";
- query += "pickuuid = ?PickId";
+ const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId";
try
{
@@ -422,33 +415,33 @@ namespace OpenSim.Data.MySQL
public bool UpdatePicksRecord(UserProfilePick pick)
{
- string query = string.Empty;
-
- query += "INSERT INTO userpicks VALUES (";
- query += "?PickId,";
- query += "?CreatorId,";
- query += "?TopPick,";
- query += "?ParcelId,";
- query += "?Name,";
- query += "?Desc,";
- query += "?SnapshotId,";
- query += "?User,";
- query += "?Original,";
- query += "?SimName,";
- query += "?GlobalPos,";
- query += "?SortOrder,";
- query += "?Enabled,";
- query += "?Gatekeeper)";
- query += "ON DUPLICATE KEY UPDATE ";
- query += "parceluuid=?ParcelId,";
- query += "name=?Name,";
- query += "description=?Desc,";
- query += "user=?User,";
- query += "simname=?SimName,";
- query += "snapshotuuid=?SnapshotId,";
- query += "pickuuid=?PickId,";
- query += "posglobal=?GlobalPos,";
- query += "gatekeeper=?Gatekeeper";
+ const string query =
+ "INSERT INTO userpicks VALUES ("
+ + "?PickId,"
+ + "?CreatorId,"
+ + "?TopPick,"
+ + "?ParcelId,"
+ + "?Name,"
+ + "?Desc,"
+ + "?SnapshotId,"
+ + "?User,"
+ + "?Original,"
+ + "?SimName,"
+ + "?GlobalPos,"
+ + "?SortOrder,"
+ + "?Enabled,"
+ + "?Gatekeeper)"
+ + "ON DUPLICATE KEY UPDATE "
+ + "parceluuid=?ParcelId,"
+ + "name=?Name,"
+ + "description=?Desc,"
+ + "user=?User,"
+ + "simname=?SimName,"
+ + "snapshotuuid=?SnapshotId,"
+ + "pickuuid=?PickId,"
+ + "posglobal=?GlobalPos,"
+ + "gatekeeper=?Gatekeeper"
+ ;
try
{
@@ -474,6 +467,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -487,10 +481,7 @@ namespace OpenSim.Data.MySQL
public bool DeletePicksRecord(UUID pickId)
{
- string query = string.Empty;
-
- query += "DELETE FROM userpicks WHERE ";
- query += "pickuuid = ?PickId";
+ string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId";
try
{
@@ -504,6 +495,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -519,11 +511,7 @@ namespace OpenSim.Data.MySQL
#region Avatar Notes Queries
public bool GetAvatarNotes(ref UserProfileNotes notes)
{ // WIP
- string query = string.Empty;
-
- query += "SELECT `notes` FROM usernotes WHERE ";
- query += "useruuid = ?Id AND ";
- query += "targetuuid = ?TargetId";
+ const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId";
try
{
@@ -548,6 +536,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -560,26 +549,25 @@ namespace OpenSim.Data.MySQL
public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
{
- string query = string.Empty;
+ string query;
bool remove;
if(string.IsNullOrEmpty(note.Notes))
{
remove = true;
- query += "DELETE FROM usernotes WHERE ";
- query += "useruuid=?UserId AND ";
- query += "targetuuid=?TargetId";
+ query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId";
}
else
{
remove = false;
- query += "INSERT INTO usernotes VALUES ( ";
- query += "?UserId,";
- query += "?TargetId,";
- query += "?Notes )";
- query += "ON DUPLICATE KEY ";
- query += "UPDATE ";
- query += "notes=?Notes";
+ query = "INSERT INTO usernotes VALUES ("
+ + "?UserId,"
+ + "?TargetId,"
+ + "?Notes )"
+ + "ON DUPLICATE KEY "
+ + "UPDATE "
+ + "notes=?Notes"
+ ;
}
try
@@ -596,6 +584,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -612,10 +601,7 @@ namespace OpenSim.Data.MySQL
#region Avatar Properties
public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
{
- string query = string.Empty;
-
- query += "SELECT * FROM userprofile WHERE ";
- query += "useruuid = ?Id";
+ string query = "SELECT * FROM userprofile WHERE useruuid = ?Id";
try
{
@@ -664,35 +650,36 @@ namespace OpenSim.Data.MySQL
props.PublishProfile = false;
props.PublishMature = false;
- query = "INSERT INTO userprofile (";
- query += "useruuid, ";
- query += "profilePartner, ";
- query += "profileAllowPublish, ";
- query += "profileMaturePublish, ";
- query += "profileURL, ";
- query += "profileWantToMask, ";
- query += "profileWantToText, ";
- query += "profileSkillsMask, ";
- query += "profileSkillsText, ";
- query += "profileLanguages, ";
- query += "profileImage, ";
- query += "profileAboutText, ";
- query += "profileFirstImage, ";
- query += "profileFirstText) VALUES (";
- query += "?userId, ";
- query += "?profilePartner, ";
- query += "?profileAllowPublish, ";
- query += "?profileMaturePublish, ";
- query += "?profileURL, ";
- query += "?profileWantToMask, ";
- query += "?profileWantToText, ";
- query += "?profileSkillsMask, ";
- query += "?profileSkillsText, ";
- query += "?profileLanguages, ";
- query += "?profileImage, ";
- query += "?profileAboutText, ";
- query += "?profileFirstImage, ";
- query += "?profileFirstText)";
+ query = "INSERT INTO userprofile ("
+ + "useruuid, "
+ + "profilePartner, "
+ + "profileAllowPublish, "
+ + "profileMaturePublish, "
+ + "profileURL, "
+ + "profileWantToMask, "
+ + "profileWantToText, "
+ + "profileSkillsMask, "
+ + "profileSkillsText, "
+ + "profileLanguages, "
+ + "profileImage, "
+ + "profileAboutText, "
+ + "profileFirstImage, "
+ + "profileFirstText) VALUES ("
+ + "?userId, "
+ + "?profilePartner, "
+ + "?profileAllowPublish, "
+ + "?profileMaturePublish, "
+ + "?profileURL, "
+ + "?profileWantToMask, "
+ + "?profileWantToText, "
+ + "?profileSkillsMask, "
+ + "?profileSkillsText, "
+ + "?profileLanguages, "
+ + "?profileImage, "
+ + "?profileAboutText, "
+ + "?profileFirstImage, "
+ + "?profileFirstText)"
+ ;
dbcon.Close();
dbcon.Open();
@@ -719,6 +706,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -733,15 +721,10 @@ namespace OpenSim.Data.MySQL
public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
{
- string query = string.Empty;
-
- query += "UPDATE userprofile SET ";
- query += "profileURL=?profileURL, ";
- query += "profileImage=?image, ";
- query += "profileAboutText=?abouttext,";
- query += "profileFirstImage=?firstlifeimage,";
- query += "profileFirstText=?firstlifetext ";
- query += "WHERE useruuid=?uuid";
+ const string query = "UPDATE userprofile SET profileURL=?profileURL,"
+ + "profileImage=?image, profileAboutText=?abouttext,"
+ + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext "
+ + "WHERE useruuid=?uuid";
try
{
@@ -759,6 +742,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -775,15 +759,13 @@ namespace OpenSim.Data.MySQL
#region Avatar Interests
public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
{
- string query = string.Empty;
-
- query += "UPDATE userprofile SET ";
- query += "profileWantToMask=?WantMask, ";
- query += "profileWantToText=?WantText,";
- query += "profileSkillsMask=?SkillsMask,";
- query += "profileSkillsText=?SkillsText, ";
- query += "profileLanguages=?Languages ";
- query += "WHERE useruuid=?uuid";
+ const string query = "UPDATE userprofile SET "
+ + "profileWantToMask=?WantMask, "
+ + "profileWantToText=?WantText,"
+ + "profileSkillsMask=?SkillsMask,"
+ + "profileSkillsText=?SkillsText, "
+ + "profileLanguages=?Languages "
+ + "WHERE useruuid=?uuid";
try
{
@@ -817,18 +799,17 @@ namespace OpenSim.Data.MySQL
public OSDArray GetUserImageAssets(UUID avatarId)
{
OSDArray data = new OSDArray();
- string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
+ const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
// Get classified image assets
-
try
{
using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
{
dbcon.Open();
- using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon))
+ using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon))
{
cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@@ -847,7 +828,7 @@ namespace OpenSim.Data.MySQL
dbcon.Close();
dbcon.Open();
- using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon))
+ using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon))
{
cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@@ -866,9 +847,9 @@ namespace OpenSim.Data.MySQL
dbcon.Close();
dbcon.Open();
- query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
+ const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
- using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon))
+ using (MySqlCommand cmd = new MySqlCommand(string.Format (queryB,"`userpicks`"), dbcon))
{
cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
@@ -884,6 +865,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -897,11 +879,7 @@ namespace OpenSim.Data.MySQL
#region User Preferences
public bool GetUserPreferences(ref UserPreferences pref, ref string result)
{
- string query = string.Empty;
-
- query += "SELECT imviaemail,visible,email FROM ";
- query += "usersettings WHERE ";
- query += "useruuid = ?Id";
+ const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id";
try
{
@@ -925,10 +903,9 @@ namespace OpenSim.Data.MySQL
dbcon.Close();
dbcon.Open();
- query = "INSERT INTO usersettings VALUES ";
- query += "(?uuid,'false','false', ?Email)";
+ const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)";
- using (MySqlCommand put = new MySqlCommand(query, dbcon))
+ using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
{
put.Parameters.AddWithValue("?Email", pref.EMail);
@@ -939,6 +916,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -953,13 +931,9 @@ namespace OpenSim.Data.MySQL
public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
{
- string query = string.Empty;
-
- query += "UPDATE usersettings SET ";
- query += "imviaemail=?ImViaEmail, ";
- query += "visible=?Visible, ";
- query += "email=?EMail ";
- query += "WHERE useruuid=?uuid";
+ const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail,"
+ + "visible=?Visible, email=?EMail "
+ + "WHERE useruuid=?uuid";
try
{
@@ -975,6 +949,7 @@ namespace OpenSim.Data.MySQL
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -991,11 +966,7 @@ namespace OpenSim.Data.MySQL
#region Integration
public bool GetUserAppData(ref UserAppData props, ref string result)
{
- string query = string.Empty;
-
- query += "SELECT * FROM `userdata` WHERE ";
- query += "UserId = ?Id AND ";
- query += "TagId = ?TagId";
+ const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId";
try
{
@@ -1017,13 +988,8 @@ namespace OpenSim.Data.MySQL
}
else
{
- query += "INSERT INTO userdata VALUES ( ";
- query += "?UserId,";
- query += "?TagId,";
- query += "?DataKey,";
- query += "?DataVal) ";
-
- using (MySqlCommand put = new MySqlCommand(query, dbcon))
+ const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)";
+ using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
{
put.Parameters.AddWithValue("?UserId", props.UserId.ToString());
put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
@@ -1035,6 +1001,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
}
catch (Exception e)
@@ -1049,14 +1016,7 @@ namespace OpenSim.Data.MySQL
public bool SetUserAppData(UserAppData props, ref string result)
{
- string query = string.Empty;
-
- query += "UPDATE userdata SET ";
- query += "TagId = ?TagId, ";
- query += "DataKey = ?DataKey, ";
- query += "DataVal = ?DataVal WHERE ";
- query += "UserId = ?UserId AND ";
- query += "TagId = ?TagId";
+ const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId";
try
{
@@ -1072,6 +1032,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..9f9c9cf4fa 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();
}
}
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
AssetBase asset = null;
+ int accessTime = 0;
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
dbcon))
{
cmd.Parameters.AddWithValue("?ID", assetID.ToString());
-
try
{
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
-
- if (m_enableCompression)
- {
- using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
- {
- MemoryStream outputStream = new MemoryStream();
- WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
-// int compressedLength = asset.Data.Length;
- asset.Data = outputStream.ToArray();
-
-// m_log.DebugFormat(
-// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
-// asset.ID, asset.Name, asset.Data.Length, compressedLength);
- }
- }
-
- UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
+ accessTime = (int)dbReader["AccessTime"];
}
}
}
@@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
}
}
+ dbcon.Close();
}
- return asset;
+ if(asset == null)
+ return asset;
+
+ if(accessTime > 0)
+ {
+ try
+ {
+ UpdateAccessTime(asset.Metadata, accessTime);
+ }
+ catch { }
+ }
+
+ if (m_enableCompression && asset.Data != null)
+ {
+ using(MemoryStream ms = new MemoryStream(asset.Data))
+ using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
+ {
+ using(MemoryStream outputStream = new MemoryStream())
+ {
+ decompressionStream.CopyTo(outputStream, int.MaxValue);
+// int compressedLength = asset.Data.Length;
+ asset.Data = outputStream.ToArray();
+ }
+// m_log.DebugFormat(
+// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
+// asset.ID, asset.Name, asset.Data.Length, compressedLength);
+ }
+ }
+ return asset;
}
///
@@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
transaction.Commit();
}
+ dbcon.Close();
}
}
@@ -344,6 +359,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 +490,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 +509,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();
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
index 1a499000fb..6ec89144b5 100644
--- a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
+++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
@@ -18,7 +18,7 @@ CREATE TABLE `os_groups_groups` (
PRIMARY KEY (`GroupID`),
UNIQUE KEY `Name` (`Name`),
FULLTEXT KEY `Name_2` (`Name`)
-) ENGINE=InnoDB;
+) ENGINE=MyISAM;
CREATE TABLE `os_groups_membership` (
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index 6e884898f5..1798d20508 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -173,16 +173,18 @@ namespace OpenSim.Data.PGSQL
if (m_enableCompression)
{
- using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
+ using(MemoryStream ms = new MemoryStream(asset.Data))
+ using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
{
- MemoryStream outputStream = new MemoryStream();
- WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
- // int compressedLength = asset.Data.Length;
- asset.Data = outputStream.ToArray();
-
- // m_log.DebugFormat(
- // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
- // asset.ID, asset.Name, asset.Data.Length, compressedLength);
+ using(MemoryStream outputStream = new MemoryStream())
+ {
+ decompressionStream.CopyTo(outputStream,int.MaxValue);
+ // int compressedLength = asset.Data.Length;
+ asset.Data = outputStream.ToArray();
+ }
+ // m_log.DebugFormat(
+ // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
+ // asset.ID, asset.Name, asset.Data.Length, compressedLength);
}
}
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 516604a648..ec3805f272 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -529,7 +529,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (psEvArgs.Request != null)
{
OSHttpRequest req = new OSHttpRequest(context, request);
- string requestBody = String.Empty;
+ string requestBody;
Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(req.InputStream, encoding))
requestBody = reader.ReadToEnd();
@@ -695,7 +695,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
//m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
- string requestBody = String.Empty;
+
+ string requestBody;
Encoding encoding = Encoding.UTF8;
using(StreamReader reader = new StreamReader(request.InputStream, encoding))
requestBody = reader.ReadToEnd();
@@ -814,6 +815,8 @@ namespace OpenSim.Framework.Servers.HttpServer
}
}
+ request.InputStream.Dispose();
+
if (buffer != null)
{
if (WebUtil.DebugLevel >= 5)
@@ -1119,7 +1122,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{
String requestBody;
- Stream requestStream = request.InputStream;
+ Stream requestStream = Util.Copy(request.InputStream);
Stream innerStream = null;
try
{
@@ -1130,10 +1133,9 @@ namespace OpenSim.Framework.Servers.HttpServer
}
using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
- {
requestBody = reader.ReadToEnd();
+
}
- }
finally
{
if (innerStream != null && innerStream.CanRead)
@@ -1396,13 +1398,10 @@ namespace OpenSim.Framework.Servers.HttpServer
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
Stream requestStream = request.InputStream;
- string requestBody = string.Empty;
+ string requestBody;
Encoding encoding = Encoding.UTF8;
- using(StreamReader reader = new StreamReader(requestStream,encoding))
- requestBody = reader.ReadToEnd();
-
- if(requestStream.CanRead)
- requestStream.Close();
+ using(StreamReader reader = new StreamReader(requestStream, encoding))
+ requestBody= reader.ReadToEnd();
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
@@ -1725,12 +1724,10 @@ namespace OpenSim.Framework.Servers.HttpServer
byte[] buffer;
Stream requestStream = request.InputStream;
- string requestBody = string.Empty;
+ string requestBody;
Encoding encoding = Encoding.UTF8;
- using(StreamReader reader = new StreamReader(requestStream,encoding))
+ using(StreamReader reader = new StreamReader(requestStream, encoding))
requestBody = reader.ReadToEnd();
- if(requestStream.CanRead)
- requestStream.Close();
Hashtable keysvals = new Hashtable();
Hashtable headervals = new Hashtable();
@@ -2269,7 +2266,7 @@ namespace OpenSim.Framework.Servers.HttpServer
string file = Path.Combine(".", "http_500.html");
if (!File.Exists(file))
return getDefaultHTTP500();
- string result = string.Empty;
+ string result;
using(StreamReader sr = File.OpenText(file))
result = sr.ReadToEnd();
return result;
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
index 0305dee118..dfc27157a3 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
@@ -50,11 +50,10 @@ namespace OpenSim.Framework.Servers.HttpServer
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
+ string requestBody;
Encoding encoding = Encoding.UTF8;
- StreamReader streamReader = new StreamReader(request, encoding);
-
- string requestBody = streamReader.ReadToEnd();
- streamReader.Close();
+ using(StreamReader streamReader = new StreamReader(request,encoding))
+ requestBody = streamReader.ReadToEnd();
string param = GetParam(path);
string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
index b3e3ac3795..e8387e3de2 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
@@ -185,8 +185,9 @@ namespace OpenSim.Region.ClientStack.Linden
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader reader = new StreamReader(request);
- string message = reader.ReadToEnd();
+ string message;
+ using(StreamReader reader = new StreamReader(request))
+ message = reader.ReadToEnd();
OSD osd = OSDParser.DeserializeLLSDXml(message);
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
index 27e84b0f13..cfa9581d82 100644
--- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
@@ -216,6 +216,8 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
rc.Request(reqStream, m_Auth);
m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId);
}
+ if(reqStream != null)
+ reqStream.Dispose();
}, null, "XBakesModule.Store"
);
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
index 81aa8829a4..091b1975e4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -65,9 +65,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
protected override byte[] ProcessRequest(
string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
+
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
index 924a1a3c1a..2c74c0e0c0 100644
--- a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
@@ -119,7 +119,15 @@ namespace OpenSim.Region.CoreModules.Framework
if(!client.IsActive)
return;
- GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID);
+ if(m_scenes.Count == 0)
+ return;
+
+ Scene baseScene = m_scenes[0];
+
+ if(baseScene == null || baseScene.ShuttingDown)
+ return;
+
+ GridRegion r = baseScene.GridService.GetRegionByUUID(UUID.Zero, regionID);
if(!client.IsActive)
return;
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
index 7ab92d1a47..5eda8ab02b 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
@@ -60,9 +60,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
+
body = body.Trim();
// m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index c0de3d95db..a5dc0ad0d0 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -460,9 +460,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
if (resp.ContentLength > 0)
{
- StreamReader content = new StreamReader(resp.GetResponseStream());
- m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
- content.Close();
+ using(StreamReader content = new StreamReader(resp.GetResponseStream()))
+ m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
}
}
}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index d52a1d53db..65d50bb9a0 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -901,7 +901,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
// Update the founder with new group information.
- SendAgentGroupDataUpdate(remoteClient, false);
+ SendAgentGroupDataUpdate(remoteClient, true);
return groupID;
}
@@ -1520,6 +1520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
lastname, activeGroupPowers, activeGroupName,
activeGroupTitle);
+
if (tellOthers)
SendScenePresenceUpdate(agentID, activeGroupTitle);
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index d3ea7e23da..4f03cf4a28 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -82,11 +82,11 @@ namespace OpenSim.Server.Handlers.Authentication
switch (p[0])
{
case "plain":
- StreamReader sr = new StreamReader(request);
- string body = sr.ReadToEnd();
- sr.Close();
-
+ string body;
+ using(StreamReader sr = new StreamReader(request))
+ body = sr.ReadToEnd();
return DoPlainMethods(body);
+
case "crypt":
byte[] buffer = new byte[request.Length];
long length = request.Length;
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
index a6605a113b..254b82fadd 100644
--- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
@@ -222,7 +222,10 @@ For more information, see http://openid.net/.
try
{
- NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd());
+ string forPost;
+ using(StreamReader sr = new StreamReader(httpRequest.InputStream))
+ forPost = sr.ReadToEnd();
+ NameValueCollection postQuery = HttpUtility.ParseQueryString(forPost);
NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query);
NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery);
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
index 69c1a896f7..b8fdacfb60 100644
--- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.Avatar
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
index 24f63d9319..d16000d572 100644
--- a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
+++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
@@ -65,10 +65,8 @@ namespace OpenSim.Server.Handlers.BakedTextures
return new byte[0];
}
- StreamReader sr = new StreamReader(request);
-
- m_BakesService.Store(p[0], sr.ReadToEnd());
- sr.Close();
+ using(StreamReader sr = new StreamReader(request))
+ m_BakesService.Store(p[0],sr.ReadToEnd());
return new byte[0];
}
diff --git a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
index e0c281044f..b7558ec2a9 100644
--- a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
+++ b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
@@ -282,9 +282,10 @@ namespace OpenSim.Server.Handlers
// /estates/estate/?eid=int®ion=uuid
if ("estate".Equals(resource))
{
- StreamReader sr = new StreamReader(request);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(request))
+ body = sr.ReadToEnd();
+
body = body.Trim();
Dictionary requestData = ServerUtils.ParseQueryString(body);
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
index 3aab30b3c3..d6668abe13 100644
--- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
@@ -61,9 +61,9 @@ namespace OpenSim.Server.Handlers.Friends
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index f51c4ee48c..44d4654ceb 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -65,9 +65,9 @@ namespace OpenSim.Server.Handlers.Grid
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
index 8806c2cbbd..1f691d66b2 100644
--- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.GridUser
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index 8116050afe..fc1a77d0e1 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -71,9 +71,9 @@ namespace OpenSim.Server.Handlers.Hypergrid
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 4400395c30..742d1a045b 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -95,9 +95,9 @@ namespace OpenSim.Server.Handlers.Inventory
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
//m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
index 7611f538dd..bfd73a257b 100644
--- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
@@ -104,9 +104,9 @@ namespace OpenSim.Server.Handlers.MapImage
protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
try
diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
index f292b9585d..8a3875dc5d 100644
--- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Server.Handlers.MapImage
public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
try
@@ -215,13 +215,16 @@ namespace OpenSim.Server.Handlers.MapImage
private byte[] DocToBytes(XmlDocument doc)
{
- MemoryStream ms = new MemoryStream();
- XmlTextWriter xw = new XmlTextWriter(ms, null);
- xw.Formatting = Formatting.Indented;
- doc.WriteTo(xw);
- xw.Flush();
-
+ using(MemoryStream ms = new MemoryStream())
+ {
+ using(XmlTextWriter xw = new XmlTextWriter(ms,null))
+ {
+ xw.Formatting = Formatting.Indented;
+ doc.WriteTo(xw);
+ xw.Flush();
+ }
return ms.ToArray();
+ }
}
private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index a02255f01d..bc12ef9b94 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -72,9 +72,9 @@ namespace OpenSim.Server.Handlers.UserAccounts
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
- StreamReader sr = new StreamReader(requestData);
- string body = sr.ReadToEnd();
- sr.Close();
+ string body;
+ using(StreamReader sr = new StreamReader(requestData))
+ body = sr.ReadToEnd();
body = body.Trim();
// We need to check the authorization header
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 939059da71..5f075ace29 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -183,8 +183,8 @@ namespace OpenSim.Services.Connectors
{
using (StreamReader sr = new StreamReader(s))
{
+ sr.ReadToEnd(); // just try to read
//reply = sr.ReadToEnd().Trim();
- sr.ReadToEnd().Trim();
//m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
}
}
diff --git a/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs
new file mode 100644
index 0000000000..8e2d8e6c98
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs
@@ -0,0 +1,339 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using OpenMetaverse;
+using OpenSim.Data;
+
+namespace OpenSim.Tests.Common.Mock
+{
+ public class TestGroupsDataPlugin : IGroupsData
+ {
+ class CompositeKey
+ {
+ private readonly string _key;
+ public string Key
+ {
+ get { return _key; }
+ }
+
+ public CompositeKey(UUID _k1, string _k2)
+ {
+ _key = _k1.ToString() + _k2;
+ }
+
+ public CompositeKey(UUID _k1, string _k2, string _k3)
+ {
+ _key = _k1.ToString() + _k2 + _k3;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj is CompositeKey)
+ {
+ return Key == ((CompositeKey)obj).Key;
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return Key;
+ }
+ }
+
+ private Dictionary m_Groups;
+ private Dictionary m_Membership;
+ private Dictionary m_Roles;
+ private Dictionary m_RoleMembership;
+ private Dictionary m_Invites;
+ private Dictionary m_Notices;
+ private Dictionary m_Principals;
+
+ public TestGroupsDataPlugin(string connectionString, string realm)
+ {
+ m_Groups = new Dictionary();
+ m_Membership = new Dictionary();
+ m_Roles = new Dictionary();
+ m_RoleMembership = new Dictionary();
+ m_Invites = new Dictionary();
+ m_Notices = new Dictionary();
+ m_Principals = new Dictionary();
+ }
+
+ #region groups table
+ public bool StoreGroup(GroupData data)
+ {
+ return false;
+ }
+
+ public GroupData RetrieveGroup(UUID groupID)
+ {
+ if (m_Groups.ContainsKey(groupID))
+ return m_Groups[groupID];
+
+ return null;
+ }
+
+ public GroupData RetrieveGroup(string name)
+ {
+ return m_Groups.Values.First(g => g.Data.ContainsKey("Name") && g.Data["Name"] == name);
+ }
+
+ public GroupData[] RetrieveGroups(string pattern)
+ {
+ if (string.IsNullOrEmpty(pattern))
+ pattern = "1";
+
+ IEnumerable groups = m_Groups.Values.Where(g => g.Data.ContainsKey("Name") && (g.Data["Name"].StartsWith(pattern) || g.Data["Name"].EndsWith(pattern)));
+
+ return (groups != null) ? groups.ToArray() : new GroupData[0];
+ }
+
+ public bool DeleteGroup(UUID groupID)
+ {
+ return m_Groups.Remove(groupID);
+ }
+
+ public int GroupsCount()
+ {
+ return m_Groups.Count;
+ }
+ #endregion
+
+ #region membership table
+ public MembershipData RetrieveMember(UUID groupID, string pricipalID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, pricipalID);
+ if (m_Membership.ContainsKey(dkey))
+ return m_Membership[dkey];
+
+ return null;
+ }
+
+ public MembershipData[] RetrieveMembers(UUID groupID)
+ {
+ IEnumerable keys = m_Membership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
+ return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
+ }
+
+ public MembershipData[] RetrieveMemberships(string principalID)
+ {
+ IEnumerable keys = m_Membership.Keys.Where(k => k.Key.EndsWith(principalID.ToString()));
+ return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
+ }
+
+ public MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
+ {
+ return RetrieveMemberships(principalID);
+ }
+
+ public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, principalID);
+ if (m_Membership.ContainsKey(dkey))
+ return m_Membership[dkey];
+ return null;
+ }
+
+ public bool StoreMember(MembershipData data)
+ {
+ CompositeKey dkey = new CompositeKey(data.GroupID, data.PrincipalID);
+ m_Membership[dkey] = data;
+ return true;
+ }
+
+ public bool DeleteMember(UUID groupID, string principalID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, principalID);
+ if (m_Membership.ContainsKey(dkey))
+ return m_Membership.Remove(dkey);
+
+ return false;
+ }
+
+ public int MemberCount(UUID groupID)
+ {
+ return m_Membership.Count;
+ }
+ #endregion
+
+ #region roles table
+ public bool StoreRole(RoleData data)
+ {
+ CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString());
+ m_Roles[dkey] = data;
+ return true;
+ }
+
+ public RoleData RetrieveRole(UUID groupID, UUID roleID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
+ if (m_Roles.ContainsKey(dkey))
+ return m_Roles[dkey];
+
+ return null;
+ }
+
+ public RoleData[] RetrieveRoles(UUID groupID)
+ {
+ IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
+ return keys.Where(m_Roles.ContainsKey).Select(x => m_Roles[x]).ToArray();
+ }
+
+ public bool DeleteRole(UUID groupID, UUID roleID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
+ if (m_Roles.ContainsKey(dkey))
+ return m_Roles.Remove(dkey);
+
+ return false;
+ }
+
+ public int RoleCount(UUID groupID)
+ {
+ return m_Roles.Count;
+ }
+ #endregion
+
+ #region rolememberhip table
+ public RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
+ {
+ IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
+ return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
+ }
+
+ public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
+ {
+ IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString() + roleID.ToString()));
+ return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
+ }
+
+ public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
+ {
+ IEnumerable keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID));
+ return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
+ }
+
+ public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
+ {
+ CompositeKey dkey = new CompositeKey(groupID, roleID.ToString(), principalID);
+ if (m_RoleMembership.ContainsKey(dkey))
+ return m_RoleMembership[dkey];
+
+ return null;
+ }
+
+ public int RoleMemberCount(UUID groupID, UUID roleID)
+ {
+ return m_RoleMembership.Count;
+ }
+
+ public bool StoreRoleMember(RoleMembershipData data)
+ {
+ CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
+ m_RoleMembership[dkey] = data;
+ return true;
+ }
+
+ public bool DeleteRoleMember(RoleMembershipData data)
+ {
+ CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
+ if (m_RoleMembership.ContainsKey(dkey))
+ return m_RoleMembership.Remove(dkey);
+
+ return false;
+ }
+
+ public bool DeleteMemberAllRoles(UUID groupID, string principalID)
+ {
+ List keys = m_RoleMembership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)).ToList();
+ foreach (CompositeKey k in keys)
+ m_RoleMembership.Remove(k);
+ return true;
+ }
+ #endregion
+
+ #region principals table
+ public bool StorePrincipal(PrincipalData data)
+ {
+ m_Principals[data.PrincipalID] = data;
+ return true;
+ }
+
+ public PrincipalData RetrievePrincipal(string principalID)
+ {
+ if (m_Principals.ContainsKey(principalID))
+ return m_Principals[principalID];
+
+ return null;
+ }
+
+ public bool DeletePrincipal(string principalID)
+ {
+ if (m_Principals.ContainsKey(principalID))
+ return m_Principals.Remove(principalID);
+ return false;
+ }
+ #endregion
+
+ #region invites table
+ public bool StoreInvitation(InvitationData data)
+ {
+ return false;
+ }
+
+ public InvitationData RetrieveInvitation(UUID inviteID)
+ {
+ return null;
+ }
+
+ public InvitationData RetrieveInvitation(UUID groupID, string principalID)
+ {
+ return null;
+ }
+
+ public bool DeleteInvite(UUID inviteID)
+ {
+ return false;
+ }
+
+ public void DeleteOldInvites()
+ {
+ }
+ #endregion
+
+ #region notices table
+ public bool StoreNotice(NoticeData data)
+ {
+ return false;
+ }
+
+ public NoticeData RetrieveNotice(UUID noticeID)
+ {
+ return null;
+ }
+
+ public NoticeData[] RetrieveNotices(UUID groupID)
+ {
+ return new NoticeData[0];
+ }
+
+ public bool DeleteNotice(UUID noticeID)
+ {
+ return false;
+ }
+
+ public void DeleteOldNotices()
+ {
+ }
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs
index f93c1201e1..4ecce383e4 100644
--- a/OpenSim/Tests/Permissions/Common.cs
+++ b/OpenSim/Tests/Permissions/Common.cs
@@ -72,12 +72,21 @@ namespace OpenSim.Tests.Permissions
IConfigSource config = new IniConfigSource();
config.AddConfig("Messaging");
config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
+
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
+
config.AddConfig("InventoryService");
config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
+ config.AddConfig("Groups");
+ config.Configs["Groups"].Set("Enabled", "true");
+ config.Configs["Groups"].Set("Module", "Groups Module V2");
+ config.Configs["Groups"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestGroupsDataPlugin");
+ config.Configs["Groups"].Set("ServicesConnectorModule", "Groups Local Service Connector");
+ config.Configs["Groups"].Set("LocalService", "local");
+
m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
// Add modules
SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());
diff --git a/bin/CSJ2K.dll b/bin/CSJ2K.dll
index e882e4c6c6..238291f7e7 100755
Binary files a/bin/CSJ2K.dll and b/bin/CSJ2K.dll differ