From f129b824c38f2ea74e4777c1399cdb9e755db96e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Aug 2014 19:46:46 +0100
Subject: Removing locking on requests in MySQLAssetData.
These locks are not necessary since the connection is taken from the underlying mysql pool and not shared.
Such locking is already not done by some other parts of OpenSim.Data.MySQL.
Pointed out by arribasim-dev
---
OpenSim/Data/MySQL/MySQLAssetData.cs | 305 +++++++++++++++++------------------
1 file changed, 144 insertions(+), 161 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index f03e322..5d8da17 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -45,7 +45,6 @@ namespace OpenSim.Data.MySQL
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_connectionString;
- private object m_dbLock = new object();
protected virtual Assembly Assembly
{
@@ -107,47 +106,46 @@ namespace OpenSim.Data.MySQL
override public AssetBase GetAsset(UUID assetID)
{
AssetBase asset = null;
- lock (m_dbLock)
+
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = new MySqlCommand(
+ "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id",
+ dbcon))
{
- dbcon.Open();
+ cmd.Parameters.AddWithValue("?id", assetID.ToString());
- using (MySqlCommand cmd = new MySqlCommand(
- "SELECT name, description, assetType, local, temporary, asset_flags, CreatorID, data FROM assets WHERE id=?id",
- dbcon))
+ try
{
- cmd.Parameters.AddWithValue("?id", assetID.ToString());
-
- try
+ using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
+ if (dbReader.Read())
{
- if (dbReader.Read())
- {
- asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString());
- asset.Data = (byte[])dbReader["data"];
- asset.Description = (string)dbReader["description"];
-
- string local = dbReader["local"].ToString();
- if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
- asset.Local = true;
- else
- asset.Local = false;
-
- asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
- asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
- }
+ asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"], dbReader["CreatorID"].ToString());
+ asset.Data = (byte[])dbReader["data"];
+ asset.Description = (string)dbReader["description"];
+
+ string local = dbReader["local"].ToString();
+ if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
+ asset.Local = true;
+ else
+ asset.Local = false;
+
+ asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
+ asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
}
}
- catch (Exception e)
- {
- m_log.Error(
- string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
- }
+ }
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
}
}
}
+
return asset;
}
@@ -158,100 +156,94 @@ namespace OpenSim.Data.MySQL
/// On failure : Throw an exception and attempt to reconnect to database
override public void StoreAsset(AssetBase asset)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd =
+ new MySqlCommand(
+ "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
+ "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
+ dbcon))
{
- 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);
+ }
- using (MySqlCommand cmd =
- new MySqlCommand(
- "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
- "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
- dbcon))
+ string assetDescription = asset.Description;
+ if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
{
- 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);
- }
-
- try
- {
- using (cmd)
- {
- // create unix epoch time
- int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
- cmd.Parameters.AddWithValue("?id", asset.ID);
- cmd.Parameters.AddWithValue("?name", assetName);
- cmd.Parameters.AddWithValue("?description", assetDescription);
- cmd.Parameters.AddWithValue("?assetType", asset.Type);
- cmd.Parameters.AddWithValue("?local", asset.Local);
- cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
- cmd.Parameters.AddWithValue("?create_time", now);
- cmd.Parameters.AddWithValue("?access_time", now);
- cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
- cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
- cmd.Parameters.AddWithValue("?data", asset.Data);
- cmd.ExecuteNonQuery();
- }
- }
- catch (Exception e)
+ 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);
+ }
+
+ try
+ {
+ using (cmd)
{
- m_log.Error(
- string.Format(
- "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ",
- asset.FullID, asset.Name)
- , e);
+ // create unix epoch time
+ int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
+ cmd.Parameters.AddWithValue("?id", asset.ID);
+ cmd.Parameters.AddWithValue("?name", assetName);
+ cmd.Parameters.AddWithValue("?description", assetDescription);
+ cmd.Parameters.AddWithValue("?assetType", asset.Type);
+ cmd.Parameters.AddWithValue("?local", asset.Local);
+ cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
+ cmd.Parameters.AddWithValue("?create_time", now);
+ cmd.Parameters.AddWithValue("?access_time", now);
+ cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
+ cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
+ cmd.Parameters.AddWithValue("?data", asset.Data);
+ cmd.ExecuteNonQuery();
}
}
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format(
+ "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ",
+ asset.FullID, asset.Name)
+ , e);
+ }
}
}
}
private void UpdateAccessTime(AssetBase asset)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
+ dbcon.Open();
- using (MySqlCommand cmd
- = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon))
+ using (MySqlCommand cmd
+ = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon))
+ {
+ try
{
- try
- {
- using (cmd)
- {
- // create unix epoch time
- int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
- cmd.Parameters.AddWithValue("?id", asset.ID);
- cmd.Parameters.AddWithValue("?access_time", now);
- cmd.ExecuteNonQuery();
- }
- }
- catch (Exception e)
+ using (cmd)
{
- m_log.Error(
- string.Format(
- "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
- asset.FullID, asset.Name),
- e);
+ // create unix epoch time
+ int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
+ cmd.Parameters.AddWithValue("?id", asset.ID);
+ cmd.Parameters.AddWithValue("?access_time", now);
+ cmd.ExecuteNonQuery();
}
}
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format(
+ "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
+ asset.FullID, asset.Name),
+ e);
+ }
}
}
}
@@ -271,20 +263,17 @@ namespace OpenSim.Data.MySQL
string ids = "'" + string.Join("','", uuids) + "'";
string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+ using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
{
- dbcon.Open();
- using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
+ using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader())
+ while (dbReader.Read())
{
- while (dbReader.Read())
- {
- UUID id = DBGuid.FromDB(dbReader["id"]);
- exist.Add(id);
- }
+ UUID id = DBGuid.FromDB(dbReader["id"]);
+ exist.Add(id);
}
}
}
@@ -309,50 +298,47 @@ namespace OpenSim.Data.MySQL
{
List retList = new List(count);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd
+ = new MySqlCommand(
+ "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
+ dbcon))
{
- dbcon.Open();
+ cmd.Parameters.AddWithValue("?start", start);
+ cmd.Parameters.AddWithValue("?count", count);
- using (MySqlCommand cmd
- = new MySqlCommand(
- "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
- dbcon))
+ try
{
- cmd.Parameters.AddWithValue("?start", start);
- cmd.Parameters.AddWithValue("?count", count);
-
- try
+ using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader())
+ while (dbReader.Read())
{
- while (dbReader.Read())
- {
- AssetMetadata metadata = new AssetMetadata();
- metadata.Name = (string)dbReader["name"];
- metadata.Description = (string)dbReader["description"];
- metadata.Type = (sbyte)dbReader["assetType"];
- metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
- metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
- metadata.FullID = DBGuid.FromDB(dbReader["id"]);
- metadata.CreatorID = dbReader["CreatorID"].ToString();
-
- // Current SHA1s are not stored/computed.
- metadata.SHA1 = new byte[] { };
-
- retList.Add(metadata);
- }
+ AssetMetadata metadata = new AssetMetadata();
+ metadata.Name = (string)dbReader["name"];
+ metadata.Description = (string)dbReader["description"];
+ metadata.Type = (sbyte)dbReader["assetType"];
+ metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct.
+ metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
+ metadata.FullID = DBGuid.FromDB(dbReader["id"]);
+ metadata.CreatorID = dbReader["CreatorID"].ToString();
+
+ // Current SHA1s are not stored/computed.
+ metadata.SHA1 = new byte[] { };
+
+ retList.Add(metadata);
}
}
- catch (Exception e)
- {
- m_log.Error(
- string.Format(
- "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
- start, count),
- e);
- }
+ }
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format(
+ "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
+ start, count),
+ e);
}
}
}
@@ -362,17 +348,14 @@ namespace OpenSim.Data.MySQL
public override bool Delete(string id)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
+ dbcon.Open();
- using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon))
- {
- cmd.Parameters.AddWithValue("?id", id);
- cmd.ExecuteNonQuery();
- }
+ using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon))
+ {
+ cmd.Parameters.AddWithValue("?id", id);
+ cmd.ExecuteNonQuery();
}
}
--
cgit v1.1
From d899bdcb9bbf1b52f91daabacfb630059757fcea Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Aug 2014 19:52:03 +0100
Subject: Remove lock in MySQLFramework. This is not necessary as the
connection is not shared.
---
OpenSim/Data/MySQL/MySQLFramework.cs | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index 3fdcf1e..5820a90 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -45,38 +45,29 @@ namespace OpenSim.Data.MySQL
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected string m_connectionString;
- protected object m_dbLock = new object();
protected MySqlFramework(string connectionString)
{
m_connectionString = connectionString;
}
- //////////////////////////////////////////////////////////////
- //
- // All non queries are funneled through one connection
- // to increase performance a little
- //
protected int ExecuteNonQuery(MySqlCommand cmd)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
- cmd.Connection = dbcon;
+ dbcon.Open();
+ cmd.Connection = dbcon;
- try
- {
- return cmd.ExecuteNonQuery();
- }
- catch (Exception e)
- {
- m_log.Error(e.Message, e);
- return 0;
- }
+ try
+ {
+ return cmd.ExecuteNonQuery();
+ }
+ catch (Exception e)
+ {
+ m_log.Error(e.Message, e);
+ return 0;
}
}
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From 709038aa2adfe5a668c2452ec7acde517125c4e8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Aug 2014 20:23:48 +0100
Subject: Remove some use of database connection locking from
MySQLSimulationData - this has not been necessary for some time as database
connections are not shared.
However, many locks remain since they may effectively be providing transactionality in some operations (e.g. prim updates across multiple tables).
These are candidates for being replaced with proper database transactions, since this would not block unrelated operations (e.g. land save and object save)
or unrelated operations on the same tables (e.g. storage of one linkset whilst another is being removed).
In practice, any performance deg due to contention is probably rare and short lived as the major prim operations are performed in memory and only persisted some time afterwards.
---
OpenSim/Data/MySQL/MySQLSimulationData.cs | 616 +++++++++++++++---------------
1 file changed, 298 insertions(+), 318 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 8937b64..bb0ab75 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -51,6 +51,15 @@ namespace OpenSim.Data.MySQL
private static string LogHeader = "[REGION DB MYSQL]";
private string m_connectionString;
+
+ ///
+ /// This lock was being used to serialize database operations when the connection was shared, but this has
+ /// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead.
+ /// FIXME: However, the locks remain in many places since they are effectively providing a level of
+ /// transactionality. This should be replaced by more efficient database transactions which would not require
+ /// unrelated operations to block each other or unrelated operations on the same tables from blocking each
+ /// other.
+ ///
private object m_dbLock = new object();
protected virtual Assembly Assembly
@@ -738,95 +747,92 @@ namespace OpenSim.Data.MySQL
RegionLightShareData nWP = new RegionLightShareData();
nWP.OnSave += StoreRegionWindlightSettings;
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ string command = "select * from `regionwindlight` where region_id = ?regionID";
+
+ using (MySqlCommand cmd = new MySqlCommand(command))
{
- dbcon.Open();
-
- string command = "select * from `regionwindlight` where region_id = ?regionID";
-
- using (MySqlCommand cmd = new MySqlCommand(command))
+ cmd.Connection = dbcon;
+
+ cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
+
+ IDataReader result = ExecuteReader(cmd);
+ if (!result.Read())
{
- cmd.Connection = dbcon;
-
- cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
-
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
- {
- //No result, so store our default windlight profile and return it
- nWP.regionID = regionUUID;
+ //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;
- }
+ 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;
}
}
}
@@ -876,124 +882,118 @@ namespace OpenSim.Data.MySQL
public void StoreRegionWindlightSettings(RegionLightShareData wl)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
{
- dbcon.Open();
-
- 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.Parameters.AddWithValue("region_id", wl.regionID);
- cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
- cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
- cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
- cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
- cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
- cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
- cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
- cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
- cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
- cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
- cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
- cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
- cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
- cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
- cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
- cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
- cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
- cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
- cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
- cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
- cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
- cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
- cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
- cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
- cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
- cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
- cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
- cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
- cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
- cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
- cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
- cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
- cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
- cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
- cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
- cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
- cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
- cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
- cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
- cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
- cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
- cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
- cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
- cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
- cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
- cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
- cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
- cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
- cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
- cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
- cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
- cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
- cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
- cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
- cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
- cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
- cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
- cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
- cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
- cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
-
- ExecuteNonQuery(cmd);
- }
+ 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.Parameters.AddWithValue("region_id", wl.regionID);
+ cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
+ cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
+ cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
+ cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
+ cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
+ cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
+ cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
+ cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
+ cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
+ cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
+ cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
+ cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
+ cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
+ cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
+ cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
+ cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
+ cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
+ cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
+ cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
+ cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
+ cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
+ cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
+ cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
+ cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
+ cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
+ cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
+ cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
+ cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
+ cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
+ cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
+ cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
+ cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
+ cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
+ cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
+ cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
+ cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
+ cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
+ cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
+ cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
+ cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
+ cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
+ cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
+ cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
+ cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
+ cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
+ cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
+ cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
+ cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
+ cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
+ cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
+ cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
+ cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
+ cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
+ cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
+ cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
+ cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
+ cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
+ cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
+ cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
+ cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
+
+ ExecuteNonQuery(cmd);
}
}
}
public void RemoveRegionWindlightSettings(UUID regionID)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
- cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
- ExecuteNonQuery(cmd);
- }
+ cmd.CommandText = "delete from `regionwindlight` where `region_id`=?regionID";
+ cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
+ ExecuteNonQuery(cmd);
}
}
}
@@ -1001,29 +1001,26 @@ namespace OpenSim.Data.MySQL
#region RegionEnvironmentSettings
public string LoadRegionEnvironmentSettings(UUID regionUUID)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ string command = "select * from `regionenvironment` where region_id = ?region_id";
+
+ using (MySqlCommand cmd = new MySqlCommand(command))
{
- dbcon.Open();
-
- string command = "select * from `regionenvironment` where region_id = ?region_id";
-
- using (MySqlCommand cmd = new MySqlCommand(command))
+ cmd.Connection = dbcon;
+
+ cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
+
+ IDataReader result = ExecuteReader(cmd);
+ if (!result.Read())
{
- cmd.Connection = dbcon;
-
- cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
-
- IDataReader result = ExecuteReader(cmd);
- if (!result.Read())
- {
- return String.Empty;
- }
- else
- {
- return Convert.ToString(result["llsd_settings"]);
- }
+ return String.Empty;
+ }
+ else
+ {
+ return Convert.ToString(result["llsd_settings"]);
}
}
}
@@ -1031,39 +1028,33 @@ namespace OpenSim.Data.MySQL
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
-
- cmd.Parameters.AddWithValue("region_id", regionUUID);
- cmd.Parameters.AddWithValue("llsd_settings", settings);
-
- ExecuteNonQuery(cmd);
- }
+ cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
+
+ cmd.Parameters.AddWithValue("region_id", regionUUID);
+ cmd.Parameters.AddWithValue("llsd_settings", settings);
+
+ ExecuteNonQuery(cmd);
}
}
}
public void RemoveRegionEnvironmentSettings(UUID regionUUID)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = dbcon.CreateCommand())
{
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
- cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
- ExecuteNonQuery(cmd);
- }
+ cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
+ cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
+ ExecuteNonQuery(cmd);
}
}
}
@@ -1071,57 +1062,55 @@ namespace OpenSim.Data.MySQL
public void StoreRegionSettings(RegionSettings rs)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
-
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "replace into regionsettings (regionUUID, " +
- "block_terraform, block_fly, allow_damage, " +
- "restrict_pushing, allow_land_resell, " +
- "allow_land_join_divide, block_show_in_search, " +
- "agent_limit, object_bonus, maturity, " +
- "disable_scripts, disable_collisions, " +
- "disable_physics, terrain_texture_1, " +
- "terrain_texture_2, terrain_texture_3, " +
- "terrain_texture_4, elevation_1_nw, " +
- "elevation_2_nw, elevation_1_ne, " +
- "elevation_2_ne, elevation_1_se, " +
- "elevation_2_se, elevation_1_sw, " +
- "elevation_2_sw, water_height, " +
- "terrain_raise_limit, terrain_lower_limit, " +
- "use_estate_sun, fixed_sun, sun_position, " +
- "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " +
- "sunvectorz, loaded_creation_datetime, " +
- "loaded_creation_id, map_tile_ID, " +
- "TelehubObject, parcel_tile_ID) " +
- "values (?RegionUUID, ?BlockTerraform, " +
- "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
- "?AllowLandResell, ?AllowLandJoinDivide, " +
- "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
- "?Maturity, ?DisableScripts, ?DisableCollisions, " +
- "?DisablePhysics, ?TerrainTexture1, " +
- "?TerrainTexture2, ?TerrainTexture3, " +
- "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
- "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
- "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
- "?WaterHeight, ?TerrainRaiseLimit, " +
- "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
- "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
- "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
- "?LoadedCreationDateTime, ?LoadedCreationID, " +
- "?TerrainImageID, " +
- "?TelehubObject, ?ParcelImageID)";
-
- FillRegionSettingsCommand(cmd, rs);
+ dbcon.Open();
- ExecuteNonQuery(cmd);
- }
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "replace into regionsettings (regionUUID, " +
+ "block_terraform, block_fly, allow_damage, " +
+ "restrict_pushing, allow_land_resell, " +
+ "allow_land_join_divide, block_show_in_search, " +
+ "agent_limit, object_bonus, maturity, " +
+ "disable_scripts, disable_collisions, " +
+ "disable_physics, terrain_texture_1, " +
+ "terrain_texture_2, terrain_texture_3, " +
+ "terrain_texture_4, elevation_1_nw, " +
+ "elevation_2_nw, elevation_1_ne, " +
+ "elevation_2_ne, elevation_1_se, " +
+ "elevation_2_se, elevation_1_sw, " +
+ "elevation_2_sw, water_height, " +
+ "terrain_raise_limit, terrain_lower_limit, " +
+ "use_estate_sun, fixed_sun, sun_position, " +
+ "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " +
+ "sunvectorz, loaded_creation_datetime, " +
+ "loaded_creation_id, map_tile_ID, " +
+ "TelehubObject, parcel_tile_ID) " +
+ "values (?RegionUUID, ?BlockTerraform, " +
+ "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
+ "?AllowLandResell, ?AllowLandJoinDivide, " +
+ "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
+ "?Maturity, ?DisableScripts, ?DisableCollisions, " +
+ "?DisablePhysics, ?TerrainTexture1, " +
+ "?TerrainTexture2, ?TerrainTexture3, " +
+ "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
+ "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
+ "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
+ "?WaterHeight, ?TerrainRaiseLimit, " +
+ "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
+ "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
+ "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
+ "?LoadedCreationDateTime, ?LoadedCreationID, " +
+ "?TerrainImageID, " +
+ "?TelehubObject, ?ParcelImageID)";
+
+ FillRegionSettingsCommand(cmd, rs);
+
+ ExecuteNonQuery(cmd);
}
}
+
SaveSpawnPoints(rs);
}
@@ -2043,41 +2032,35 @@ namespace OpenSim.Data.MySQL
public void SaveExtra(UUID regionID, string name, string val)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
+ dbcon.Open();
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)";
- cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
- cmd.Parameters.AddWithValue("?Name", name);
- cmd.Parameters.AddWithValue("?value", val);
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)";
+ cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
+ cmd.Parameters.AddWithValue("?Name", name);
+ cmd.Parameters.AddWithValue("?value", val);
- cmd.ExecuteNonQuery();
- }
+ cmd.ExecuteNonQuery();
}
}
}
public void RemoveExtra(UUID regionID, string name)
{
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
+ dbcon.Open();
- using (MySqlCommand cmd = dbcon.CreateCommand())
- {
- cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name";
- cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
- cmd.Parameters.AddWithValue("?Name", name);
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name";
+ cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
+ cmd.Parameters.AddWithValue("?Name", name);
- cmd.ExecuteNonQuery();
- }
+ cmd.ExecuteNonQuery();
}
}
}
@@ -2086,22 +2069,19 @@ namespace OpenSim.Data.MySQL
{
Dictionary ret = new Dictionary();
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
+ dbcon.Open();
- using (MySqlCommand cmd = dbcon.CreateCommand())
+ using (MySqlCommand cmd = dbcon.CreateCommand())
+ {
+ cmd.CommandText = "select * from regionextra where RegionID=?RegionID";
+ cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
+ using (IDataReader r = cmd.ExecuteReader())
{
- cmd.CommandText = "select * from regionextra where RegionID=?RegionID";
- cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
- using (IDataReader r = cmd.ExecuteReader())
+ while (r.Read())
{
- while (r.Read())
- {
- ret[r["Name"].ToString()] = r["value"].ToString();
- }
+ ret[r["Name"].ToString()] = r["value"].ToString();
}
}
}
--
cgit v1.1
From 0cb805a64cff87b5696528afa01c76732dae98aa Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Aug 2014 20:28:56 +0100
Subject: Remove query locking in MySQLUserProfileData. This is not necessary
as the connection is not shared.
---
OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index adb75d6..7e846e3 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -46,11 +46,6 @@ namespace OpenSim.Data.MySQL
{
get; set;
}
-
- protected object Lock
- {
- get; set;
- }
protected virtual Assembly Assembly
{
@@ -1025,11 +1020,8 @@ namespace OpenSim.Data.MySQL
put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
put.Parameters.AddWithValue("?DataKey", props.DataKey.ToString());
put.Parameters.AddWithValue("?DataVal", props.DataVal.ToString());
-
- lock(Lock)
- {
- put.ExecuteNonQuery();
- }
+
+ put.ExecuteNonQuery();
}
}
}
@@ -1065,14 +1057,11 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
{
cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString());
- cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString ());
- cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString ());
- cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString ());
-
- lock(Lock)
- {
- cmd.ExecuteNonQuery();
- }
+ cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString());
+ cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString());
+ cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString());
+
+ cmd.ExecuteNonQuery();
}
}
}
@@ -1086,5 +1075,4 @@ namespace OpenSim.Data.MySQL
}
#endregion Integration
}
-}
-
+}
\ No newline at end of file
--
cgit v1.1
From fabab7414f346c91f5aa9a3ae3f29c262d131c6d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Aug 2014 20:34:33 +0100
Subject: Remove database connection locking in MySQLXAssetData. This is
unnecessary as connections aren't shared and transactions are already in
place where necessary.
---
OpenSim/Data/MySQL/MySQLXAssetData.cs | 354 ++++++++++++++++------------------
1 file changed, 168 insertions(+), 186 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 8361da2..af7e876 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -57,7 +57,6 @@ namespace OpenSim.Data.MySQL
private bool m_enableCompression = false;
private string m_connectionString;
- private object m_dbLock = new object();
///
/// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
@@ -131,60 +130,58 @@ namespace OpenSim.Data.MySQL
// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
AssetBase asset = null;
- lock (m_dbLock)
+
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlCommand cmd = new MySqlCommand(
+ "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
+ dbcon))
{
- dbcon.Open();
+ cmd.Parameters.AddWithValue("?ID", assetID.ToString());
- using (MySqlCommand cmd = new MySqlCommand(
- "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
- dbcon))
+ try
{
- cmd.Parameters.AddWithValue("?ID", assetID.ToString());
-
- try
+ using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
+ if (dbReader.Read())
{
- if (dbReader.Read())
- {
- asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
- asset.Data = (byte[])dbReader["Data"];
- asset.Description = (string)dbReader["Description"];
+ asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
+ asset.Data = (byte[])dbReader["Data"];
+ asset.Description = (string)dbReader["Description"];
- string local = dbReader["Local"].ToString();
- if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
- asset.Local = true;
- else
- asset.Local = false;
+ string local = dbReader["Local"].ToString();
+ if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
+ asset.Local = true;
+ else
+ asset.Local = false;
- asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
- asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
+ asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
+ asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
- if (m_enableCompression)
+ if (m_enableCompression)
+ {
+ using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
{
- 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);
- }
+ 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"]);
}
+
+ UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
}
}
- catch (Exception e)
- {
- m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
- }
+ }
+ catch (Exception e)
+ {
+ m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
}
}
}
@@ -201,113 +198,110 @@ namespace OpenSim.Data.MySQL
{
// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+
+ using (MySqlTransaction transaction = dbcon.BeginTransaction())
{
- 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(
+ "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Name, asset.ID, asset.Name.Length, assetName.Length);
+ }
- using (MySqlTransaction transaction = dbcon.BeginTransaction())
+ string assetDescription = asset.Description;
+ if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
{
- string assetName = asset.Name;
- if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
- {
- assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
- m_log.WarnFormat(
- "[XASSET 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(
- "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
- asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
- }
+ assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
+ m_log.WarnFormat(
+ "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
+ }
- if (m_enableCompression)
- {
- MemoryStream outputStream = new MemoryStream();
+ if (m_enableCompression)
+ {
+ MemoryStream outputStream = new MemoryStream();
- using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
- {
- // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
- // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
- compressionStream.Close();
- byte[] compressedData = outputStream.ToArray();
- asset.Data = compressedData;
- }
+ using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
+ {
+// Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
+ // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
+ compressionStream.Close();
+ byte[] compressedData = outputStream.ToArray();
+ asset.Data = compressedData;
}
+ }
- byte[] hash = hasher.ComputeHash(asset.Data);
+ byte[] hash = hasher.ComputeHash(asset.Data);
// m_log.DebugFormat(
// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
// asset.ID, asset.Name, hash, compressedData.Length);
+ try
+ {
+ using (MySqlCommand cmd =
+ new MySqlCommand(
+ "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
+ "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
+ dbcon))
+ {
+ // create unix epoch time
+ int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
+ cmd.Parameters.AddWithValue("?ID", asset.ID);
+ cmd.Parameters.AddWithValue("?Hash", hash);
+ cmd.Parameters.AddWithValue("?Name", assetName);
+ cmd.Parameters.AddWithValue("?Description", assetDescription);
+ cmd.Parameters.AddWithValue("?AssetType", asset.Type);
+ cmd.Parameters.AddWithValue("?Local", asset.Local);
+ cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
+ cmd.Parameters.AddWithValue("?CreateTime", now);
+ cmd.Parameters.AddWithValue("?AccessTime", now);
+ cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
+ cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
+ cmd.ExecuteNonQuery();
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
+ asset.FullID, asset.Name, e.Message);
+
+ transaction.Rollback();
+
+ return;
+ }
+
+ if (!ExistsData(dbcon, transaction, hash))
+ {
try
{
using (MySqlCommand cmd =
new MySqlCommand(
- "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
- "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
+ "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
dbcon))
{
- // create unix epoch time
- int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
- cmd.Parameters.AddWithValue("?ID", asset.ID);
cmd.Parameters.AddWithValue("?Hash", hash);
- cmd.Parameters.AddWithValue("?Name", assetName);
- cmd.Parameters.AddWithValue("?Description", assetDescription);
- cmd.Parameters.AddWithValue("?AssetType", asset.Type);
- cmd.Parameters.AddWithValue("?Local", asset.Local);
- cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
- cmd.Parameters.AddWithValue("?CreateTime", now);
- cmd.Parameters.AddWithValue("?AccessTime", now);
- cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
- cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
+ cmd.Parameters.AddWithValue("?Data", asset.Data);
cmd.ExecuteNonQuery();
}
}
catch (Exception e)
{
- m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
+ m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}",
asset.FullID, asset.Name, e.Message);
transaction.Rollback();
return;
}
-
- if (!ExistsData(dbcon, transaction, hash))
- {
- try
- {
- using (MySqlCommand cmd =
- new MySqlCommand(
- "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
- dbcon))
- {
- cmd.Parameters.AddWithValue("?Hash", hash);
- cmd.Parameters.AddWithValue("?Data", asset.Data);
- cmd.ExecuteNonQuery();
- }
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}",
- asset.FullID, asset.Name, e.Message);
-
- transaction.Rollback();
-
- return;
- }
- }
-
- transaction.Commit();
}
+
+ transaction.Commit();
}
}
}
@@ -328,31 +322,28 @@ namespace OpenSim.Data.MySQL
if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
return;
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
- MySqlCommand cmd =
- new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
+ dbcon.Open();
+ MySqlCommand cmd =
+ new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
- try
- {
- using (cmd)
- {
- // create unix epoch time
- cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
- cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
- cmd.ExecuteNonQuery();
- }
- }
- catch (Exception)
+ try
+ {
+ using (cmd)
{
- m_log.ErrorFormat(
- "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
- assetMetadata.ID, assetMetadata.Name);
+ // create unix epoch time
+ cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
+ cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
+ cmd.ExecuteNonQuery();
}
}
+ catch (Exception)
+ {
+ m_log.ErrorFormat(
+ "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
+ assetMetadata.ID, assetMetadata.Name);
+ }
}
}
@@ -411,20 +402,17 @@ namespace OpenSim.Data.MySQL
string ids = "'" + string.Join("','", uuids) + "'";
string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ dbcon.Open();
+ using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
{
- dbcon.Open();
- using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
+ using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader())
+ while (dbReader.Read())
{
- while (dbReader.Read())
- {
- UUID id = DBGuid.FromDB(dbReader["ID"]);
- exists.Add(id);
- }
+ UUID id = DBGuid.FromDB(dbReader["ID"]);
+ exists.Add(id);
}
}
}
@@ -449,43 +437,40 @@ namespace OpenSim.Data.MySQL
{
List retList = new List(count);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
- MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
- cmd.Parameters.AddWithValue("?start", start);
- cmd.Parameters.AddWithValue("?count", count);
+ dbcon.Open();
+ MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
+ cmd.Parameters.AddWithValue("?start", start);
+ cmd.Parameters.AddWithValue("?count", count);
- try
+ try
+ {
+ using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
- using (MySqlDataReader dbReader = cmd.ExecuteReader())
+ while (dbReader.Read())
{
- while (dbReader.Read())
- {
- AssetMetadata metadata = new AssetMetadata();
- metadata.Name = (string)dbReader["Name"];
- metadata.Description = (string)dbReader["Description"];
- metadata.Type = (sbyte)dbReader["AssetType"];
- metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
- metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
- metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
- metadata.CreatorID = dbReader["CreatorID"].ToString();
-
- // We'll ignore this for now - it appears unused!
+ AssetMetadata metadata = new AssetMetadata();
+ metadata.Name = (string)dbReader["Name"];
+ metadata.Description = (string)dbReader["Description"];
+ metadata.Type = (sbyte)dbReader["AssetType"];
+ metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
+ metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
+ metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
+ metadata.CreatorID = dbReader["CreatorID"].ToString();
+
+ // We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]);
- UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
+ UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
- retList.Add(metadata);
- }
+ retList.Add(metadata);
}
}
- catch (Exception e)
- {
- m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
- }
+ }
+ catch (Exception e)
+ {
+ m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
}
}
@@ -496,21 +481,18 @@ namespace OpenSim.Data.MySQL
{
// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id);
- lock (m_dbLock)
+ using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
- {
- dbcon.Open();
-
- using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
- {
- cmd.Parameters.AddWithValue("?ID", id);
- cmd.ExecuteNonQuery();
- }
+ dbcon.Open();
- // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
- // keep a reference count (?)
+ using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
+ {
+ 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 (?)
}
return true;
--
cgit v1.1
From aeadddf77acc627dff017e50335069f7f4aaa1c6 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Mon, 25 Aug 2014 20:29:46 -0400
Subject: Add back URL endings in examples
---
bin/Robust.HG.ini.example | 4 ++--
bin/Robust.ini.example | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example
index fb6531e..684c019 100644
--- a/bin/Robust.HG.ini.example
+++ b/bin/Robust.HG.ini.example
@@ -367,10 +367,10 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset
AllowRemoteSetLoginLevel = "false"
; For V2 map
- MapTileURL = "http://127.0.0.1:8002";
+ MapTileURL = "http://127.0.0.1:8002/";
; Url to search service
- ; SearchURL = "http://127.0.0.1:8002";
+ ; SearchURL = "http://127.0.0.1:8002/";
; For V2/3 Web Profiles
; Work in progress: The ProfileServerURL/OpenIDServerURL are
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example
index 17c3dcd..eafab64 100644
--- a/bin/Robust.ini.example
+++ b/bin/Robust.ini.example
@@ -326,10 +326,10 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto
AllowRemoteSetLoginLevel = "false"
; For V2 map
- MapTileURL = "http://127.0.0.1:8002";
+ MapTileURL = "http://127.0.0.1:8002/";
; Url to search service
- ; SearchURL = "http://127.0.0.1:8002";
+ ; SearchURL = "http://127.0.0.1:8002/";
; For V2/3 Web Profiles
; Work in progress: The ProfileServerURL/OpenIDServerURL are
--
cgit v1.1