From fba9e3f513a0d9b4e0ccaf5a9fe24899d96e98c8 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sun, 23 Nov 2008 20:39:51 +0000
Subject: Don't serve texture preview from other people's objects if you
havenever seen that texture before.
---
OpenSim/Data/MySQL/MySQLRegionData.cs | 52 ++++++++++++++++------
.../Communications/Cache/InventoryFolderImpl.cs | 27 +++++++++++
.../Agent/TextureDownload/TextureDownloadModule.cs | 22 +++++++++
3 files changed, 88 insertions(+), 13 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2e36123..f57d485 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -141,6 +141,14 @@ namespace OpenSim.Data.MySQL
Migration m = new Migration(m_connection, assem, "RegionStore");
m.Update();
+ PrepareConnection();
+ }
+
+ public void Dispose() {}
+
+ private void PrepareConnection()
+ {
+ GetWaitTimeout();
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
@@ -203,8 +211,6 @@ namespace OpenSim.Data.MySQL
}
}
- public void Dispose() {}
-
///
/// Get the wait_timeout value for our connection
///
@@ -254,6 +260,8 @@ namespace OpenSim.Data.MySQL
m_connection.Close();
m_connection = new MySqlConnection(m_connectionString);
m_connection.Open();
+
+ PrepareConnection();
}
}
@@ -308,22 +316,40 @@ namespace OpenSim.Data.MySQL
/// The region UUID
public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{
- lock (m_dataSet)
+ int tries = 3;
+ while (tries > 0)
{
- foreach (SceneObjectPart prim in obj.Children.Values)
+ tries--;
+
+ try
{
- if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0
- && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0)
- {
- //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
- addPrim(prim, obj.UUID, regionUUID);
- }
- else
+ lock (m_dataSet)
{
- // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
+ foreach (SceneObjectPart prim in obj.Children.Values)
+ {
+ if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0
+ && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0)
+ {
+ //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
+ addPrim(prim, obj.UUID, regionUUID);
+ }
+ else
+ {
+ // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
+ }
+ }
+ Commit();
+ return;
}
}
- Commit();
+ catch(MySqlException)
+ {
+ m_connection.Close();
+ m_connection = new MySqlConnection(m_connectionString);
+ m_connection.Open();
+
+ PrepareConnection();
+ }
}
}
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index f78cdee..8e624f9 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -138,6 +138,33 @@ namespace OpenSim.Framework.Communications.Cache
return null;
}
+ public InventoryItemBase FindAsset(UUID assetID)
+ {
+ lock (Items)
+ {
+ foreach (InventoryItemBase item in Items.Values)
+ {
+ if (item.AssetID == assetID)
+ return item;
+ }
+ }
+
+ lock (SubFolders)
+ {
+ foreach (InventoryFolderImpl folder in SubFolders.Values)
+ {
+ InventoryItemBase item = folder.FindAsset(assetID);
+
+ if (item != null)
+ {
+ return item;
+ }
+ }
+ }
+
+ return null;
+ }
+
///
/// Deletes an item if it exists in this folder or any children
///
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index af51df6..8e56afb 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -33,6 +33,7 @@ using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
+using OpenSim.Framework.Communications.Cache;
using BlockingQueue = OpenSim.Framework.BlockingQueue;
namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
@@ -161,6 +162,27 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
public void TextureRequest(Object sender, TextureRequestArgs e)
{
IClientAPI client = (IClientAPI) sender;
+
+ if (e.Priority == 1016001f) // Preview
+ {
+ if (client.Scene is Scene)
+ {
+ Scene scene = (Scene)client.Scene;
+
+ CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
+ if (profile == null) // Deny unknown user
+ return;
+
+ if (profile.RootFolder == null) // Deny no inventory
+ return;
+
+ if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned
+ return;
+
+ m_log.Debug("Texture preview");
+ }
+ }
+
UserTextureDownloadService textureService;
if (TryGetUserTextureService(client, out textureService))
--
cgit v1.1