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"); Migration m = new Migration(m_connection, assem, "RegionStore");
m.Update(); m.Update();
PrepareConnection();
}
public void Dispose() {}
private void PrepareConnection()
{
GetWaitTimeout();
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
@ -203,8 +211,6 @@ namespace OpenSim.Data.MySQL
} }
} }
public void Dispose() {}
/// <summary> /// <summary>
/// Get the wait_timeout value for our connection /// Get the wait_timeout value for our connection
/// </summary> /// </summary>
@ -254,6 +260,8 @@ namespace OpenSim.Data.MySQL
m_connection.Close(); m_connection.Close();
m_connection = new MySqlConnection(m_connectionString); m_connection = new MySqlConnection(m_connectionString);
m_connection.Open(); m_connection.Open();
PrepareConnection();
} }
} }
@ -307,6 +315,13 @@ namespace OpenSim.Data.MySQL
/// <param name="obj">The object</param> /// <param name="obj">The object</param>
/// <param name="regionUUID">The region UUID</param> /// <param name="regionUUID">The region UUID</param>
public void StoreObject(SceneObjectGroup obj, UUID regionUUID) public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{
int tries = 3;
while (tries > 0)
{
tries--;
try
{ {
lock (m_dataSet) lock (m_dataSet)
{ {
@ -324,6 +339,17 @@ namespace OpenSim.Data.MySQL
} }
} }
Commit(); Commit();
return;
}
}
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; 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> /// <summary>
/// Deletes an item if it exists in this folder or any children /// Deletes an item if it exists in this folder or any children
/// </summary> /// </summary>

View File

@ -33,6 +33,7 @@ using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Communications.Cache;
using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Environment.Interfaces.ITextureSender>; using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Environment.Interfaces.ITextureSender>;
namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload 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) public void TextureRequest(Object sender, TextureRequestArgs e)
{ {
IClientAPI client = (IClientAPI) sender; 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; UserTextureDownloadService textureService;
if (TryGetUserTextureService(client, out textureService)) if (TryGetUserTextureService(client, out textureService))