Don't serve texture preview from other people's objects if you

havenever seen that texture before.
0.6.1-post-fixes
Melanie Thielker 2008-11-23 20:39:51 +00:00
parent bb982ab57f
commit fba9e3f513
3 changed files with 88 additions and 13 deletions

View File

@ -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() {}
/// <summary>
/// Get the wait_timeout value for our connection
/// </summary>
@ -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
/// <param name="regionUUID">The region UUID</param>
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)
lock (m_dataSet)
{
//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);
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();
}
}
}

View File

@ -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;
}
/// <summary>
/// Deletes an item if it exists in this folder or any children
/// </summary>

View File

@ -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<OpenSim.Region.Environment.Interfaces.ITextureSender>;
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))